http://stackoverflow.com/q/21562502
has body: I have an android app and I would like to set a link in a textview to open an instagram page if the user has it installed. If not it would open the webpage. I figured out how to check if the app is installed but I am stuck on how to open it and redirect it to the specific page I want boolean instagram = false; try { ApplicationInfo info = getActivity().getPackageManager().getApplicationInfo("com.instagram.android", 0); instagram = true; //open Instagram app and redirect to @ExamplePage } catch (PackageManager.NameNotFoundException e) { instagram = false; //open http://Instagram.com/ExamplePage } The textview &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="@string/follow_zamaaan_link" android:id="@+id/follow_instagram" android:layout_margin="10dp" android:layout_gravity="center_horizontal" android:textColor="@color/link_color" /&gt; Any help or pointers are appreciated.
tagged with: java
has title: Link to page in Instagram app
has answer: http://stackoverflow.com/a/21563308
type: Question
score: 0
answer count: 1
tagged with: textview
tagged with: instagram
type: UnansweredQuestion
tagged with: android
tagged with: http://stackoverflow.com/tag/xml

http://stackoverflow.com/a/21562603
upvote count: 2
type: Answer
score: 2
has body: The Serializable interface gives enough detail in this regard: The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization. If the receiver has loaded a class for the object that has a different serialVersionUID than that of the corresponding sender's class, then deserialization will result in an InvalidClassException. A serializable class can declare its own serialVersionUID explicitly by declaring a field named "serialVersionUID" that must be static, final, and of type long: ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L; If a serializable class does not explicitly declare a serialVersionUID, then the serialization runtime will calculate a default serialVersionUID value for that class based on various aspects of the class, as described in the Java(TM) Object Serialization Specification. However, it is strongly recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and can thus result in unexpected InvalidClassExceptions during deserialization. Therefore, to guarantee a consistent serialVersionUID value across different java compiler implementations, a serializable class must declare an explicit serialVersionUID value. Also you can read more about this in Java Object Serialization Specification
downvote count: 0
answers question: http://stackoverflow.com/q/21562525

http://stackoverflow.com/a/36101789
score: -1
upvote count: 0
type: Answer
has body: import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; import org.springframework.stereotype.Component; @Aspect @Component public class TimeLoggingAspect { @Before("timeLoggingAspect()") public void logBefore(JoinPoint joinPoint){ System.out.println("Method Name="+joinPoint.getSignature().getName()); System.out.println("Logging Before..."); } /* // Other way for AOP implemetation @Pointcut("execution(public void userService())") public void timeLoggingAspect(){ } @After("timeLoggingAspect()") public void logAfter() throws Exception{ System.out.println("Logging After..."); throw new Exception("Error after Logging"); } @AfterThrowing(pointcut="timeLoggingAspect()",throwing="exception") public void logAfterThrowingException(Exception exception){ System.out.println(exception.getLocalizedMessage()); }*/ } /** Config class **/ import org.springframework.stereotype.Component; import com.annotation.EnableMethodVisit; @Component @EnableMethodVisit public class UserService { public void userService(){ System.out.println("user service calling......"); } } /** Custom Annotation are used **/ import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface EnableMethodVisit { } /** UserService **/ import org.springframework.stereotype.Component; import com.annotation.EnableMethodVisit; @Component @EnableMethodVisit public class UserService { public void userService(){ System.out.println("user service calling......"); } } /** AOP Test **/ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import com.aop.classes.UserService; public class SpringAopTest { public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(AspectConfig.cla…
downvote count: 1
answers question: http://stackoverflow.com/q/21588684

http://stackoverflow.com/comment/32620855
comment on: http://stackoverflow.com/a/21592550
type: Comment
has text: @shmkane yes, it does. It has to match what the HTTP server is expecting so it can parse the parameters accordingly. There are a number of ways that you can grab the link, but you'll need to read in the response like you're doing and then somehow parse the response using some sort of standard format. I would suggest you look for tips on parsing html. Alternatively, look for a url that returns json or xml.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32579422
score: 1
has text: Safer way is definitely not using regex. For safe way use HTM/XML parser. btw your regex is removing all HTML tags not just bold, italics etc.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21569138

http://stackoverflow.com/comment/32746819
comment on: http://stackoverflow.com/a/21664511
score: 0
type: Comment
has text: What is the correct result *is* `0`? In general, exceptions or `null` (via autoboxed return type) are preferred over using magic numbers.
type: AnswerComment

http://stackoverflow.com/comment/32584449
type: Comment
type: QuestionComment
has text: Answers become so much simpler if you ask your search engine how to do it using -Java-.
score: 0
comment on: http://stackoverflow.com/q/21571320

http://stackoverflow.com/comment/32768949
score: 0
comment on: http://stackoverflow.com/q/21677767
type: Comment
type: QuestionComment
has text: Try changing your code back to the first version and run it. I'm betting it will work fine.

http://stackoverflow.com/q/21545137
has comment: http://stackoverflow.com/comment/32535752
score: 0
tagged with: java
has title: Recursive statement calling another Recursive statement?
possible better answer: http://stackoverflow.com/a/21545253
has comment: http://stackoverflow.com/comment/32535805
accepted answer: http://stackoverflow.com/a/21545249
type: Question
tagged with: recursion
has body: public class Recursive_Prob { public static void main(String[] args) { out.print("\f"); out.print(m(4)); } public static int m(int a) { if (a &lt; 0) return 0; else return m(a-2) + n(a-1); } public static int n(int b) { if (b &lt;= 0) return 0; else return 1 + n(b-1); } } I had a question asking what the output would be when method m was called with out.print(m(4)); I tried working it out and came out with 0 but the answer was 4 when I ran the code. I ended up with m(a-2) being 0 and that part was right but using the same logic, n(a-1) was also 0 so clearly I'm doing something wrong. Could someone explain how this works?
has answer: http://stackoverflow.com/a/21545323
has answer: http://stackoverflow.com/a/21545285
answer count: 6
tagged with: static-methods
has answer: http://stackoverflow.com/a/21545249
has answer: http://stackoverflow.com/a/21545343
has answer: http://stackoverflow.com/a/21545226
has comment: http://stackoverflow.com/comment/32535687
has answer: http://stackoverflow.com/a/21545253
type: AnsweredQuestion

http://stackoverflow.com/comment/32642468
has text: Don't concatenate parameters, use a `PreparedStatement`
type: Comment
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/21604250

http://stackoverflow.com/a/21554166
type: Answer
answers question: http://stackoverflow.com/q/21548712
has comment: http://stackoverflow.com/comment/32581821
upvote count: 1
score: 1
has body: You can initialise the form fields with the values of the parameters - so that the fields are automatically populated when you return to the form after a login failure. For example, if you have a username and password form field, then you can initialise the value of the fields: &lt;input type="text" name="username" value="${param.username}" /&gt; &lt;input type="password" name="password" value="${param.password}" /&gt;
accepted answer of: http://stackoverflow.com/q/21548712
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/21564157
has comment: http://stackoverflow.com/comment/32576569
upvote count: 1
has comment: http://stackoverflow.com/comment/32658170
favorite count: 0
has comment: http://stackoverflow.com/comment/32698724
has comment: http://stackoverflow.com/comment/32692241
possible better answer: http://stackoverflow.com/a/76995171
tagged with: lotus-notes
type: AnsweredQuestion
downvote count: 0
accepted answer: http://stackoverflow.com/a/21637291
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32666049
tagged with: lotus-domino
type: Question
has answer: http://stackoverflow.com/a/76995171
has answer: http://stackoverflow.com/a/21637291
has body: Basically I'm trying to execute the following code within an lotus notes java agent in a local database to force ignore the host name mismatch for the SSL certificate. HostnameVerifier hv = new HostnameVerifier() { public boolean verify(String urlHostName, SSLSession session) { System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost()); return true; } }; HttpsURLConnection.setDefaultHostnameVerifier(hv); However, I'm encountering an error that says that the access to the particular method is denied java.security.AccessControlException: Access denied (javax.net.ssl.SSLPermission setHostnameVerifier) at java.security.AccessController.throwACE(AccessController.java:100) at java.security.AccessController.checkPermission(AccessController.java:174) at java.lang.SecurityManager.checkPermission(SecurityManager.java:544) at COM.ibm.JEmpower.applet.AppletSecurity.superDotCheckPermission(AppletSecurity.java:1449) at COM.ibm.JEmpower.applet.AppletSecurity.checkPermission(AppletSecurity.java:1617) at COM.ibm.JEmpower.applet.AppletSecurity.checkPermission(AppletSecurity.java:1464) at javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(HttpsURLConnection.java:40) at JavaAgent.NotesMain(JavaAgent.java:45) at lotus.domino.AgentBase.runNotes(Unknown Source) at lotus.domino.NotesThread.run(Unknown Source) I have tried the following code inside the java.policy file but the error remains the same permission javax.net.ssl.SSLPermission “setHostnameVerifier”; I tried the same code in eclipse IDE and ran it and worked well.
has title: Unable to run setDefaultHostnameVerifier
answer count: 2

http://stackoverflow.com/comment/32703184
score: 0
comment on: http://stackoverflow.com/a/21635052
type: Comment
type: AnswerComment
has text: That makes sense. I forgot to take that into consideration.

http://stackoverflow.com/q/21523050
score: 1
tagged with: java
upvote count: 1
type: Question
has title: serialize java objects of different classes into a single row in CSV using JSEFA
answer count: 1
downvote count: 0
favorite count: 0
has body: I am using JSEFA to serialize my java object to into single row in CSV using JSEFA. I have arround 46 fields in one single class , But now the problem is i want to split this class into different sub classes which holds information,One class contains fields of CSV for first 23 positions and next class contains remaining position. When i tried approach of Prefix it is inserting data into two different rows but i need all data of two classes into a single row can some body suggest best approach using JSEFA or any other . First class contains first two fields: @CsvDataType(defaultPrefix = "1") public class TestClass1 implements Serializable { private static final long serialVersionUID = 371968159365574089L; @CsvField(pos = 1) private int id; @CsvField(pos = 2) private String Name; public int getId() { return this.id; } public void setId(final int id) { this.id = id; } public String getName() { return this.Name; } public void setName(final String name) { this.Name = name; } } Sub Class 2 which contains remaining two fields: @CsvDataType(defaultPrefix = "2") public class TestClass2 implements Serializable { private static final long serialVersionUID = 371968159365574089L; @CsvField(pos = 3) private int orderno; @CsvField(pos = 4) private String orderName; public int getOrderno() { return this.orderno; } public void setOrderno(final int orderno) { this.orderno = orderno; } public String getOrderName() { return orderName; } public void setOrderName(String orderName) { this.orderName = orderName; } } main method for combining: public static void main(final String[] args) { final File file = new File("/home/chandra/Documents/dataExcelFiles/final.csv"); file.getParentFile().mkdirs(); Serializer serializer = CsvIOFactory.createFactory(TestClass.class, TestClass2.class).createSerializer(); TestClass prod1 = new TestClass(); prod1.setId(1); prod1.setName("HTC"); TestClass2 prod2 = new TestClass2(); prod2.setOrderno(512); prod2.setOrderName("HTC500"); try { serializer.open(new Fi…
tagged with: serialization
has answer: http://stackoverflow.com/a/22680812
tagged with: http://stackoverflow.com/tag/csv
accepted answer: http://stackoverflow.com/a/22680812
type: AnsweredQuestion

http://stackoverflow.com/a/21540957
has comment: http://stackoverflow.com/comment/32529918
has comment: http://stackoverflow.com/comment/32531491
upvote count: 2
has comment: http://stackoverflow.com/comment/32530972
has body: Actually looking at http://search.maven.org and the pom for that artifact is indeed missing! However the pom later version does exist. Assuming that artifact is backward compatible I think you can fix it simply by upgrading joda-time-jsptags to 1.1. Find and update following dependency on the pom.xml joda-time joda-time-jsptags 1.1 runtime
type: Answer
answers question: http://stackoverflow.com/q/21540699
has comment: http://stackoverflow.com/comment/32530369
score: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/32529608

http://stackoverflow.com/comment/32727984
comment on: http://stackoverflow.com/a/21654159
score: 0
type: AnswerComment
has text: You mean then you should _not_.
type: Comment

http://stackoverflow.com/comment/32754320
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21651102
type: Comment
has text: I am a newbie, I can't say it is the right approach, but it seems nice. *******1. What about defining `html elements` on `page.class` itself using `page factory` instead of defining it in separate class/package naming `objectrepo.class` *******2. What about using `testng groups` to run `testsuite`, is this nice approach??

http://stackoverflow.com/q/21668864
type: UnansweredQuestion
score: -3
upvote count: 0
tagged with: java
type: Question
answer count: 2
has body: I'm trying to get the overall average of the grades. I was able to get the average of each individual grade. Now just to get the total I'm not sure how to get it. My output is: Quizzes:66.0 Labs:88.0 Lab_atendance: 81.0 Midterms:91.0 public static double average(int[] scoreArray, int numScores, int maxGrade, String name) { double sum = 0; for (int i = 0; i &lt; scoreArray.length; i++) { sum += scoreArray[i]; } double average = Math.round((sum / numScores)*100/maxGrade); System.out.println( name + ":" + average+" %"); return average; }
has answer: http://stackoverflow.com/a/21668899
tagged with: arrays
has comment: http://stackoverflow.com/comment/32754029
has title: Getting the overall average
favorite count: 0
has answer: http://stackoverflow.com/a/21668964
downvote count: 3
has comment: http://stackoverflow.com/comment/32754067

http://stackoverflow.com/comment/32764526
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21675326
has text: LinkedHashSet in stead of hashset? (LinkedHashSet keeps the order of insertion)
score: 0

http://stackoverflow.com/q/21667884
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32752613
has answer: http://stackoverflow.com/a/21668003
score: 21
tagged with: java
upvote count: 21
type: Question
tagged with: jodatime
has comment: http://stackoverflow.com/comment/32757949
has comment: http://stackoverflow.com/comment/32752555
has comment: http://stackoverflow.com/comment/32752511
has comment: http://stackoverflow.com/comment/32752546
tagged with: date
has comment: http://stackoverflow.com/comment/32752738
has comment: http://stackoverflow.com/comment/32752610
accepted answer: http://stackoverflow.com/a/21668003
has comment: http://stackoverflow.com/comment/32752683
linked to: http://stackoverflow.com/q/2653567
has body: import java.text.SimpleDateFormat; import java.util.Date; import org.joda.time.*; public class Test { public static void main(String[] args) { String dateStart = "01/01/2000 05:30"; String dateStop = "02/2/2001 06:31"; SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm"); Date d1 = null; Date d2 = null; try { d1 = format.parse(dateStart); d2 = format.parse(dateStop); DateTime dt1 = new DateTime(d1); DateTime dt2 = new DateTime(d2); System.out.print(Years.yearsBetween(dt1, dt2).getYears() + " years, "); System.out.print(Months.monthsBetween(dt1, dt2).getMonths() % 52 + " months, "); System.out.print(Weeks.weeksBetween(dt1, dt2).getWeeks() % 4 + " weeks, "); System.out.print(Days.daysBetween(dt1, dt2).getDays() % 7 + " days, "); System.out.print(Hours.hoursBetween(dt1, dt2).getHours() % 24 + " hours, "); System.out.print(Minutes.minutesBetween(dt1, dt2).getMinutes() % 60 + " minutes, "); } catch (Exception e) { e.printStackTrace(); } } } I want to output the number of years, months, weeks, days, hours, and minutes between two dates using Joda-Time. My question is where do I implement the number of weeks in a month (which in never constant). I don't think my %'s are right either. When run I get: 1 years, 13 months, 0 weeks, 6 days, 1 hours, 1 minutes,
downvote count: 0
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/32752499
has comment: http://stackoverflow.com/comment/32752873
has title: How to calculate difference between two dates in years...etc with Joda-Time
tagged with: time
has comment: http://stackoverflow.com/comment/32752652

java-7
tags question: http://stackoverflow.com/q/21589436
tags question: http://stackoverflow.com/q/21536223
tags question: http://stackoverflow.com/q/21634315
tag name: java-7
tags question: http://stackoverflow.com/q/21516065
tags question: http://stackoverflow.com/q/21529341
tags question: http://stackoverflow.com/q/21635989
type: Tag
tags question: http://stackoverflow.com/q/21615780
tags question: http://stackoverflow.com/q/21664973
tags question: http://stackoverflow.com/q/21672385
tags question: http://stackoverflow.com/q/21653883
tags question: http://stackoverflow.com/q/21556492

http://stackoverflow.com/comment/32528638
type: Comment
type: QuestionComment
has text: @souser If you have one single entry you need to find in your log, slap a UUID on that entry and you are done. But your question seems to be more than that. Do mean something like Susan (or Thread 'A') is running code that makes several log entries, and Bob (or Thread 'B') is running that same code, and given that the log entries look confusingly alike you want to be able to find the collection of Susan's entries from just that one run of code while ignoring Bob's entries?
comment on: http://stackoverflow.com/q/21536572
score: 0

http://stackoverflow.com/a/21538021
upvote count: 3
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21537982
has body: Ya definately implementing class can define its own method as well and if are not implementing all the methods of your abstract class in the derived class then mark this derived class also as Abstract but at the end of chain you have to make one concrete class which implements all the method that was not implement in abstract sub-parent
score: 3

http://stackoverflow.com/comment/32558017
type: QuestionComment
has text: Thanks Divers, that is what I am confused about. I saw different replies for this and I am not 100% sure.
comment on: http://stackoverflow.com/q/21557190
score: 0
type: Comment

http://stackoverflow.com/comment/32686247
type: Comment
comment on: http://stackoverflow.com/a/21630000
has text: Wow! I didn't know that. Thanks, pretty informative. It's seems TestNG don't do that. Good to know as well.
type: AnswerComment
score: 0

http://stackoverflow.com/q/21652416
upvote count: 1
answer count: 1
favorite count: 0
has body: I'm working at a tiled game. I want to check the direction where the tiled is from the player, when is colliding. static public boolean intersectRectangles(Rectangle rectangle1, Rectangle rectangle2, Rectangle intersection) { if (rectangle1.overlaps(rectangle2)) { intersection.x = Math.max(rectangle1.x, rectangle2.x); intersection.width = Math.min(rectangle1.x + rectangle1.width, rectangle2.x + rectangle2.width) - intersection.x; intersection.y = Math.max(rectangle1.y, rectangle2.y); intersection.height = Math.min(rectangle1.y + rectangle1.height, rectangle2.y + rectangle2.height) - intersection.y; return true; } return false; } I want this function to return 0 if there is no collision 1 = rect1 is in the left 2 = rect1 is in the right 3 = rect1 is in the bottom 4 = rect1 is in the top Like this pic: I tried doing this // if there is a collision between player and tile float xdif = player.x + 40 - j * 40; float ydif = player.y + 40 - i * 40; Direction direction = Direction.RIGHT; if (Math.abs(xdif) &gt; Math.abs(ydif)) { if (player.y &gt; i * 40) direction = Direction.DOWN; else direction = direction.UP; } else { if (player.x &gt; j * 40) direction = Direction.LEFT; else direction = direction.RIGHT; } But is not working..
type: UnansweredQuestion
tagged with: collision
downvote count: 0
score: 1
tagged with: java
linked to: http://stackoverflow.com/q/13261767
type: Question
has answer: http://stackoverflow.com/a/21652765
has title: java - get direction of rectangle collision
has comment: http://stackoverflow.com/comment/32725111

http://stackoverflow.com/comment/32654846
type: QuestionComment
has text: You should clarify the line that throws the exception. For instance, is it the one where you declare the payload array?
comment on: http://stackoverflow.com/q/21612393
score: 0
type: Comment

http://stackoverflow.com/q/21592311
has answer: http://stackoverflow.com/a/21593746
downvote count: 1
type: Question
score: -1
has body: In my Struts application the action is not being called after changing my library jar files, instead of that, the page is refreshed. Before changing it's worked fine. Below are the details of my lib folder after changing Files that was changed: struts2-core-2.3.16 struts2-jquery-plugin 3.7.0 struts2-jquery-grid-plugin 3.7.0 xwork-core-2.3.16 ognl-3.0.8 freemaker 2.3.20
tagged with: struts2
answer count: 2
upvote count: 0
tagged with: jar
favorite count: 0
type: UnansweredQuestion
has title: Action is not being called after changing my library jar files in Struts 2
has answer: http://stackoverflow.com/a/21602710
tagged with: java

http://stackoverflow.com/comment/32496870
comment on: http://stackoverflow.com/a/21522953
type: AnswerComment
has text: @user3265048 Aaron explains why it is allowed - essentially as a unicode marker for compilers.
score: 0
type: Comment

jfreechart
type: Tag
tags question: http://stackoverflow.com/q/21622419
tags question: http://stackoverflow.com/q/21631233
tags question: http://stackoverflow.com/q/21558069
tags question: http://stackoverflow.com/q/21628277
tags question: http://stackoverflow.com/q/21549105
tag name: jfreechart
tags question: http://stackoverflow.com/q/21627587
tags question: http://stackoverflow.com/q/21599695

http://stackoverflow.com/a/21622347
score: 0
has body: The main method is not a good candidate for unit testing. It is just an entry point for an application. Probably, you need to refactor your class to some kind of dependency injection. For example: public class Something { private final LinesProvider linesProvider; public Something(LinesProvider linesProvider) { this.linesProvider = linesProvider; } public void sayHello() { String str = linesProvider.readLine(); System.out.println("halo "+str); } public static void main(String args[]) { new Something(new LinesProvider() { private final Console console = System.console(); @Override public String readLine() { return console.readLine(); } }).sayHello(); } } interface LinesProvider { String readLine(); } Then, you can test the system output like shown below, though it's not a good practice. Instead, try to separate I/O logic from application logic: public class TestSomething { private ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); private PrintStream printStream = new PrintStream(outputStream, true); @Before public void setUp() { System.setOut(printStream); } @Test public void test() { new Something(new LinesProvider() { @Override public String readLine() { return "Vasya"; } }).sayHello(); assertEquals("halo Vasya" + System.getProperty("line.separator"), new String(outputStream.toByteArray())); } }
type: Answer
answers question: http://stackoverflow.com/q/21620484

http://stackoverflow.com/comment/32678103
has text: Thanks everyone for all the suggestions and example: This is very great.
comment on: http://stackoverflow.com/a/21625412
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/21643188
accepted answer: http://stackoverflow.com/a/21643219
type: Question
has comment: http://stackoverflow.com/comment/32760929
answer count: 1
score: 0
has comment: http://stackoverflow.com/comment/32739016
has title: Generics with inner class and comparision
tagged with: generics
has body: I am not very good with generics in java. I am getting confused over how to deal with generics when an inner class exists. Below code to implement Binary Search Tree gives me an error. public class BST &lt;T extends Comparable&lt;T&gt;&gt; { Node&lt;T&gt; root; private class Node&lt;T extends Comparable&lt;T&gt;&gt; { T data; Node&lt;T&gt; left, right; Node(T data) { this.data = data; left= right = null; } } public void insert(Node&lt;T&gt; start, T data) { if(start == null) { Node&lt;T&gt; newnode = new Node&lt;T&gt; (data); start = newnode; return; } else if( data &lt; start.data ) //ERROR LINE insert(start.left, data); else if ( data &gt; start.data ) //ERROR LINE insert(start.right, data); else { //no need to do anything as the elements has the same key as the new key return; } } Error: BST.java:29: error: bad operand types for binary operator '&lt;' else if( data &lt; start.data ) first type: T second type: T where T is a type-variable: T extends Comparable&lt;T&gt; declared in class BST.
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32708985
tagged with: java
has comment: http://stackoverflow.com/comment/32709327
has answer: http://stackoverflow.com/a/21643219

http://stackoverflow.com/q/21663558
has answer: http://stackoverflow.com/a/21663662
tagged with: java
tagged with: hibernate
has title: Hibernate 4.3.0 XML Mapping Escape Characters Exception
accepted answer: http://stackoverflow.com/a/21664218
type: AnsweredQuestion
tagged with: sql
type: Question
tagged with: http://stackoverflow.com/tag/xml
has answer: http://stackoverflow.com/a/21664218
has body: In my User.hbm.xml I have: &lt;property name="delete" type="java.lang.String"&gt; &lt;column name="`delete`" /&gt; &lt;/property&gt; I've also tried with '' and [] but all give the same exception: org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"delete" If I change the column name from delete to deletea then it works so I know that it's not escaping the column name properly.
score: 0
possible better answer: http://stackoverflow.com/a/21663662
answer count: 2
tagged with: mysql

http://stackoverflow.com/comment/32535858
type: QuestionComment
has text: @MostyMostacho could u help?
score: 0
comment on: http://stackoverflow.com/q/21544614
type: Comment

http://stackoverflow.com/a/21580087
has comment: http://stackoverflow.com/comment/32598187
has comment: http://stackoverflow.com/comment/32598160
answers question: http://stackoverflow.com/q/21579944
score: 4
upvote count: 4
has body: You have an invalid invisible character between &amp;&amp; and the following space (unicode = 8204): if ((base[i-1][j]!=0) &amp;&amp;‌ (base[i-1][j]!=c))//the error is on this line ^ It works fine if you delete and retype &amp;&amp; (including the space): if ((base[i-1][j]!=0) &amp;&amp; (base[i-1][j]!=c))//the error is on this line
has comment: http://stackoverflow.com/comment/32598141
downvote count: 0
has comment: http://stackoverflow.com/comment/32598243
has comment: http://stackoverflow.com/comment/32598119
type: Answer

http://stackoverflow.com/a/21646819
score: 3
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21646047
type: Answer
answers question: http://stackoverflow.com/q/21646047
has body: Gson has trouble with serialization of Map keys if they are custom objects. The default process would invoke toString() on your key and since key's toString() isn't overridden you might be getting an output like: TravelMode@138532dc and hence the error. To get over this issue you would have to implement Gson Custom Serializer and Deserializer (see the user guide here and their recommendation for other other Library classes as well). Or use Map&lt;String, String&gt; for your implementation.
upvote count: 3

duplicates
tags question: http://stackoverflow.com/q/21557972
tags question: http://stackoverflow.com/q/21613204
tags question: http://stackoverflow.com/q/21562958
type: Tag
tags question: http://stackoverflow.com/q/21517101
tag name: duplicates

http://stackoverflow.com/a/21671301
answers question: http://stackoverflow.com/q/21671280
upvote count: 5
downvote count: 0
has comment: http://stackoverflow.com/comment/32757753
has comment: http://stackoverflow.com/comment/32757711
score: 5
type: Answer
has comment: http://stackoverflow.com/comment/32757877
has comment: http://stackoverflow.com/comment/32757861
has body: Your code is equivalent to: if(a.equals(b)) { } { System.out.printf("Somehow \"%s\" and \"%s\" are the same" ,a,b); } So the print statement in a block that'll be always executed regardless of the condition, since the body of the if doesn't include that statement. See the JLS - 14.6. The Empty Statement: An empty statement does nothing. EmptyStatement: ; Execution of an empty statement always completes normally
has comment: http://stackoverflow.com/comment/32757738

http://stackoverflow.com/a/21552478
has comment: http://stackoverflow.com/comment/32680098
has comment: http://stackoverflow.com/comment/32551212
accepted answer of: http://stackoverflow.com/q/21534316
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32548067
answers question: http://stackoverflow.com/q/21534316
has comment: http://stackoverflow.com/comment/32551721
has comment: http://stackoverflow.com/comment/32548106
has comment: http://stackoverflow.com/comment/32548037
has comment: http://stackoverflow.com/comment/81873496
upvote count: 30
type: Answer
has comment: http://stackoverflow.com/comment/32679466
has comment: http://stackoverflow.com/comment/32548383
has body: Here it is. First, you're gonna buy the ANTLR4 book ;-) Second, you'll download antlr4 jar and the java grammar (http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference) Then, you can change the grammar a little bit, adding these to the header (...) grammar Java; options { language = Java; } // starting point for parsing a java file compilationUnit (...) I'll change a little thing in the grammar just to illustrate something. /* methodDeclaration : (type|'void') Identifier formalParameters ('[' ']')* ('throws' qualifiedNameList)? ( methodBody | ';' ) ; */ methodDeclaration : (type|'void') myMethodName formalParameters ('[' ']')* ('throws' qualifiedNameList)? ( methodBody | ';' ) ; myMethodName : Identifier ; You see, the original grammar does not let you identify the method identifier from any other identifier, so I've commented the original block and added a new one just to show you how to get what you want. You'll have to do the same for other elements you want to retrieve, like the comments, that are currently being just skipped. That's for you :-) Now, create a class like this to generate all the stubs package mypackage; public class Gen { public static void main(String[] args) { String[] arg0 = { "-visitor", "/home/leoks/EclipseIndigo/workspace2/SO/src/mypackage/Java.g4", "-package", "mypackage" }; org.antlr.v4.Tool.main(arg0); } } Run Gen, and you'll get some java code created for you in mypackage. Now create a Visitor. Actually, the visitor will parse itself in this example package mypackage; import java.io.FileInputStream; import java.io.IOException; import mypackage.JavaParser.MyMethodNameContext; import org.antlr.v4.runtime.ANTLRInputStream; import org.antlr.v4.runtime.CommonTokenStream; import org.antlr.v4.runtime.tree.ParseTree; import org.antlr.v4.runtime.tree.ParseTreeWalker; /** * @author Leonardo Kenji Feb 4, 2014 */ public class MyVisitor extends JavaBaseVisitor&lt;Void&gt; { /** * Main Method * * @param args * @throws IOException */ publi…
has comment: http://stackoverflow.com/comment/32680212
score: 29
downvote count: 1
has comment: http://stackoverflow.com/comment/32679497

http://stackoverflow.com/a/21551792
has comment: http://stackoverflow.com/comment/32546910
answers question: http://stackoverflow.com/q/21551723
type: Answer
upvote count: 1
score: 1
downvote count: 0
has body: Try with: String[] resultArray = array[0]; //gets the first row of array
has comment: http://stackoverflow.com/comment/32546945

http://stackoverflow.com/a/21574835
score: 4
has comment: http://stackoverflow.com/comment/32589070
type: Answer
upvote count: 4
has body: 1) Why does line 1 successfully compile? The first line compiles because List&lt;Sub&gt; is subclass of List&lt;? extends Super&gt; and that can only be true if List does not allow you to add any new members to it. ? means that you don't exactly know that it is a List&lt;Sub&gt; or List&lt;Sub1&gt;, so it is unsafe to allow adding of new elements into the list and so it does not allow it. 2) Is line 1 a good practice in declaring a List (or other collections)? If you already know that it is going to be List&lt;Sub&gt; then I don't find any use, but wildcards are used much when you are passing the List around to other classes like Utilities. 3) Why does line 2 fail compilation, after list was declared to be type Sub in line 1? Because as I already explained it is unsafe to add any element to list when you dont know the exact type. 4) Eclipse's autocompletion says only "null" elements are allowed in list now. Why? Because null is of every reference type, this is why you can assign any object a value of null. Always remember PECS (Producer Extends Consumer Super) rule by Josh Bloch when working with generics Good References: Difference between ? extends and ? super When do we require &lt;? extends T&gt; as compared to &lt;T&gt;
has comment: http://stackoverflow.com/comment/32590032
has comment: http://stackoverflow.com/comment/32588937
downvote count: 0
has comment: http://stackoverflow.com/comment/32590078
accepted answer of: http://stackoverflow.com/q/21574696
answers question: http://stackoverflow.com/q/21574696
type: AcceptedAnswer

http://stackoverflow.com/a/21526798
upvote count: 1
score: 1
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21526747
has body: Only One for String s=“Sachin”+“ Tendulkar”;

http://stackoverflow.com/comment/32539727
score: 0
has text: This is strange; we tried with a lot of rows but without problems. maybe a db-driver issue?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21547373

http://stackoverflow.com/q/21570013
score: 2
has answer: http://stackoverflow.com/a/21584691
type: AnsweredQuestion
has body: What I expect for the queue is following: Let say, the queue contains A-B-C-D-E. And I have 3 consumers. What I need is ALL consumers consume the item A before dequeue A and move on to consume B. That's to say, all the consumers get ALL the items in the queue. I have the trade-off solution, which is use 3 ArrayBlockingQueue for 3 consumers. But I'd know to know whether there's such queue.
tagged with: java
tagged with: concurrency
accepted answer: http://stackoverflow.com/a/21570297
tagged with: java.util.concurrent
linked to: http://stackoverflow.com/q/6933347
type: Question
downvote count: 0
answer count: 6
favorite count: 0
has answer: http://stackoverflow.com/a/21607793
has answer: http://stackoverflow.com/a/21787830
has answer: http://stackoverflow.com/a/21570072
has title: Is there any concurrent queue that allow N consumers to consume the item N times separately?
possible better answer: http://stackoverflow.com/a/21570384
has answer: http://stackoverflow.com/a/21570297
has answer: http://stackoverflow.com/a/21570384
upvote count: 2
tagged with: multithreading

http://stackoverflow.com/comment/32545717
score: 0
has text: please Check Code in **AndroidManifest.xml** above, all permission is allowed but application is not opening after install
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/21547006

http://stackoverflow.com/q/21541681
has answer: http://stackoverflow.com/a/21542210
has title: Game board with random game objects and difficulties
favorite count: 0
has comment: http://stackoverflow.com/comment/32531005
has body: I have a game board which I want to fill with random game objects. Lets give them the values 1...6 in an int[10][10] array. The game should have different difficulties. The easier, the more of the same objects are allowed to be next to each other; the harder, the less of the same objects are next to each other (radius=2). Example: Lets assume a medium difficulty. 40% of the objects around an object (radius=2) can be of the same type. -000------ 00000----- 00100----- 00000----- -000------ Only 40% of the 0 are allowed to be of type 1. How can I create such a random array? Or is there a better way to implement difficulty in this case?
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32530862
has answer: http://stackoverflow.com/a/21541905
score: 1
tagged with: java
upvote count: 1
has comment: http://stackoverflow.com/comment/32531674
type: Question
tagged with: arrays
tagged with: random
answer count: 2
downvote count: 0

http://stackoverflow.com/comment/32739568
comment on: http://stackoverflow.com/q/21660471
score: 0
type: Comment
type: QuestionComment
has text: There is no class named A in this jar file. A jar file is a zip file. Unzip it, and you'll see which class files are in this jar. Also, note that putting classes in the defult package is a very bad practice. Shame should be on princeton to do that. And shame on them to put source files in the same jar as class files as well.

http://stackoverflow.com/q/21599852
has comment: http://stackoverflow.com/comment/32632793
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21624395
upvote count: 1
tagged with: object
has body: I have met the foolish case :(, I have tried call Object from another method but always return null (I have added Getter...). Can someone figured out my problem. Here my code: private Email email; public void loadPage() { // Call from init page email = emailDAO.findById(40); // I debugged here and had values } public String changeResetPassword() { // Call by click button event email.getSender(); // Error here - java.lang.NullPointerException } public Email getEmail() { return email; } public void setEmail(Email email) { this.email = email; }
tagged with: java
downvote count: 3
type: Question
answer count: 2
has title: Call Object from another method - JAVA
score: -2
has answer: http://stackoverflow.com/a/21599938
favorite count: 0

http://stackoverflow.com/comment/32542559
score: 0
type: QuestionComment
has text: @KonradRudolph In fact it is 1 million iterations (nested loop) but I can try it again for higher numbers.
type: Comment
comment on: http://stackoverflow.com/q/21540013

http://stackoverflow.com/comment/32614795
comment on: http://stackoverflow.com/a/21589000
type: AnswerComment
type: Comment
has text: Mac Address is not "a String". In Postgres it's an own datatype with its own distinct operators. It's used to define columns in tables, not to create entities (tables)
score: 1

java
tags question: http://stackoverflow.com/q/21658061
tags question: http://stackoverflow.com/q/21548866
tags question: http://stackoverflow.com/q/21643670
tags question: http://stackoverflow.com/q/21517564
tags question: http://stackoverflow.com/q/21630818
tags question: http://stackoverflow.com/q/21576326
tags question: http://stackoverflow.com/q/21527653
tags question: http://stackoverflow.com/q/21617573
tags question: http://stackoverflow.com/q/21558868
tags question: http://stackoverflow.com/q/21614681
tags question: http://stackoverflow.com/q/21629975
tags question: http://stackoverflow.com/q/21650178
tags question: http://stackoverflow.com/q/21562350
tags question: http://stackoverflow.com/q/21518064
tags question: http://stackoverflow.com/q/21570073
tags question: http://stackoverflow.com/q/21564658
tags question: http://stackoverflow.com/q/21637879
tags question: http://stackoverflow.com/q/21621000
tags question: http://stackoverflow.com/q/21563029
tags question: http://stackoverflow.com/q/21668014
tags question: http://stackoverflow.com/q/21565212
tags question: http://stackoverflow.com/q/21605250
tags question: http://stackoverflow.com/q/21667425
tags question: http://stackoverflow.com/q/21554671
tags question: http://stackoverflow.com/q/21588038
tags question: http://stackoverflow.com/q/21654127
tags question: http://stackoverflow.com/q/21537458
tags question: http://stackoverflow.com/q/21537801
tags question: http://stackoverflow.com/q/21515401
tags question: http://stackoverflow.com/q/21672602
tags question: http://stackoverflow.com/q/21562423
tags question: http://stackoverflow.com/q/21604378
tags question: http://stackoverflow.com/q/21635618
tags question: http://stackoverflow.com/q/21659190
tags question: http://stackoverflow.com/q/21586347
tags question: http://stackoverflow.com/q/21677815
tags question: http://stackoverflow.com/q/21676470
tags question: http://stackoverflow.com/q/21647562
tags question: http://stackoverflow.com/q/21544973
tags question: http://stackoverflow.com/q/21515341
tags question: http://stackoverflow.com/q/21628361
tags question: http://stackoverflow.com/q/21627177
tags question: http://stackoverflow.com/q/21588684
tags question: http://stackoverflow.com/q/21639505
tags question: http://stackoverflow.com/q/21566936
tags question: http://stackoverflow.com/q/21576502
tags question: http://stackoverflow.com/q/21657194
tags question: http://stackoverflow.com/q/21653467
tags question: http://stackoverflow.com/q/21561080
tags question: http://stackoverflow.com/q/21632621
tags question: http://stackoverflow.com/q/21633387
tags question: http://stackoverflow.com/q/21569400
tags question: http://stackoverflow.com/q/21629232
tags question: http://stackoverflow.com/q/21549164
tags question: http://stackoverflow.com/q/21675829
tags question: http://stackoverflow.com/q/21633117
tags question: http://stackoverflow.com/q/21667712
tags question: http://stackoverflow.com/q/21566818
tags question: http://stackoverflow.com/q/21617648
tags question: http://stackoverflow.com/q/21670137
tags question: http://stackoverflow.com/q/21570747
tags question: http://stackoverflow.com/q/21609887
tags question: http://stackoverflow.com/q/21597846
tags question: http://stackoverflow.com/q/21612385
tags question: http://stackoverflow.com/q/21618288
tags question: http://stackoverflow.com/q/21540021
tags question: http://stackoverflow.com/q/21662242
tags question: http://stackoverflow.com/q/21589277
tags question: http://stackoverflow.com/q/21544866
tags question: http://stackoverflow.com/q/21647254
tags question: http://stackoverflow.com/q/21586637
tags question: http://stackoverflow.com/q/21569291
tags question: http://stackoverflow.com/q/21531632
tags question: http://stackoverflow.com/q/21586070
tags question: http://stackoverflow.com/q/21670923
tags question: http://stackoverflow.com/q/21636036
tags question: http://stackoverflow.com/q/21651444
tags question: http://stackoverflow.com/q/21637043
tags question: http://stackoverflow.com/q/21561157
tags question: http://stackoverflow.com/q/21615748

http://stackoverflow.com/q/21666357
tagged with: java
has comment: http://stackoverflow.com/comment/32749735
has body: So, I'm experimenting with the Calendar class in Java, and I'm writing a method which returns a Calendar object. What I want for said method is to return a Calendar object containing "Sun Feb 09 22:49:36 +0000 2014". Now I'm (debatably) not lazy and I have done some work on my method. Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat( "EEE MMM dd HH:mm:ss Z yyyy"); try { cal.setTime(sdf.parse("Sun Feb 09 22:49:36 +0000 2014")); } catch (ParseException e) { e.printStackTrace(); } return cal; The problem is it keeps telling me that I got a ParseException, that it's an "Unparseable date". I thought my logic was pretty correct, but I'm starting to doubt it. I'd prefer it without importing any more than Calendar, but SimpleDateFormat seems to be pretty handy too. The less imports the better, I always say. Anyone see how what I want can be achieved? EDIT 1 Tried to run the code in a main method and just print out the result, with no difference in Exception. The following is my main: import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; public class TestingMyCalendar { public static void main(String[] args) { Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat( "EEE MMM dd HH:mm:ss Z yyyy"); try { cal.setTime(sdf.parse("Sun Feb 09 22:49:36 +0000 2014")); } catch (ParseException e) { e.printStackTrace(); } System.out.println(cal); } } For those interested, the following is my entire console text after the main crashed: java.text.ParseException: Unparseable date: "Sun Feb 09 22:49:36 +0000 2014" at java.text.DateFormat.parse(Unknown Source) at TestingMyCalendar.main(TestingMyCalendar.java:15) java.util.GregorianCalendar[time=1391987659892,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/Berlin",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=143,lastRule=java.util.SimpleTimeZone[id=Europe/Berlin,offset=3600000,d…
type: Question
upvote count: 4
has answer: http://stackoverflow.com/a/21667815
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/21666456
accepted answer: http://stackoverflow.com/a/21666433
answer count: 3
has comment: http://stackoverflow.com/comment/32749769
possible better answer: http://stackoverflow.com/a/21666456
score: 4
has comment: http://stackoverflow.com/comment/32749826
tagged with: calendar
has title: Calendar class in Java, ParseException
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32749805
tagged with: simpledateformat
has answer: http://stackoverflow.com/a/21666433

http://stackoverflow.com/q/21545977
has answer: http://stackoverflow.com/a/21546206
downvote count: 0
tagged with: jsp
favorite count: 0
tagged with: struts2
accepted answer: http://stackoverflow.com/a/21546322
answer count: 3
has body: I am using Struts2 iterator tag to display value in JSP. having list called DepotList iterating using following code <s:iterator value="depotList" var="product" status="incr"> <s:property value="depotDescription" /> 0 </s:iterator> it display like below Depot1 0 Depot2 0 Depot3 0 15511 0 but I want to display below manner Depot1 0 Depot2 0 Depot3 0 15511 0 Any idea how to iterate loop to get out put like this?
possible better answer: http://stackoverflow.com/a/21546033
upvote count: 1
has answer: http://stackoverflow.com/a/21546033
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21546322
score: 1
tagged with: java
has title: Struts2 iterator display
type: Question

http://stackoverflow.com/comment/32558735
comment on: http://stackoverflow.com/a/21558030
type: Comment
has text: Yes, I know saveOrUpdate() will check if the entity has an ID. I'm wondering if that check is optimized enough to use all the time instead of checking myself
score: 0
type: AnswerComment

http://stackoverflow.com/q/21561755
downvote count: 0
type: Question
has comment: http://stackoverflow.com/comment/34171865
score: 3
tagged with: java
has title: Eclipse Kepler crashes when I open Marketplace
has comment: http://stackoverflow.com/comment/32568190
tagged with: eclipse
has answer: http://stackoverflow.com/a/34864496
upvote count: 3
answer count: 2
possible better answer: http://stackoverflow.com/a/34864496
favorite count: 0
tagged with: linux
linked to: http://stackoverflow.com/q/21134508
has answer: http://stackoverflow.com/a/21802026
accepted answer: http://stackoverflow.com/a/21802026
type: AnsweredQuestion
tagged with: opensuse
has body: I am trying to use Eclipse 4.3 "Kepler" on openSUSE 13.1 KDE 4.11 Every time I go to open the marketplace under "Help>Marketplace", Eclipse crashes. When I ran eclipse from CLI here is the output: No bp log location saved, using default. [000:000] Cpu: 6.42.7, x4, 2200Mhz, 11952MB [000:000] Computer model: Not available [000:000] Browser XEmbed support present: 1 [000:000] Browser toolkit is Gtk2. [000:000] Using Gtk2 toolkit No bp log location saved, using default. [000:000] Cpu: 6.42.7, x4, 2200Mhz, 11952MB [000:000] Computer model: Not available java version "1.7.0_51" OpenJDK Runtime Environment (IcedTea 2.4.4) (suse-24.13.5-x86_64) OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode) In my .log file I see a few errors, but not sure whats conflicting. Here is my .log file: http://pastebin.com/qpjRnXLM Any ideas?

http://stackoverflow.com/a/21525414
type: Answer
has comment: http://stackoverflow.com/comment/32503298
has comment: http://stackoverflow.com/comment/32505873
score: 0
has comment: http://stackoverflow.com/comment/32501559
answers question: http://stackoverflow.com/q/21522882
has comment: http://stackoverflow.com/comment/32502664
has body: I don't know if this could fit your scenario: Maybe somewhere you can find a better class (and better tested) to do this, but as a example, here is a Reader that reads data from a String List: class SReader extends Reader{ private Iterator&lt;String&gt; iterator; private String currentLine; public SReader(List&lt;String&gt; list){ this.iterator = list.iterator(); if(iterator.hasNext()){ this.currentLine = iterator.next(); } } @Override public int read(char[] cbuf, int off, int len) throws IOException { if(!iterator.hasNext() &amp;&amp; currentLine.isEmpty()){ return -1; } char c;int j = 0; for(int i = 0; i&lt;len; i++){ if(j &lt; currentLine.length()){ c = currentLine.charAt(j); j++; } else{ if(!iterator.hasNext()){ return i; } j = 0; currentLine = iterator.next(); c = '\n';//currentLine.charAt(j); } cbuf[off + i] = c; } currentLine =currentLine.substring(j); return len; } @Override public void close() throws IOException { } } You can use it in your code: List&lt;String&gt; d = Arrays.asList("asdasdasdasdasd", "asdasdasdas", "dasdasda", "dasdasassssssssssssssssssssssssssssssssssssssssssss"); int length = 0; for(String s : d){ length += s.length() + 1; //I assume you want \n after each line } InputStream input = new ReaderInputStream(new SReader(d)); ObjectMetadata metaData = new ObjectMetadata(); metaData.setContentLength(length); s3.putObject(outputBucket,outputFile,input,metaData); Hope it helps.

http://stackoverflow.com/a/21646979
type: Answer
score: 0
has comment: http://stackoverflow.com/comment/32715285
answers question: http://stackoverflow.com/q/21646913
has body: You stuck here: if (x + 1 &lt; size) { run_test(x + 1, y, a, v, size); } if (x &gt; 0) { run_test(x - 1, y, a, v, size); } Because x is always the first or second if- condition.

http://stackoverflow.com/comment/32655028
has text: Maybe you're right. Have you tried it that way?
comment on: http://stackoverflow.com/q/21611976
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32652649
has text: You probably didn't understand me. I meant that I need handler for event, that raised when menuitems are being added to the menu. Sorry for my english
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21609890

http://stackoverflow.com/comment/32527523
score: 0
type: Comment
has text: Thanks for your fast answer! I copied the code and pasted it into my Android Eclipse project and tried to test it again. This time there is no error but when I click the button the text field remains blank and nothing happens.
comment on: http://stackoverflow.com/a/21539760
type: AnswerComment

record
type: Tag
tags question: http://stackoverflow.com/q/21514596
tag name: record

http://stackoverflow.com/comment/32731475
has text: Thanks, that makes since, I just haven't seen a loop for a list before. And about which values I need in the constructor, I actually need x1, y2. I'm using the x1 to determine the horizontal position of the top and bottom half of the pipe, and the y2 has to do with the size of the pipe, how long it is (height). I understand that part might look confusing, but I'm going to keep the values the same for now. I might take the time to redo them later. For example, my y2 value is smaller than my y4 value, and I should probably be using y4 for the height instead of y2.
comment on: http://stackoverflow.com/a/21655763
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33348291
comment on: http://stackoverflow.com/a/21635315
type: Comment
has text: I have another related question. Are you willing to help me solve it? here is the link to the new posting: http://stackoverflow.com/questions/22002272/entity-relationship-not-populating-properly
type: AnswerComment
score: 0

http://stackoverflow.com/comment/32702441
type: Comment
has text: So it's a part of JDT? If it succeeds compiling, how come it doesn't show any warning like yours? what am I missing?
type: AnswerComment
comment on: http://stackoverflow.com/a/21625572
score: 0

http://stackoverflow.com/q/21571579
tagged with: java
type: Question
tagged with: jakarta-ee
has comment: http://stackoverflow.com/comment/32583928
has comment: http://stackoverflow.com/comment/32584231
tagged with: jboss-4.2.x
score: 0
has comment: http://stackoverflow.com/comment/32589067
type: UnansweredQuestion
has title: java.sql.SQLException: Table already exists: JMS_MESSAGES in statement [CREATE CACHED TABLE JMS_MESSAGES]
has body: Please help. I'm getting below error when i start JBOSS 4.2.2 --. 2014-02-05 13:07:21,476 DEBUG [org.jboss.mq.pm.jdbc2.PersistenceManager] Creating Schema 2014-02-05 13:07:21,491 DEBUG [org.jboss.mq.pm.jdbc2.PersistenceManager] Could not create table with SQL: CREATE CACHED TABLE JMS_MESSAGES ( MESSAGEID INTEGER NOT NULL, DESTINATION VARCHAR(255) NOT NULL, TXID INTEGER, TXOP CHAR(1), MESSAGEBLOB OBJECT, PRIMARY KEY (MESSAGEID, DESTINATION) ) java.sql.SQLException: Table already exists: JMS_MESSAGES in statement [CREATE CACHED TABLE JMS_MESSAGES] at org.hsqldb.jdbc.Util.throwError(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source) at org.jboss.resource.adapter.jdbc.CachedPreparedStatement.executeUpdate(CachedPreparedStatement.java:95) at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:251) at org.jboss.mq.pm.jdbc2.PersistenceManager.createSchema(PersistenceManager.java:273) at org.jboss.mq.pm.jdbc2.PersistenceManager.startService(PersistenceManager.java:1789) at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289) at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245) at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978) at com.sun.proxy.$Proxy0.start(Unknown Source) at org.jboss.system.ServiceController.start(ServiceContr…
answer count: 0

http://stackoverflow.com/a/21549213
has comment: http://stackoverflow.com/comment/32543759
answers question: http://stackoverflow.com/q/21548270
type: Answer
has comment: http://stackoverflow.com/comment/32543677
has body: The form is submiting an action name as addUsermenu. In your struts.xml, you have an action tag to point to all the methods, that matches *menu. So your addUsermenu will find its corresponding method. ie addUser(). But in the case of delete you must change the action name to deleteUsermenu inorder to find the function deleteUser() Solution Change the delete Link to this Delete to this <a href="<s:url action='deleteUsermenu'/>">Delete
has comment: http://stackoverflow.com/comment/32545641
has comment: http://stackoverflow.com/comment/32543390
has comment: http://stackoverflow.com/comment/32543601
score: 0

http://stackoverflow.com/q/21667717
answer count: 1
tagged with: widget
tagged with: java
accepted answer: http://stackoverflow.com/a/21669326
upvote count: 1
has body: When I add my widget from the widget page on my phone, it plays the toast message "Button Clicked." The toast is only suppose to be displayed once you push the button, and it works, but it also is displayed when the widget is added to the screen.. I am guessing it may have to do with the super, but I am not exactly sure. Code: @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { final int N = appWidgetIds.length; for (int i=0; i&lt;N; i++) { int appWidgetId = appWidgetIds[i]; Intent intent = new Intent(context, Provider.class); intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0); RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget); views.setOnClickPendingIntent(R.id.onoffbutton, pendingIntent); appWidgetManager.updateAppWidget(appWidgetId, views); } } @Override public void onReceive(Context context, Intent intent) { super.onReceive(context, intent); if (intent.getAction().equals(AppWidgetManager.ACTION_APPWIDGET_UPDATE)) { Toast.makeText(context, "Button Clicked", Toast.LENGTH_SHORT).show(); System.out.println("Click!"); } } EDIT: public static String BUTTON_CLICK = "android.appwidget.action.BUTTON_CLICK"; @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { final int N = appWidgetIds.length; for (int i=0; i&lt;N; i++) { int appWidgetId = appWidgetIds[i]; Intent intent = new Intent(context, Provider.class); intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); Intent clickIntent = new Intent(context, Provider.class); clickIntent.setAction(BUTTON_CLICK); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0); RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget); views.setOnClickPendingIntent(R.id.onoffbutton, pendingIntent); appWidgetManager.updateAppWidget(appWidgetId, views); } } @Override publ…
has title: Android Widget Button Click On Add
type: AnsweredQuestion
tagged with: button
downvote count: 0
score: 1
has answer: http://stackoverflow.com/a/21669326
favorite count: 0
type: Question
tagged with: android

http://stackoverflow.com/q/21595375
has answer: http://stackoverflow.com/a/21595416
has title: Why does the Date class object prints today's date instead of reference of Date class
has answer: http://stackoverflow.com/a/21595418
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/21597723
has answer: http://stackoverflow.com/a/21595425
upvote count: 1
accepted answer: http://stackoverflow.com/a/21595416
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21595425
score: 1
tagged with: java
tagged with: date
type: Question
has body: When we create an object, the object will have the reference of the data members and methods of a class. For Eg: TestObject obj = new TestObject(); System.out.println("Test Object is:"+obj); As per my knowledge, what new operator does is, it creates/ allocates the memory blocks for the specified class(variables and methods) and assigns that reference to the left hand variable (obj). So, the above print statement prints the reference of the TestObject class. But, my question is, when we create an object for Date class and print the object, it prints the today's date. For eg: Date date = new Date(); System.out.println("Date Object is:"+date); The above code prints the today's date. why and how it is printing the date instead of Date class reference. Please help me. Am sorry, if this is a silly question. Even this is silly, I don't have the answer for this question. Brief explanation would be appreciable.
downvote count: 0

http://stackoverflow.com/q/21575452
tagged with: java
has answer: http://stackoverflow.com/a/21575526
type: Question
tagged with: split
answer count: 2
tagged with: arrays
downvote count: 0
has title: Java String's split method ignores empty substrings
tagged with: string
favorite count: 0
score: 11
possible better answer: http://stackoverflow.com/a/21575547
accepted answer: http://stackoverflow.com/a/21575526
tagged with: regex
has answer: http://stackoverflow.com/a/21575547
upvote count: 11
has body: It occured to me today the behavior of java String.split() is very strange. Actually I want to split a string "aa,bb,cc,dd,,,ee" to array by .split(",") that gives me a String array ["aa","bb","cc","dd","","","ee"] of length 7. But when I try to split a String "aa,bb,cc,dd,,,," to array this gives me a array of length 4 means only ["aa","bb","cc","dd"] rejecting all next blank Strings. I want a procedure that splits a String like "aa,bb,cc,dd,,,," to array ["aa","bb","cc","dd","","",""]. Is this possible with java.lang.String api? Thanks in advance.
type: AnsweredQuestion

http://stackoverflow.com/a/21654625
type: Answer
upvote count: 4
has comment: http://stackoverflow.com/comment/32728901
has comment: http://stackoverflow.com/comment/32728959
accepted answer of: http://stackoverflow.com/q/21654581
has comment: http://stackoverflow.com/comment/32729171
answers question: http://stackoverflow.com/q/21654581
downvote count: 0
has comment: http://stackoverflow.com/comment/32729334
score: 4
has comment: http://stackoverflow.com/comment/32729236
has comment: http://stackoverflow.com/comment/32729279
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32729316
has body: You forgot to define the ArrayList of Card cards inside the method displaySuits. private String displaySuits() { ArrayList&lt;Card&gt; cards = hand.getCards(); StringBuilder suits = new StringBuilder(); for (int i = 0; i &lt; cards.size(); i++) { Card card = cards[i]; suits.append(" "); suits.append(card.getRank()); switch (card.getSuit()) { case SPADE: suits.append((char)'\u2660'); break; case DIAMOND: suits.append((char)'\u2666'); break; case CLUB: suits.append((char)'\u2663'); break; case HEART: suits.append((char)'\u2764'); break; } } return suits.toString(); }
has comment: http://stackoverflow.com/comment/32728999
has comment: http://stackoverflow.com/comment/32729033

http://stackoverflow.com/comment/32566839
type: QuestionComment
comment on: http://stackoverflow.com/q/21550831
has text: what's the -Xmx parameter value for the JVM? What's your container?
score: 0
type: Comment

http://stackoverflow.com/a/44383261
type: Answer
score: 0
has body: I had the same problem but found the target of KeyEvent is the TableView, not parent stage, that is why the parent doesn't get Esc event. My variant based on EventHandler (bubbling phase): myTable.setOnKeyReleased(event -&gt; { if (event.getCode() == KeyCode.ESCAPE) { stage.close(); } });
answers question: http://stackoverflow.com/q/21669760

http://stackoverflow.com/a/21635570
upvote count: 9
downvote count: 0
score: 9
type: Answer
has comment: http://stackoverflow.com/comment/32729112
has comment: http://stackoverflow.com/comment/32698804
has body: Note that Jackson does not use java.io.Serializable for anything: there is no real value for adding that. It gets ignored. Given this, Jackson will see values as equivalent of whatever actual type is (for serialization, i.e. writing JSON); or, when reading, as equivalent of java.lang.Object. If you know the actual type, you could annotate property with @JsonDeserialize(as=ActualType.class) to give a hint. But if actual values are Strings and Longs, this really should not be needed.
answers question: http://stackoverflow.com/q/21628361

http://stackoverflow.com/q/21670137
upvote count: 2
possible better answer: http://stackoverflow.com/a/21670647
tagged with: android
has answer: http://stackoverflow.com/a/21670647
tagged with: httpurlconnection
favorite count: 0
tagged with: xmlpullparser
has title: Connection Exception - XMLPullParser
type: AnsweredQuestion
score: 2
downvote count: 0
tagged with: java
type: Question
has body: I'm trying to read the BBC Football RSS. Below is the code I've tried: URL url = new URL("http://feeds.bbci.co.uk/sport/0/football/rss.xml"); XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(false); XmlPullParser xpp = factory.newPullParser(); xpp.setInput(url.openConnection().getInputStream(), "UTF_8"); // -- ERROR - Line 21 But I'm getting Connection exception. Below is the exception in console: java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at java.net.AbstractPlainSocketImpl.connect(Unknown Source) 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 sun.net.NetworkClient.doConnect(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.&lt;init&gt;(Unknown Source) at sun.net.www.http.HttpClient.New(Unknown Source) at sun.net.www.http.HttpClient.New(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at com.testing.code.RssParsing.main(RssParsing.java:21) Any suggestions?
answer count: 2
has answer: http://stackoverflow.com/a/21680602
accepted answer: http://stackoverflow.com/a/21680602

http://stackoverflow.com/comment/32634632
comment on: http://stackoverflow.com/q/21601010
score: 0
type: Comment
type: QuestionComment
has text: Your question is quite unclear, *at least to me*. Could you please elaborate ?

http://stackoverflow.com/comment/32488859
type: AnswerComment
comment on: http://stackoverflow.com/a/21518207
score: 0
type: Comment
has text: output doesn't display... but, There are "+ Integer.valueOf(numLockerTextField.getText()) +" lockers, and "+ runLockers(0) +" are left open."); ... that will display

http://stackoverflow.com/q/21519774
has answer: http://stackoverflow.com/a/21519840
tagged with: java
type: Question
upvote count: 1
answer count: 1
favorite count: 0
has body: I need to put labels and color into each slice. So it should be "Global -- 20%" with a color. I'm still a beginner, please help me out!! import java.awt.*; import java.awt.event.*; import java.awt.font.*; import java.awt.geom.*; import java.awt.image.*; import java.text.*; import javax.swing.*; public class PieChart { public static void main(String[] args) { JFrame f = new JFrame("CMIS242 PieChart"); f.getContentPane().add(new PieChartPanel()); f.setSize(400,400); f.setLocationRelativeTo(null); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); } } class PieChartPanel extends JPanel { BufferedImage image; final int PAD = 30; Font font; NumberFormat numberFormat; public PieChartPanel() { font = new Font("Comic Sans", Font.BOLD, 18); numberFormat = NumberFormat.getPercentInstance(); addMouseListener(new Visibility(this)); addComponentListener(new ComponentAdapter() {}); } protected void paintComponent(Graphics graphics) { super.paintComponent(graphics); Graphics2D graphics2d = (Graphics2D)graphics; graphics2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); createChartImage(); graphics2d.drawImage(image, 0, 0, this); } private void createChartImage() { int[] marks = {10, 24, 30, 36}; int width = getWidth(); int height = getHeight(); int cp = width/2; int cq = height/2; image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); g2.setPaint(Color.white); g2.fillRect(0, 0, width, height); g2.setPaint(Color.black); int pie = Math.min(width,height) - 2*PAD; g2.draw(new Ellipse2D.Double(cp - pie/2, cq - pie/2, pie, pie)); double total = 0; for(int j = 0; j &lt; marks.length; j++) total += marks[j]; double theta = 0, phi = 0; double p, q; for(int j = 0; j &lt; marks.length; j++) { p = cp + (pie/2) * Math.cos(theta); q = cq + (pie/2) * Math.sin(theta); g2.draw(new Line2D.Double(cp, cq, p, q)); phi = (marks[j]/total) * 2 * Math.PI; p = cp + (9*pie/24) * Math.cos(theta + p…
downvote count: 0
has title: How to put the words in label of Pie Chart
type: UnansweredQuestion
tagged with: swing
score: 1

http://stackoverflow.com/comment/32728122
type: Comment
type: QuestionComment
has text: Yep. Java has evolved over time. That means there are always going to be places in the older classes/feature where the newer ones _could_ have been used, but weren't available -- and since things work well enough without them, there hasn't been sufficient justification for doing so. You can of course implement your own wrappers/reinventions of the older classes to use the new features, and if they actually prove useful enough they may be adopted; that is in fact part of how the Java libraries have grown. But that happens only there's enough real added value, and enough demand, to justify it.
comment on: http://stackoverflow.com/q/21653796
score: 0

http://stackoverflow.com/a/21621579
type: Answer
has body: your class name is StoreCommands but you have declared constructor named StoringArray public StoringArray(String fruitsNames, double fno1, int fno2, int fno3) throws Exception { Name = fruitsNames; Number1 = (int) fno1; Number2 = fno1; Number3 = fno3; } replace this by public StoreCommands(String fruitsNames, double fno1, int fno2, int fno3) throws Exception { Name = fruitsNames; Number1 = fno1; //you do not need to cast int because both are int Number2 = fno1; Number3 = fno3; } in for loop change the conditional logic for (StoringArray item : arraysList) if (item.getCommand().equals("Apple")) { } .. it should works now if your other logic and code is ok
has comment: http://stackoverflow.com/comment/32670997
score: 0
answers question: http://stackoverflow.com/q/21620923
has comment: http://stackoverflow.com/comment/32671058
has comment: http://stackoverflow.com/comment/32671252

http://stackoverflow.com/a/21600515
accepted answer of: http://stackoverflow.com/q/21600153
answers question: http://stackoverflow.com/q/21600153
score: 6
has comment: http://stackoverflow.com/comment/32638629
has comment: http://stackoverflow.com/comment/95293946
has body: Not sure if this is what you are asking for. I always use the @PostConstruct annotation in my Spring-beans, to do stuff that needs to be done at startup of the application: @Component public class SchedulerBootstrap { @Autowired MyRepository myRepository; @Autowired OpenPropertyPlaceholderConfigurer configurer; @PostConstruct /** * This method will be called after the bean has been * instantiated and all dependencies injected. */ public void init() { } } Adding an example of how you can write a unit test to experiment with the behaviour of the bean in a Spring context. import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; @ContextConfiguration(locations = {"classpath:spring-context.xml"}) public class BootstrapTest extends AbstractJUnit4SpringContextTests { @Autowired SchedulerBootstrap schedulerBootstrap; @Test public void myTest() { //Some code that berifies that init-method had been called. //Or start unit test in debug-mode and add a breakpoint in the //init-method, you will see it being called before the test is executed. } }
has comment: http://stackoverflow.com/comment/32636383
type: AcceptedAnswer
upvote count: 6
downvote count: 0
type: Answer

http://stackoverflow.com/a/21602155
has comment: http://stackoverflow.com/comment/32637340
has comment: http://stackoverflow.com/comment/32637644
answers question: http://stackoverflow.com/q/21601671
has comment: http://stackoverflow.com/comment/32637544
upvote count: 1
has comment: http://stackoverflow.com/comment/32636913
has comment: http://stackoverflow.com/comment/32637453
has comment: http://stackoverflow.com/comment/32636980
has comment: http://stackoverflow.com/comment/32637261
has comment: http://stackoverflow.com/comment/32637395
has comment: http://stackoverflow.com/comment/32637132
has body: Let's first initialize object of your class Student leaving error checks aside. As you said, you are obliged to set these two fields (fullName and studentId) no matter what. So thats what we would have: public class Student { private String studentId; private String fullName; public Student(String studentId, String fullName) { this.studentId = studentId; this.fullName = fullName; } public static void main(String[] args) { Student s = new Student("12", "John Doe"); } } Above code does what you need in the first place. I hope you understand what is going on there? If not, then ask. OK, what do we need now is adding this "length check". The key is to understand "if" construct. "If" allows you to execute some block of code only if certain condition is met. Condition may be any expression, but it must be evaluated to "true" or "false" (it needs to be boolean). "If" construct looks like this: if (expression) { System.out.println("Expression was true!"); } You can put in place of "expression" your condition and if happens it is true, the code will be executed. See this: if (3 &gt; 2) { System.out.println("Three is greater than two"); } Well, we can use this knowledge to perform our length tests: if (fullName.length() &lt; 4) { System.err.println("Name '" + fullName + "' is too short"); } Use the same construct (but different condition) to test studentId. I believe you should be able to modify the original source to check for string lengths. As to this assignment --- you don't need else construct in this case, but to be complete: you can use it in combination with "if", to execute certain code, when the condition is not met, like this: if (fullName.length() &lt; 4) { System.err.println("Too short!"); } else { System.out.println("OK"); } Hope this helps.
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/32636606
type: Answer
has comment: http://stackoverflow.com/comment/32636747

http://stackoverflow.com/a/21528015
answers question: http://stackoverflow.com/q/21527806
type: Answer
has body: Spring currently supports @Inject as an annotation similar to their @Autowired. You just have to annotate the class to be injected as @Component, @Repository, @Service, or @Controller, or configure the same on Beans.xml. I suggest you to take a look at the documentation: http://docs.spring.io/spring/docs/4.0.1.RELEASE/spring-framework-reference/htmlsingle/#beans-factory-collaborators
score: 0
has comment: http://stackoverflow.com/comment/32518803
has comment: http://stackoverflow.com/comment/32512334

http://stackoverflow.com/comment/32620546
type: QuestionComment
comment on: http://stackoverflow.com/q/21592376
has text: Why's x a dobule BTW, if you're reading int's into it?
score: 0
type: Comment

http://stackoverflow.com/a/21698941
upvote count: 1
downvote count: 0
has body: You can use an ASTVisitor to check the relevant nodes in your AST. You can then use resolveBinding() or resolveTypeBinding() to extract the dependencies. (For this to work you need to turn on "resolveBindings" when you parse.) I haven't tested this, but this example should give you an idea: public static IType[] findDependencies(ASTNode node) { final Set&lt;IType&gt; result = new HashSet&lt;IType&gt;(); node.accept(new ASTVisitor() { @Override public boolean visit(SimpleName node) { ITypeBinding typeBinding = node.resolveTypeBinding(); if (typeBinding == null) return false; IJavaElement element = typeBinding.getJavaElement(); if (element != null &amp;&amp; element instanceof IType) { result.add((IType)element); } return false; } }); return result.toArray(new IType[result.size()]); }
answers question: http://stackoverflow.com/q/21669244
type: Answer
score: 1

http://stackoverflow.com/q/21539458
has comment: http://stackoverflow.com/comment/32528032
has title: Just installed Eclipse, won't run programs or show errors
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32526972
has comment: http://stackoverflow.com/comment/32526668
has body: new here, but I've got a simple question. i have just installed the Eclipse Indigo IDE program on my laptop from my college website, as well as the Java Runtime Environment. While Eclipse itself is working and showing code, it won't run, every time I click on the run button, its says "The Selection can't be launched, and there are no recent launches". It also won't show any errors in the code either. This isn't a one time thing either, as I also downloaded it onto my home computer and it has the same problems. I get the impression I need to further configure it but I don't know what to do, can anyone help?
has comment: http://stackoverflow.com/comment/32526659
has comment: http://stackoverflow.com/comment/32526697
type: Question
has comment: http://stackoverflow.com/comment/32526791
has comment: http://stackoverflow.com/comment/32527112
tagged with: installation
score: 0
tagged with: java
tagged with: eclipse

http://stackoverflow.com/q/21552592
type: UnansweredQuestion
answer count: 0
has title: How to assign XSL value in XSLT from Java Input
tagged with: xslt-1.0
has comment: http://stackoverflow.com/comment/32620927
has body: In my main xml file i have 100 elements but i want only 20 elements from that xml files so i use to transform that xml using XSLT and also create my own xml file and set 20 elements with attributes by my own tag name,but now my problem is i want to select 20 elements out of 100 elements by user interface in my java servlet,so i use checkbox and make display 100 elements from that i check 20 elements it will affect my xslt sheet , my xml schema is &lt;?xml version="1.0" encoding="ISO-8859-1"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/&gt; &lt;xsl:template match="/"&gt; &lt;xsl:element name="Staff_Detail"&gt; &lt;xsl:for-each select="company/Staff"&gt; &lt;xsl:element name="Staff"&gt; // here i have to display my checked element &lt;xsl:value-of select="firstname" /&gt; // here i want to display value of the element &lt;/xsl:element&gt; // i dont want to repeat 20 times to set element name and value &lt;/xsl:for-each&gt; &lt;/xsl:element&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt;
type: Question
tagged with: http://stackoverflow.com/tag/xml
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/32578100
tagged with: xslt
has comment: http://stackoverflow.com/comment/32548249

http://stackoverflow.com/q/21652581
upvote count: 2
type: UnansweredQuestion
downvote count: 1
score: 1
tagged with: java
has title: Tomcat Linux server failed issue
type: Question
has comment: http://stackoverflow.com/comment/32725772
answer count: 1
tagged with: tomcat
favorite count: 0
tagged with: centos
tagged with: linux
has answer: http://stackoverflow.com/a/21653341
has body: It is late on a Friday afternoon, and my web application has stopped responding to requests. The server is still reachable, and the Apache Tomcat process is not running–there are no errors in the logs. You want to go home but you can’t until it is fixed. What do you do? site will run after I restart the server Server admin told me that its " On further investigation, it came into our understanding that Tomcat application is unable to handle the large number for requests coming into the server at the peak business hours in your website or whenever there is a high traffic in the website. It's the reason the Tomcat service is getting hung up or crashed, then only solution is to restart it, so that Tomcat service running. so other time that said heap Size issue" But my website generate only maximum 250 persons each day. Please suggest me what will I do.

http://stackoverflow.com/q/21647885
has comment: http://stackoverflow.com/comment/32717339
tagged with: anonymous-class
upvote count: 1
has comment: http://stackoverflow.com/comment/32721220
answer count: 1
has answer: http://stackoverflow.com/a/21647904
accepted answer: http://stackoverflow.com/a/21647904
favorite count: 0
has comment: http://stackoverflow.com/comment/32717585
has comment: http://stackoverflow.com/comment/32716992
has comment: http://stackoverflow.com/comment/32716893
has title: java, anonymous Inner class issue
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32760389
downvote count: 0
tagged with: inner-classes
has comment: http://stackoverflow.com/comment/32717024
score: 1
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32717416
has body: Let's assume I need a specific application-wide actionListener. For example: public class TestAnonymousInnerClass { private ActionListener closeAction = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } } ... } This code compiles and works fine, but can I say that I have used an anonymous inner class to instantiate this closeAction field? UPD: I am reading the book SG Ganesh, Tushar Sharma - Oracle Certified Professional Java SE 7 Programmer Exams 1Z0-804 and 1Z0-805 (The Expert's Voice in Java) - 2013 And here is the confusing illustration: As follows it is not possible to have anonymous and 'non-local' class. But my class seems to be of that kind because it is not in context of method and still anonymous.

http://stackoverflow.com/comment/32712605
type: AnswerComment
has text: ok so I know the class name is spelt right so how would i add it to the list im passing to javac?
type: Comment
comment on: http://stackoverflow.com/a/21645406
score: 0

http://stackoverflow.com/q/21625296
has body: I'm trying to get my head round the toString() method. I've had a look through google to try and understand the method. Can someone explain the method?
tagged with: tostring
has answer: http://stackoverflow.com/a/35890950
tagged with: java
downvote count: 3
has answer: http://stackoverflow.com/a/21625403
has title: Can someone explain the toString() method
has comment: http://stackoverflow.com/comment/32677124
type: Question
has answer: http://stackoverflow.com/a/21626446
has comment: http://stackoverflow.com/comment/32676937
has answer: http://stackoverflow.com/a/21625370
has comment: http://stackoverflow.com/comment/32676958
answer count: 6
has comment: http://stackoverflow.com/comment/32676863
upvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/21625402
has answer: http://stackoverflow.com/a/21625410
has comment: http://stackoverflow.com/comment/32676921
type: UnansweredQuestion
score: -3

http://stackoverflow.com/comment/32499044
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21524246
type: AnswerComment
has text: @JavaTechnical The button is painted on the `Frame`, so if you click it you also click on the frame :) If you don't want the frame to fire that event, attach an `ActionListener` to the `Button` instead of extending system event queue

http://stackoverflow.com/q/21541052
accepted answer: http://stackoverflow.com/a/21541103
tagged with: jpanel
score: 0
has answer: http://stackoverflow.com/a/21541103
answer count: 1
tagged with: paintcomponent
has comment: http://stackoverflow.com/comment/32529539
has comment: http://stackoverflow.com/comment/32529568
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32529549
tagged with: java
tagged with: swing
has body: I've been trying to make a simple login program with a MYSQL database and when I added the JTextField and JPasswordField anything I paint under the paintComponent method appears to be covered. The problem where I can't see what I paint goes away when I don't add the panel which I need. Here is an example of my code. public void createWindow(){ frame.add(this); frame.setSize(1200, 720); etc.. all the necessary stuff //userfield is my JTextField panel.add(userfield); //This next line is the problem frame.add(panel); } @Override public void paintComponent(Graphics g){ super.paintComponent(g); g.drawString("Hello", 0, 0); }
type: Question
has title: I seem to be painting under the JPanel
has comment: http://stackoverflow.com/comment/32529520

http://stackoverflow.com/comment/32682958
score: 0
type: Comment
has text: Yes of course. Thank you so much for the time and effort, I'm already getting the hang of your code, though I think I'm gonna have a little problem with not simply using a plain color as the outline, but actually using the .png template, but I'm gonna go try and see what I'll end up with and then I'll return here. Thank you!
comment on: http://stackoverflow.com/a/21628037
type: AnswerComment

http://stackoverflow.com/q/21652550
tagged with: outlook
upvote count: 0
score: -1
tagged with: jakarta-mail
has body: Hi I am writing an email that has 2 attachments, one is another email &amp; a text document. Everything works as expected after a few hours of research I cannot seem to fix one problem. Ok, so I know that Outlook which is the program that the email will be opened in stores its emails using a .eml extension. After all the email building I write the attachment email to a tmp file like this. msg.writeTo(new FileOutputStream(new File("/tmp/"+contactName+".eml"))); My goal was to create a 'draft' like email where once you open it all fields like To, CC, Bcc, and subject are already available and editable. If I write it this way the only way to edit those fields is to open the attachment email and hit 'reply-all'. This extra step also includes deleting the text that gets generated like. From: eolnotification@niksun.com [mailto:eolnotification@company.com] Sent: Saturday, February 08, 2014 4:11 PM Subject: NOTICE of End of Life Company products within 90 Days So I figured out that instead of .eml I should use .msg. When I use this it seems to be a permission problem. msg.writeTo(new FileOutputStream(new File("/tmp/"+contactName+".msg"))); Cannot open file: C:\tmp\joe_susie.msg The file may not exist, you may not have permission to open it, or it may be open in another program. Right-click the folder that contains the file, and then click Properties to check your permissions for the folder. I tried all different ways to change permission and nothing works. Someone said it's because of how the file is written to the outputstream. I even tried making a FileOutputStream object and explicitly closed it, that doesn't work either. I know for a fact that a .msg does open editable how I want but with my code it's not working. Does anyone know about this ?
answer count: 1
favorite count: 0
type: UnansweredQuestion
has title: I get a permissions error when trying to open .msg file written with javax
tagged with: java
tagged with: fileoutputstream
downvote count: 1
has answer: http://stackoverflow.com/a/21787532
type: Question

http://stackoverflow.com/a/21621539
upvote count: 1
has comment: http://stackoverflow.com/comment/32671110
accepted answer of: http://stackoverflow.com/q/21621472
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32671177
answers question: http://stackoverflow.com/q/21621472
type: Answer
has comment: http://stackoverflow.com/comment/32671143
has body: I think something like this. public class TheOtherClass implements IMyInterface{ public void doSomething(){} } public class MyClass implements IMyInterface{ // Instance initialization block: // Runs before the constructor each time you instantiate an object { this.doSomething() } public MyClass(){ } IMyInterface theOtherClass = new TheOtherClass (); public void doSomething(){ theOtherClass .doSomething(); //Add more logic here } } Instead of call doSomething in constructor as per this thread link I suggest use the instance initialization blocks read more here
score: 1

http://stackoverflow.com/q/21667834
has comment: http://stackoverflow.com/comment/32752321
favorite count: 0
answer count: 3
has answer: http://stackoverflow.com/a/21668194
has answer: http://stackoverflow.com/a/21668291
possible better answer: http://stackoverflow.com/a/21668001
has answer: http://stackoverflow.com/a/21668001
upvote count: 1
type: AnsweredQuestion
score: 1
tagged with: java
has title: Converting a do-while loop into a for loop in Java
has comment: http://stackoverflow.com/comment/32752310
accepted answer: http://stackoverflow.com/a/21668291
type: Question
tagged with: for-loop
has body: So I had this while loop for a lab in my class I had to make. I then had to convert the loop to a do-while loop to see the difference in design and make sure I got the same results. Now I need to convert it into a for loop, but I don't know how to set up the for statement. Here is how it is currently: do { die1Value = generator.nextInt(6) + 1; die2Value = generator.nextInt(6) + 1; if (die1Value == die2Value) { if (die1Value == 1) { snakeEyes += 1; } else if (die1Value == 2) { twos += 1; } else if (die1Value == 3) { threes += 1; } else if (die1Value == 4) { fours += 1; } else if (die1Value == 5) { fives += 1; } else if (die1Value == 6) { sixes += 1; } } count += 1; }while (count &lt; NUMBER);
downvote count: 0

http://stackoverflow.com/q/21553634
tagged with: http://stackoverflow.com/tag/xml
has answer: http://stackoverflow.com/a/21553689
type: AnsweredQuestion
score: 1
tagged with: java
possible better answer: http://stackoverflow.com/a/21553689
upvote count: 1
tagged with: jaxb
has answer: http://stackoverflow.com/a/21554146
type: Question
answer count: 2
has title: Inheritance with JAXB (unmarshalling)
has body: I have many entities with common properties. There is no xml schema, so I write jaxb entities on my own. abstract class SuperEntity { protected String id; protected String name; @XmlElement public void setId() { .. sets Id .. } @XmlElement public void setName() { .. sets name .. } } // id and name are null after deserialization .. they are completely ignored // there are other entities such as this, I don't want to repeat my code @XmlRootElement @XmlSeeAlso({SuperEntity.class}) class SpecificEntity extends SuperEntity { protected String specificField; @XmlElement public void setSpecificField() { .. sets specific field .. } } SuperEntity is not deserialized (unmarshelled) at all, leaving fields null. If i copy fields and setters from superclass to specific class, it works, but I dont want to just copy that code to every child entity. Thank you for your help.
downvote count: 0
accepted answer: http://stackoverflow.com/a/21554146
favorite count: 0

http://stackoverflow.com/q/21674512
answer count: 1
has comment: http://stackoverflow.com/comment/32763174
tagged with: linux
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32763248
has answer: http://stackoverflow.com/a/21674768
tagged with: java
has body: I have Java application which is running on Linux Ubuntu. My goal is to send email from this application using my own domain, with Java part everything is ok. But do I need to install some mail server? If so, maybe you could suggest less complex one? Maybe I can somehow use gmail or something else, but make emails show my domain?
type: Question
has comment: http://stackoverflow.com/comment/32763290
has comment: http://stackoverflow.com/comment/32764283
has comment: http://stackoverflow.com/comment/32763221
has comment: http://stackoverflow.com/comment/32763317
score: 0
has title: Send mail from Java application
accepted answer: http://stackoverflow.com/a/21674768

http://stackoverflow.com/comment/32573640
type: QuestionComment
has text: Avoid `null` layouts. `JPanel` uses a `FlowLayout` by default, which may be overriding your settings
score: 0
comment on: http://stackoverflow.com/q/21565763
type: Comment

http://stackoverflow.com/comment/32768209
has text: I can't find where it's happens specifically? In which line?
type: QuestionComment
comment on: http://stackoverflow.com/q/21677275
score: 0
type: Comment

http://stackoverflow.com/q/21544746
tagged with: java
tagged with: pls-file
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/21544886
tagged with: internet-radio
favorite count: 0
has body: I have created a simple live streaming radio application. Here a .pls file is parsing for the streaming of the audio from the url . I am getting a NullPointerException. Giving my logcat below : 02-04 04:54:54.409: E/AndroidRuntime(1603): FATAL EXCEPTION: main 02-04 04:54:54.409: E/AndroidRuntime(1603): Process: com.rad, PID: 1603 02-04 04:54:54.409: E/AndroidRuntime(1603): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rad/com.rad.MainActivity}: java.lang.NullPointerException 02-04 04:54:54.409: E/AndroidRuntime(1603): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) 02-04 04:54:54.409: E/AndroidRuntime(1603): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 02-04 04:54:54.409: E/AndroidRuntime(1603): at android.app.ActivityThread.access$800(ActivityThread.java:135) 02-04 04:54:54.409: E/AndroidRuntime(1603): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 02-04 04:54:54.409: E/AndroidRuntime(1603): at android.os.Handler.dispatchMessage(Handler.java:102) 02-04 04:54:54.409: E/AndroidRuntime(1603): at android.os.Looper.loop(Looper.java:136) 02-04 04:54:54.409: E/AndroidRuntime(1603): at android.app.ActivityThread.main(ActivityThread.java:5017) 02-04 04:54:54.409: E/AndroidRuntime(1603): at java.lang.reflect.Method.invokeNative(Native Method) 02-04 04:54:54.409: E/AndroidRuntime(1603): at java.lang.reflect.Method.invoke(Method.java:515) 02-04 04:54:54.409: E/AndroidRuntime(1603): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 02-04 04:54:54.409: E/AndroidRuntime(1603): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 02-04 04:54:54.409: E/AndroidRuntime(1603): at dalvik.system.NativeStart.main(Native Method) 02-04 04:54:54.409: E/AndroidRuntime(1603): Caused by: java.lang.NullPointerException 02-04 04:54:54.409: E/AndroidRuntime(1603): at com.rad.MainActivity.initializeMediaPlayer(MainActivity.java:133) Giving my m…
has answer: http://stackoverflow.com/a/21544865
type: UnansweredQuestion
tagged with: android
has comment: http://stackoverflow.com/comment/32535120
has title: Live Streaming radio application - NullPointerException
upvote count: 1
tagged with: live-streaming
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/32544318
linked to: http://stackoverflow.com/q/218384

http://stackoverflow.com/comment/80566749
comment on: http://stackoverflow.com/a/27303504
type: Comment
has text: DO NOT USE THIS PROPERTY, IF SPRING MANAGES YOUR TRANSACTIONS THIS PROPERTY WILL LEAD TO TRANSACTIONS EXPLOSION, SIMPLY SPRING WILL SHUTDOWN THE APPLICATION
score: 26
type: AnswerComment

http://stackoverflow.com/comment/32607904
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21585052
has text: Can we see your DAO class?

http://stackoverflow.com/q/21675524
has comment: http://stackoverflow.com/comment/32765002
tagged with: android
has comment: http://stackoverflow.com/comment/32764851
accepted answer: http://stackoverflow.com/a/21675669
has comment: http://stackoverflow.com/comment/32764905
has title: Adding a bunch of items to ArrayList correctly
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/32765258
has body: I have a major problem with how I am adding items to my list. In the for loop I have constructed, I am not sure how to continually add elements to the list. I keep adding only one element which overwrites the last element in the list. So if I was to add 2 elements to my list, after the loop has finished, my array list size will be 1. I'm not sure how to add items properly. I know exactly where the problem lies but am struggling to find any clever way of adding correctly. Will really appreciate any help tasklist = db.getAllTasks(); locationlist = db.getAllLocations(); for (int i = 0; i &lt; locationlist.size(); i++) { task_location_list = db.getAllTasksbyLocation(locationlist.get(i) .getAddress()); for (Task task : task_location_list) { task_location_list.add(task); } }
type: Question
score: 0
has comment: http://stackoverflow.com/comment/32766425
answer count: 1
has answer: http://stackoverflow.com/a/21675669
tagged with: arraylist
has comment: http://stackoverflow.com/comment/32765019

http://stackoverflow.com/q/21534518
has answer: http://stackoverflow.com/a/21535749
tagged with: android
has title: Android SimpleCursorAdapter Logcat Error Message
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32517883
has comment: http://stackoverflow.com/comment/32517640
tagged with: java
tagged with: eclipse
linked to: http://stackoverflow.com/q/4974816
type: Question
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/32518040
has body: The results from the logcat after clicking on a button in my application 02-03 12:40:44.015: E/AndroidRuntime(1259): FATAL EXCEPTION: main 02-03 12:40:44.015: E/AndroidRuntime(1259): java.lang.IllegalStateException: Could not execute method of the activity 02-03 12:40:44.015: E/AndroidRuntime(1259): at android.view.View$1.onClick(View.java:3633) 02-03 12:40:44.015: E/AndroidRuntime(1259): at android.view.View.performClick(View.java:4240) 02-03 12:40:44.015: E/AndroidRuntime(1259): at android.view.View$PerformClick.run(View.java:17721) 02-03 12:40:44.015: E/AndroidRuntime(1259): at android.os.Handler.handleCallback(Handler.java:730) 02-03 12:40:44.015: E/AndroidRuntime(1259): at android.os.Handler.dispatchMessage(Handler.java:92) 02-03 12:40:44.015: E/AndroidRuntime(1259): at android.os.Looper.loop(Looper.java:137) 02-03 12:40:44.015: E/AndroidRuntime(1259): at android.app.ActivityThread.main(ActivityThread.java:5103) 02-03 12:40:44.015: E/AndroidRuntime(1259): at java.lang.reflect.Method.invokeNative(Native Method) 02-03 12:40:44.015: E/AndroidRuntime(1259): at java.lang.reflect.Method.invoke(Method.java:525) 02-03 12:40:44.015: E/AndroidRuntime(1259): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 02-03 12:40:44.015: E/AndroidRuntime(1259): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 02-03 12:40:44.015: E/AndroidRuntime(1259): at dalvik.system.NativeStart.main(Native Method) 02-03 12:40:44.015: E/AndroidRuntime(1259): Caused by: java.lang.reflect.InvocationTargetException 02-03 12:40:44.015: E/AndroidRuntime(1259): at java.lang.reflect.Method.invokeNative(Native Method) 02-03 12:40:44.015: E/AndroidRuntime(1259): at java.lang.reflect.Method.invoke(Method.java:525) 02-03 12:40:44.015: E/AndroidRuntime(1259): at android.view.View$1.onClick(View.java:3628) 02-03 12:40:44.015: E/AndroidRuntime(1259): ... 11 more 02-03 12:40:44.015: E/AndroidRuntime(1259): Caused by: java.lang.IllegalArgumentException: column '_id'…
has answer: http://stackoverflow.com/a/21535673
tagged with: sqlite

http://stackoverflow.com/comment/32704207
type: QuestionComment
has text: @mdewitt of course :)
score: 0
type: Comment
comment on: http://stackoverflow.com/q/21639873

http://stackoverflow.com/comment/32503853
has text: "What I want to be able to do is write many lines of code just once and copy and paste it into multiple methods." - Nooooooooooo.
type: QuestionComment
score: 9
comment on: http://stackoverflow.com/q/21527099
type: Comment

http://stackoverflow.com/comment/32614858
type: Comment
has text: The DTOs are created as a result of web service calls all handled from one class run by timer. it goes off,calls a web service,fills in DTOs,persists them,then creates the "entities" which are held in memory.The front end then accesses the entities and mutates them via controller. As for "Why should the pojo know that only people of opposite sex can get married?" (bad example in 21 century!)-isnt that a core part of OOP?So you can say have a CelebrityPerson that overrides marry() and doesnt take their spouses name?Vs a switch on the type in your service layer that acts depending on the type?
type: AnswerComment
comment on: http://stackoverflow.com/a/21588852
score: 0

http://stackoverflow.com/q/21670931
tagged with: opengl-es-2.0
tagged with: android
has answer: http://stackoverflow.com/a/21908376
tagged with: textures
tagged with: text
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/1339136
has title: Android OpenGL ES 2.0: Text aren't showing up
score: 1
tagged with: java
upvote count: 1
type: Question
accepted answer: http://stackoverflow.com/a/21908376
answer count: 2
has body: I have adapted the code from Draw Text in OpenGL ES Android into my app, but the text isn't really showing up. Here's what it currently looks like: The green rectangle box is actually a Drawable bitmap. I am expecting some sort of text, either white or black on top of the background, but nothing is ever showing up. Here's the code for the Text class. package gl.es; import java.nio.*; import android.content.Context; import android.graphics.*; import android.graphics.drawable.Drawable; import android.opengl.*; import android.opengl.Matrix; public class Text { public int textTexture; public FloatBuffer textFloatBuffer; public FloatBuffer textureFloatBuffer; public int bufferSize; public int program; private final int textWidth = 112; private final int textHeight = 16; //private float posX; private int aTextPositionLocation; private int aTexturePositionLocation; private int uMatrixLocation; private int uTextureUnitLocation; public Text(Context context) { program = Shader.buildProgram(context, R.raw.text_vert, R.raw.text_frag); aTextPositionLocation = GLES20.glGetAttribLocation(program, "a_textPosition"); aTexturePositionLocation = GLES20.glGetAttribLocation(program, "a_texturePosition"); uMatrixLocation = GLES20.glGetUniformLocation(program, "u_matrix"); uTextureUnitLocation = GLES20.glGetUniformLocation(program, "u_textureUnit"); textTexture = createTexture(context); setBuffer(); //posX = 0f; } public int createTexture(Context context) { //Create empty mutable bitmap. Bitmap bitmap = Bitmap.createBitmap(textWidth, textHeight, Bitmap.Config.ARGB_8888); //Use Canvas to paint over it. Canvas canvas = new Canvas(bitmap); bitmap.eraseColor(0); //Draw background Drawable background = context.getResources().getDrawable(R.drawable.text_bg); background.setBounds(0, 0, 112, 16); background.draw(canvas); //Draw text Paint textPaint = new Paint(); textPaint.setTextSize(6f); textPaint.setAntiAlias(false); textPaint.setARGB(0xff, 0, 0, 0); //Draw text centered. canvas.drawText("Text…
downvote count: 0
possible better answer: http://stackoverflow.com/a/21671111
has answer: http://stackoverflow.com/a/21671111
favorite count: 0

http://stackoverflow.com/comment/32671761
score: 0
type: Comment
comment on: http://stackoverflow.com/q/21621955
type: QuestionComment
has text: The file is a simple text file to which I write a HashMap, I collect data in Key Value pairs from Contacts, FB and G+. Then I have three tables in the DB to which I write detailed information based on numerous calculations.

http://stackoverflow.com/a/21594382
answers question: http://stackoverflow.com/q/21594229
score: 0
type: Answer
has body: Create an array and store them using an index using: //Create the array int[] arr = new int[3]; //Store the values using the index arr[0] = sc.nextInt(); arr[1] = sc.nextInt(); arr[2] = sc.nextInt();

http://stackoverflow.com/comment/32669157
comment on: http://stackoverflow.com/q/21606180
has text: Hey , thanks for your unswer, the reason i can not use getDate function is because i am overriding function `Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex)` on `javax.swing.table.DefaultTableCellRenderer`, this only gives Object value variable , and not the resultSet it self.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32671661
has text: You should find a detailed answer here: http://stackoverflow.com/questions/14150628/string-constant-pool-java
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21621958

http://stackoverflow.com/q/21604447
has answer: http://stackoverflow.com/a/21604560
has comment: http://stackoverflow.com/comment/32640486
has body: I have a process in Java which starts many daemons internally. While I shut down the original process, I need to perform a graceful shutdown by bringing down all the sub threads as well. How can I accomplish this in Java. Sorry if the question is repititive. I have gone through so many links but have not been able to find a solution for the same. Thanks.
score: 0
has comment: http://stackoverflow.com/comment/32843809
answer count: 1
has title: Java Process management
type: UnansweredQuestion
tagged with: java
tagged with: process
type: Question

http://stackoverflow.com/q/21616614
accepted answer: http://stackoverflow.com/a/21616690
possible better answer: http://stackoverflow.com/a/21616676
type: Question
has answer: http://stackoverflow.com/a/21616676
linked to: http://stackoverflow.com/q/1701839
has comment: http://stackoverflow.com/comment/32663156
has comment: http://stackoverflow.com/comment/32663052
tagged with: java
has comment: http://stackoverflow.com/comment/32662996
answer count: 2
downvote count: 3
has comment: http://stackoverflow.com/comment/32667993
favorite count: 0
tagged with: regex
has body: For my question, I have gone through this thread, but did not get help for my problem. I am using following line: String[] result = s.split("\\",-1); In my Date class and calling: Date date1 = new Date("20\01\2012"); But it does not work. I get an exception: Exception in thread "main" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \ ^ at java.util.regex.Pattern.error(Pattern.java:1924) at java.util.regex.Pattern.compile(Pattern.java:1671) at java.util.regex.Pattern.&lt;init&gt;(Pattern.java:1337) at java.util.regex.Pattern.compile(Pattern.java:1022) at java.lang.String.split(String.java:2313) at Date.&lt;init&gt;(Date.java:84) at Date.main(Date.java:279)
has comment: http://stackoverflow.com/comment/32663283
type: AnsweredQuestion
upvote count: 0
has title: regex "\\" does not work for split() method in java
score: -3
has answer: http://stackoverflow.com/a/21616690

http://stackoverflow.com/comment/32677795
type: AnswerComment
has text: The kid made an effort to hot link an image for you and you don't even _use_ it? WTH :D
type: Comment
comment on: http://stackoverflow.com/a/21625684
score: 0

jframe
tags question: http://stackoverflow.com/q/21638710
tags question: http://stackoverflow.com/q/21639620
tags question: http://stackoverflow.com/q/21548866
tags question: http://stackoverflow.com/q/21584110
tags question: http://stackoverflow.com/q/21572021
tags question: http://stackoverflow.com/q/21636895
tags question: http://stackoverflow.com/q/21581671
tags question: http://stackoverflow.com/q/21677969
tags question: http://stackoverflow.com/q/21652914
tag name: jframe
tags question: http://stackoverflow.com/q/21644014
tags question: http://stackoverflow.com/q/21524128
tags question: http://stackoverflow.com/q/21629330
tags question: http://stackoverflow.com/q/21621096
tags question: http://stackoverflow.com/q/21643817
tags question: http://stackoverflow.com/q/21562350
tags question: http://stackoverflow.com/q/21607385
tags question: http://stackoverflow.com/q/21565810
tags question: http://stackoverflow.com/q/21539847
tags question: http://stackoverflow.com/q/21516570
tags question: http://stackoverflow.com/q/21668115
tags question: http://stackoverflow.com/q/21586765
tags question: http://stackoverflow.com/q/21663590
tags question: http://stackoverflow.com/q/21650420
tags question: http://stackoverflow.com/q/21529667
tags question: http://stackoverflow.com/q/21577712
tags question: http://stackoverflow.com/q/21654735
tags question: http://stackoverflow.com/q/21524781
tags question: http://stackoverflow.com/q/21653445
tags question: http://stackoverflow.com/q/21658696
tags question: http://stackoverflow.com/q/21648885
tags question: http://stackoverflow.com/q/21538625
tags question: http://stackoverflow.com/q/21587972
tags question: http://stackoverflow.com/q/21548588
tags question: http://stackoverflow.com/q/21560817
tags question: http://stackoverflow.com/q/21611508
tags question: http://stackoverflow.com/q/21657220
tags question: http://stackoverflow.com/q/21597308
tags question: http://stackoverflow.com/q/21555968
tags question: http://stackoverflow.com/q/21619170
tags question: http://stackoverflow.com/q/21660699
tags question: http://stackoverflow.com/q/21591491
tags question: http://stackoverflow.com/q/21516365
tags question: http://stackoverflow.com/q/21623787
tags question: http://stackoverflow.com/q/21592492
tags question: http://stackoverflow.com/q/21526631
type: Tag
tags question: http://stackoverflow.com/q/21649835
tags question: http://stackoverflow.com/q/21565763
tags question: http://stackoverflow.com/q/21544969
tags question: http://stackoverflow.com/q/21648533
tags question: http://stackoverflow.com/q/21567437

http://stackoverflow.com/q/21673017
type: Question
score: 0
tagged with: uibinder
has comment: http://stackoverflow.com/comment/32762713
has comment: http://stackoverflow.com/comment/32776692
has comment: http://stackoverflow.com/comment/32779346
tagged with: gwt-gin
answer count: 0
has comment: http://stackoverflow.com/comment/32776798
has title: Deffered binding failed for inner interface exntended UiBinder<T,T>
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32765051
has comment: http://stackoverflow.com/comment/32761862
has comment: http://stackoverflow.com/comment/32776711
has body: ERROR: Error injecting com.avtodoria.tracer.web.client.view.SearchProfileViewImpl$SearchProfileViewUiBinder: Unable to create or inherit binding: No @Inject or default constructor found for com.avtodoria.tracer.web.client.view.SearchProfileViewImpl$SearchProfileViewUiBinder Generally, this error appears if I forgot to annotate constructor SearchProfileViewImpl with @Inject. But: ... import com.google.inject.Inject; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.web.bindery.event.shared.EventBus; ... public class SearchResultViewImpl extends AbstractView implements SearchResultView { interface SearchResultViewUiBinder extends UiBinder&lt;FlowPanel, SearchResultViewImpl&gt; {} @Inject private EventBus eventBus; @UiField(provided = true) CellTable&lt;SearchResultProxy&gt; resultTable; @UiField(provided = true) MapWidget mapWidget; @UiField SearchResultResources res; @UiField Breadcrumbs breadcrumbs; @UiField FlowPanel resultPanel; @UiField Button collapseButton; @UiField NavLink backLink; @UiField NavLink currentSearchPatternNavLink; @UiField Pager pager; @UiField Grid pagerPanel; @UiField FlowPanel container; **@Inject** public SearchResultViewImpl(SearchResultViewUiBinder uiBinder) { prepareResultTable(); prepareMap(); initWidget(uiBinder.createAndBindUi(this)); res.css().ensureInjected(); pager.setDisplay(resultTable); detailsPopup = new SearchResultDetailsPopup(map, DEFAULT_PROJECTION, "resultDetailsPopup", 300, 300); bindEvents(); } ... In the same classes, which use Uibinder too, this error doesn`t appear. Gin Module: public class AppModule extends AbstractGinModule { @Override protected void configure() { bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class); bind(AppView.class).to(AppViewImpl.class); bind(SearchProfileView.class).to(SearchProfileViewImpl.class); bind(AreaSelectView.class).to(AreaSelectViewImpl.class); bind(SearchResultView.class).to(SearchResultViewImpl.class); } ... …
tagged with: gwt
tagged with: java
has comment: http://stackoverflow.com/comment/32812166
has comment: http://stackoverflow.com/comment/32779179

http://stackoverflow.com/a/21527727
upvote count: 1
score: 0
downvote count: 1
has body: You can use a static method factory in your class Entity, and put the constructor private: public class Entity { private String name; private Entity() { } public Entity(String name) { this.name = name; } public static Entity createEntity() { Entity result = new Entity(); result.name = result.toString(); return result; } }
has comment: http://stackoverflow.com/comment/32506753
answers question: http://stackoverflow.com/q/21527523
type: Answer
has comment: http://stackoverflow.com/comment/32505201

network-programming
tags question: http://stackoverflow.com/q/21557542
tags question: http://stackoverflow.com/q/21548686
tags question: http://stackoverflow.com/q/21613838
tags question: http://stackoverflow.com/q/21609609
type: Tag
tags question: http://stackoverflow.com/q/21613843
tags question: http://stackoverflow.com/q/21586735
tags question: http://stackoverflow.com/q/21652003
tags question: http://stackoverflow.com/q/21657118
tags question: http://stackoverflow.com/q/21667712
tag name: network-programming
tags question: http://stackoverflow.com/q/21552695
tags question: http://stackoverflow.com/q/21624101
tags question: http://stackoverflow.com/q/21617263
tags question: http://stackoverflow.com/q/21595000
tags question: http://stackoverflow.com/q/21616059
tags question: http://stackoverflow.com/q/21666785
tags question: http://stackoverflow.com/q/21677864
tags question: http://stackoverflow.com/q/21604680
tags question: http://stackoverflow.com/q/21618118
tags question: http://stackoverflow.com/q/21628146
tags question: http://stackoverflow.com/q/21541684
tags question: http://stackoverflow.com/q/21654855

http://stackoverflow.com/comment/51787944
score: 0
type: AnswerComment
has text: Sorry, i tried this but it does not work well using maven.
type: Comment
comment on: http://stackoverflow.com/a/21727233

http://stackoverflow.com/comment/32526657
comment on: http://stackoverflow.com/a/21539064
type: AnswerComment
has text: my takephoto() method is an action that does not return a boolean. by the way. if i do this i would still get anerror. saying cannot convert void to boolean. thanks
score: 0
type: Comment

http://stackoverflow.com/comment/32547934
score: 0
type: AnswerComment
has text: A classical illustration of my pet peeve: Using the right collection for the job!
comment on: http://stackoverflow.com/a/21552431
type: Comment

http://stackoverflow.com/comment/32567331
type: Comment
comment on: http://stackoverflow.com/a/21562711
type: AnswerComment
has text: As for outputting `depth` in your shader, that is absolutely pointless. I am beginning to hate the book you got these shaders from. You are writing your window-space depth to a color buffer, but you have `glDrawBuffers (GL_NONE)`. Your shader should not even have an output called `depth`, remove that for your own good and use an empty fragment shader for the shadow map creation.
score: 0

http://stackoverflow.com/a/58068722
answers question: http://stackoverflow.com/q/21544973
type: Answer
downvote count: 1
score: 8
upvote count: 9
has body: The best way to convert it to HashMap&lt;String, Object&gt; is this: HashMap&lt;String, Object&gt; result = new ObjectMapper().readValue(jsonString, new TypeReference&lt;Map&lt;String, Object&gt;&gt;(){}));

generics
tags question: http://stackoverflow.com/q/21553532
tags question: http://stackoverflow.com/q/21601168
tags question: http://stackoverflow.com/q/21666635
tags question: http://stackoverflow.com/q/21648735
tags question: http://stackoverflow.com/q/21656769
tags question: http://stackoverflow.com/q/21658622
tags question: http://stackoverflow.com/q/21574696
tags question: http://stackoverflow.com/q/21523071
tags question: http://stackoverflow.com/q/21615142
tags question: http://stackoverflow.com/q/21552300
tags question: http://stackoverflow.com/q/21638562
tags question: http://stackoverflow.com/q/21614919
tags question: http://stackoverflow.com/q/21664875
tags question: http://stackoverflow.com/q/21534224
tags question: http://stackoverflow.com/q/21588671
tags question: http://stackoverflow.com/q/21577493
tags question: http://stackoverflow.com/q/21647501
tags question: http://stackoverflow.com/q/21519706
tags question: http://stackoverflow.com/q/21643188
tags question: http://stackoverflow.com/q/21527894
tags question: http://stackoverflow.com/q/21614675
tags question: http://stackoverflow.com/q/21556925
tags question: http://stackoverflow.com/q/21650068
type: Tag
tags question: http://stackoverflow.com/q/21611416
tags question: http://stackoverflow.com/q/21577453
tags question: http://stackoverflow.com/q/21603541
tags question: http://stackoverflow.com/q/21653796
tags question: http://stackoverflow.com/q/21562868
tags question: http://stackoverflow.com/q/21612231
tags question: http://stackoverflow.com/q/21539844
tags question: http://stackoverflow.com/q/21595633
tags question: http://stackoverflow.com/q/21573815
tags question: http://stackoverflow.com/q/21652601
tags question: http://stackoverflow.com/q/21651032
tags question: http://stackoverflow.com/q/21562284
tags question: http://stackoverflow.com/q/21615337
tags question: http://stackoverflow.com/q/21648079
tags question: http://stackoverflow.com/q/21549988
tags question: http://stackoverflow.com/q/21576082
tags question: http://stackoverflow.com/q/21538003
tags question: http://stackoverflow.com/q/21544716
tags question: http://stackoverflow.com/q/21521054
tags question: http://stackoverflow.com/q/21518482
tags question: http://stackoverflow.com/q/21599824
tags question: http://stackoverflow.com/q/21647271
tags question: http://stackoverflow.com/q/21554309
tags question: http://stackoverflow.com/q/21640002
tags question: http://stackoverflow.com/q/21665555
tags question: http://stackoverflow.com/q/21585258
tags question: http://stackoverflow.com/q/21658187
tags question: http://stackoverflow.com/q/21676884
tag name: generics
tags question: http://stackoverflow.com/q/21651572
tags question: http://stackoverflow.com/q/21664932
tags question: http://stackoverflow.com/q/21601854
tags question: http://stackoverflow.com/q/21671617

http://stackoverflow.com/comment/71976242
has text: Its nor for Android Studio, commented for Eclipse errors
score: 0
comment on: http://stackoverflow.com/a/27167317
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/32661991
comment on: http://stackoverflow.com/q/21616059
has text: @SotiriosDelimanolis HTTP
score: 0
type: Comment
type: QuestionComment

greatest-common-divisor
tags question: http://stackoverflow.com/q/21570890
type: Tag
tag name: greatest-common-divisor

http://stackoverflow.com/comment/32592700
score: 1
has text: by the looks of it, you play with paths the wrong way. please tell us where is your file located, I for one think you may need to use absolute filepaths
comment on: http://stackoverflow.com/q/21577137
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21653403
has body: I would think about these steps: Create a class to map with the data in your CSV. For example, an Athlete class with attributes name, birthday and salary (it's up to you define each data type). Read the CSV file. You can use Scanner or BufferedReader (using a FileReader) to accomplish this. For each line read: Split the string into several strings by comma (,) Create a new Athlete object and parse each string into an attribute to set it into the object. Store the new Athlete in a collection (List or something). Once you completed loading a number of Athletes, save them into your database. Repeat this until you finish reading the csv.
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/21653323
downvote count: 0
type: Answer

http://stackoverflow.com/q/21568516
favorite count: 0
tagged with: multithreading
has answer: http://stackoverflow.com/a/21568647
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21568663
accepted answer: http://stackoverflow.com/a/21568663
downvote count: 0
score: 7
tagged with: java
has comment: http://stackoverflow.com/comment/32578461
linked to: http://stackoverflow.com/q/9580605
type: Question
tagged with: java-memory-model
possible better answer: http://stackoverflow.com/a/21568647
has body: Consider the Java example below. Notice that neither of the class member variables are declared to be volatile. If I am understanding the memory model and "happens before" rules correctly, a Java implementation could optimize the run() method so that it runs forever, even if another thread calls the stopNow() method. This can happen because there is nothing in the run() method that forces the thread to read the value of stop more than once. Is that correct? If not, why not? class Example implements Runnable { boolean stop = false; int value = 0; public void stopNow() { stop = true; } public int getValue() { return value; } @Override public void run() { // Loop until stop is set to true. while (!stop) { ++value; } return; } }
answer count: 2
upvote count: 7
has title: Are assignments to non-volatile member variables in one thread guaranteed to be seen in another thread?

http://stackoverflow.com/a/21625923
type: Answer
has body: I don't think what you want to do is possible in the SFTP protocol. You will have to create each sub-directory in turn.
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/21625602
downvote count: 0

http://stackoverflow.com/q/21604480
tagged with: overriding
tagged with: sorting
tagged with: comparable
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/21604588
has title: Java - Unable to sort a user defined array after overriding Comparable's compareTo method
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21604572
has comment: http://stackoverflow.com/comment/32640689
tagged with: java
has body: So, I am simply trying to test out how to use the compareTo method on my own types, and cannot get it to work for even the simplest of cases. My code (self explanatory) is below (it creates an array of 'numbers' from 15 -> 1 under the user defined type TestType. I would like it to be sorted 'naturally'. public class TestType implements Comparable&lt;TestType&gt; { public int n; TestType(int _n) { n = _n; } @Override public int compareTo(TestType otherType) { return this.n &lt; otherType.n ? -1 : (this.n &gt; otherType.n ? 1 : 0); } public static void main(String[] args){ TestType[] a = new TestType[15]; for(int i = 0; i &lt; 15; i++){ a[i] = new TestType(15 - i); System.out.println(a[i].n); } a.sort(); } } If you can see why it doesn't work, please let me know :) .
type: Question
tagged with: compareto

http://stackoverflow.com/comment/32716119
score: 0
comment on: http://stackoverflow.com/q/21647403
has text: updated now having the download method :D
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21642268
answer count: 3
linked to: http://stackoverflow.com/q/13702100
has title: Adding a cookie to my HTML page?
type: UnansweredQuestion
tagged with: http://stackoverflow.com/tag/html
tagged with: cookies
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21642370
tagged with: addressbook
has answer: http://stackoverflow.com/a/21642325
has body: I have looked around stackoverflow for an answer to my question, but I dont totally understand them or they dont work for me. I am creating an address book for an assignment and I want to be able to keep the names of the people I add without using a data base. I want to be able to make a cookie that can store the info of the person. This is my assignment so far: http://pastebin.com/4vX2h0A0 Its nothing special, but i would really appreciate if someone could help :D
score: 0
has answer: http://stackoverflow.com/a/21642317

http://stackoverflow.com/a/38262680
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/66070271
upvote count: 21
has body: With existing Hamcrest libraries (as of v.2.0.0.0) you are forced to use Collection.toArray() method on your Collection in order to use containsInAnyOrder Matcher. Far nicer would be to add this as a separate method to org.hamcrest.Matchers: public static &lt;T&gt; org.hamcrest.Matcher&lt;java.lang.Iterable&lt;? extends T&gt;&gt; containsInAnyOrder(Collection&lt;T&gt; items) { return org.hamcrest.collection.IsIterableContainingInAnyOrder.&lt;T&gt;containsInAnyOrder((T[]) items.toArray()); } Actually I ended up adding this method to my custom test library and use it to increase readability of my test cases (due to less verbosity).
answers question: http://stackoverflow.com/q/21624592
score: 21

http://stackoverflow.com/q/21587345
score: -1
has comment: http://stackoverflow.com/comment/32611882
has body: Nothing happens when I use the method "frageStellen" - why? I want my computer to return the answer from the HashMap "ratschlagMap" which fits to "frage". import java.util.HashMap; public class Kapitän { private HashMap&lt;String, String&gt; ratschlagMap; public Kapitän() { ratschlagMap = new HashMap&lt;String, String&gt;(); antwortenGenerieren(); } public void antwortenGenerieren() { ratschlagMap.put("hallo", "Guten Tag, mein Herr!"); ratschlagMap.put("wetter", "Es riecht nach Sturm!"); ratschlagMap.put("liebe", "Die Liebe ist wie die See: erst stürmisch, dann flaut sie ab..."); ratschlagMap.put("zukunft", "Erst die Segel setzten, dann übers Ziel nachdenken!"); } public void frageStellen (String frage) { frage.toLowerCase(); if (ratschlagMap.containsKey(frage)) { ratschlagMap.get(frage); } } } Thanks!!
upvote count: 0
has title: HashMap does not work
favorite count: 0
type: UnansweredQuestion
answer count: 4
has answer: http://stackoverflow.com/a/21587403
has comment: http://stackoverflow.com/comment/32611893
has answer: http://stackoverflow.com/a/21587448
has comment: http://stackoverflow.com/comment/32612382
downvote count: 1
has answer: http://stackoverflow.com/a/21587381
type: Question
has answer: http://stackoverflow.com/a/21587476
tagged with: hashmap
tagged with: java

http://stackoverflow.com/q/21574236
has title: How to fix org.hibernate.LazyInitializationException - could not initialize proxy - no Session
has answer: http://stackoverflow.com/a/25056258
type: Question
has answer: http://stackoverflow.com/a/29601232
has answer: http://stackoverflow.com/a/49980166
has answer: http://stackoverflow.com/a/40284778
has answer: http://stackoverflow.com/a/71146636
upvote count: 302
has answer: http://stackoverflow.com/a/36001361
possible better answer: http://stackoverflow.com/a/32276916
has answer: http://stackoverflow.com/a/53005977
tagged with: session
has answer: http://stackoverflow.com/a/64829771
has answer: http://stackoverflow.com/a/32276916
has answer: http://stackoverflow.com/a/39372379
has answer: http://stackoverflow.com/a/39465150
has body: I get the following exception: Exception in thread "main" org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:167) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:215) at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190) at sei.persistence.wf.entities.Element_$$_jvstc68_47.getNote(Element_$$_jvstc68_47.java) at JSON_to_XML.createBpmnRepresantation(JSON_to_XML.java:139) at JSON_to_XML.main(JSON_to_XML.java:84) when I try to call from main the following lines: Model subProcessModel = getModelByModelGroup(1112); System.out.println(subProcessModel.getElement().getNote()); I implemented the getModelByModelGroup(int modelgroupid) method firstly like this : public static Model getModelByModelGroup(int modelGroupId, boolean openTransaction) { Session session = SessionFactoryHelper.getSessionFactory().getCurrentSession(); Transaction tx = null; if (openTransaction) { tx = session.getTransaction(); } String responseMessage = ""; try { if (openTransaction) { tx.begin(); } Query query = session.createQuery("from Model where modelGroup.id = :modelGroupId"); query.setParameter("modelGroupId", modelGroupId); List&lt;Model&gt; modelList = (List&lt;Model&gt;)query.list(); Model model = null; for (Model m : modelList) { if (m.getModelType().getId() == 3) { model = m; break; } } if (model == null) { Object[] arrModels = modelList.toArray(); if (arrModels.length == 0) { throw new Exception("Non esiste "); } model = (Model)arrModels[0]; } if (openTransaction) { tx.commit(); } return model; } catch(Exception ex) { if (openTransaction) { tx.rollback(); } ex.printStackTrace(); if (responseMessage.compareTo("") == 0) { responseMessage = "Error" + ex.getMessage(); } return null; } } and got the exception. Then a friend suggested me to always test the session and get the current s…
has answer: http://stackoverflow.com/a/57030407
has answer: http://stackoverflow.com/a/77326239
has answer: http://stackoverflow.com/a/42987719
has answer: http://stackoverflow.com/a/53066107
has answer: http://stackoverflow.com/a/36511384
favorite count: 0
has answer: http://stackoverflow.com/a/72014614
tagged with: lazy-loading
answer count: 26
has answer: http://stackoverflow.com/a/21575368
accepted answer: http://stackoverflow.com/a/21575368
has answer: http://stackoverflow.com/a/32214318
linked to: http://stackoverflow.com/q/1103363
linked to: http://stackoverflow.com/q/25362831
linked to: http://stackoverflow.com/q/28246182
has answer: http://stackoverflow.com/a/50882857
type: AnsweredQuestion
score: 302
has answer: http://stackoverflow.com/a/27303504
downvote count: 0
tagged with: java
tagged with: hibernate
tagged with: orm
has answer: http://stackoverflow.com/a/46319489
has answer: http://stackoverflow.com/a/79373695
has answer: http://stackoverflow.com/a/69611021
has answer: http://stackoverflow.com/a/67970860
has answer: http://stackoverflow.com/a/73204456

http://stackoverflow.com/q/21527806
type: UnansweredQuestion
tagged with: spring
has body: I am used to have the @Inject Instance&lt;Interface&gt; xxx construction that will inject a new instance of each class that implements the interface. This is very useful because I do not need to know how many or who are these classes in order to instantiate them, and I can iterate them without knowing how many are they. Now I don't know how to reproduce this behavior with Spring. Can you help me? Thanks,
tagged with: java
has title: How to reproduce weld Instance behavior on Spring
has answer: http://stackoverflow.com/a/21528015
has answer: http://stackoverflow.com/a/21531856
type: Question
upvote count: 4
downvote count: 0
score: 4
answer count: 3
favorite count: 0
tagged with: cdi
has answer: http://stackoverflow.com/a/27878298

http://stackoverflow.com/comment/32647257
comment on: http://stackoverflow.com/a/21607755
has text: You could use BufferedReader to read the inputs from user and then it will be stored in string. You can tokenize the string to get multiple numbers as string array. You can do a lot of things, just go out there and experiment.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32667097
type: QuestionComment
comment on: http://stackoverflow.com/q/21618257
score: 0
type: Comment
has text: I was not attempting guesswork, and was only trying to apply what I read in aforementioned documentation. I appreciate the time you take to offer feedback, but I don't feel it necessary to be rude. In any case, I have re-read the doc, and it doesn't sufficiently answer the question I have. It simply covers setting those two paths, not troubleshooting compilation errors on a multi-class file package.

http://stackoverflow.com/comment/32732784
comment on: http://stackoverflow.com/a/21656109
score: 0
type: AnswerComment
type: Comment
has text: Yes. I agree that singletons can be evil if not used correctly, however when I need to ensure that there is only ever one instance of an object like a logging or caching mechanism in existence, there really is no better way. The reason that I did not initially subclass the singleton was due to the fact that the singleton has no default constructor, so I can not add my own private constructor in the subclass to initialize the object.

http://stackoverflow.com/q/21661492
has comment: http://stackoverflow.com/comment/32740630
type: Question
has comment: http://stackoverflow.com/comment/32740620
has comment: http://stackoverflow.com/comment/32741159
tagged with: java
score: -1
has title: Nested for Loop Statements Java
downvote count: 1
answer count: 1
favorite count: 0
has body: I am currently trying to create a nested for Loop statement using java, how do I Create new nested for Loop statement using java which gives the following output: 8 5 5 5 6 5 8 9 5 6 8 7 7 8 7 6 7 8 8 9 7 8 7 6 7 8 7 5 6 8 7 9 9 9 8 9 7 9 8 9 9 7 8 8 7 8 7 8 9 6 8 6 5 6 4 5 6 5 6 6 6 7 8 7 7 6 8 7 8 6 6 5 7 6 7 6 7 6 7 7 7 the above numbers are stored in a text file called data1.txt but need to be displayed properly as ints using a 2D array, Below is my attempt at the code: import java.util.*; import java.io.*; /** * class ReadMarks simulates storing student data in a collection. * * @author * @version 09 Feburary 2014 */ public class ReadMarks { /** * Constructor for objects of class ReadMarks */ public ReadMarks() { } /** * An example of a method - replace this comment with your own * */ public void readMarksData(String fileName) throws FileNotFoundException { File dataFile = new File(fileName); Scanner scanner = new Scanner(dataFile); while( scanner.hasNext() ) { String info = scanner.nextLine(); System.out.println(info); } scanner.close(); } for (int i= 0; i <8; i++) for (int j=1; j<=i; j++) System.out.print(i*j + "\t"); } for (int row=1; row<=10; row++) { for (int col=1; col<=8; col++) System.out.print(row*col + "\t"); System.out.println(); } any answers or replies would be greatly appreciated
type: UnansweredQuestion
upvote count: 0
has comment: http://stackoverflow.com/comment/32740650
has answer: http://stackoverflow.com/a/21661862
has comment: http://stackoverflow.com/comment/32741150

http://stackoverflow.com/comment/50315672
score: 0
type: Comment
has text: thank you so much :) I have accepted your answer and ticked as useful too, and will award you bounty after 5 hours.. this is the most easiest way of doing this ... Salute you, and one more thing - like i have selected 6 Jul 2015 in first spinner and now i want to show date from 7 Jul 2015 (again with next 30 days) in second spinner (just like hotel check in and check out) functionality .. I have posted activity code check above and please let me know where i have to make changes - place code in your new EDITED section
type: AnswerComment
comment on: http://stackoverflow.com/a/31139170

http://stackoverflow.com/comment/32725236
type: Comment
type: QuestionComment
has text: Did you remove override annotation ?
comment on: http://stackoverflow.com/q/21652509
score: 0

http://stackoverflow.com/a/21598393
downvote count: 0
has body: Similar to this question on SO I had to add the following code prior doing any FS activities: configuration.set("fs.webhdfs.impl", org.apache.hadoop.hdfs.web.WebHdfsFileSystem.class.getName()); I don't know why, but there seems to be something wrong with the Maven build process... for now it works.
score: 4
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21597420
answers question: http://stackoverflow.com/q/21597420
type: Answer
upvote count: 4

http://stackoverflow.com/comment/32763824
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21674665
has text: i have not write editor.commit() in oode when trying to write there getting error
score: 0

http://stackoverflow.com/a/21636515
has comment: http://stackoverflow.com/comment/32698006
score: 2
has body: You ware almost there. Change (?&lt;!XYZ\\d{8}) to (?&lt;!XYZ\\d{0,7}). You need to check if your match is not part of previous identifier XYZ\\d{8} which means it cant have XYZ XYZ1 XYZ12 ... XYZ1234567 before it. Demo based on your examples String[] data ={ "XYZ12345678123456789123", //123456789123 "123456789123", //123456789123 "XYZ12345678REF123456789123 ", //REF123456789123 "12345678912", //no match because not 12 digits "REF123456789123", //REF123456789123 "REF12345678912", //no match because not 12 digits "XYZ12345678123456789123ABC", //123456789123 "XYZ123456789123", //no match "XYZ1234567891234", //no match }; Pattern p = Pattern.compile("(?&lt;!XYZ\\d{0,7})(?&gt;REF[A-Z]*)?(\\d{3}+)(\\d{6}+)(\\d{3}+)"); for (String s:data){ System.out.printf("%-30s",s); Matcher m = p.matcher(s); while (m.find()) System.out.print("match: "+m.group()); System.out.println(); } output: XYZ12345678123456789123 match: 123456789123 123456789123 match: 123456789123 XYZ12345678REF123456789123 match: REF123456789123 12345678912 REF123456789123 match: REF123456789123 REF12345678912 XYZ12345678123456789123ABC match: 123456789123 XYZ123456789123 XYZ1234567891234
accepted answer of: http://stackoverflow.com/q/21635681
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21635681
has comment: http://stackoverflow.com/comment/32698667
type: Answer
upvote count: 2

http://stackoverflow.com/comment/32695483
type: QuestionComment
has text: @zapl: So you mean that `wait(1)` may use even more time than just `wait()` and `notify()`? Okey, you got me, now I really need to test it. ;)
score: 0
comment on: http://stackoverflow.com/q/21633246
type: Comment

http://stackoverflow.com/comment/32611777
score: 0
type: Comment
type: QuestionComment
has text: MadProgrammer, I have looked at your answers before but I could not find what I looked for. JohnGardner, Do not know much about overlapping controls. I searched on internet about what you mean. As far as I understand this happens because of jbuttons. Actually I will not use Jbuttons instead I will use some graphical objects on panels. My main question could I get component at location with z-order? I want to use swing to not reinvent the wheel. However, If this is not possible with swing i will not use it instead I will do all the things with java graphics.
comment on: http://stackoverflow.com/q/21586025

http://stackoverflow.com/q/21672612
score: 0
answer count: 2
linked to: http://stackoverflow.com/q/21623979
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32811180
has answer: http://stackoverflow.com/a/21674138
has body: Display only selective columns in collection { "_id": ObjectId("52f4a5ed07b0f7106a9d5e4c"), "FM_ID":"1253", "passwd": ".aDoSkljf_h+6589q76w3rJK", "Area": { "0": { "X": "53543500", "Y": "14031500", "images": { "0": { "ImgId": ObjectId("52f4a5a107b0f7106a9d1a84"), "ImageType": NumberInt(15) }, "1": { "ImgId": ObjectId("52f4a5a107b0f7106a9d1a87"), "ImageType": NumberInt(2) } } }, "1": { "X": "53543500", "Y": "14094572", "images": { "0": { "ImgId": ObjectId("52f4a5a107b0f7106a9d1aa8"), "ImageType": NumberInt(15) }, "1": { "ImgId": ObjectId("52f4a5a107b0f7106a9d1aab"), "ImageType": NumberInt(2) } } }, "2": { "X": "53480464", "Y": "14031500", "images": { "0": { "ImgId": ObjectId("52f4a5a107b0f7106a9d1acc"), "ImageType": NumberInt(15) } } } } } I want to display only selective data in collection BasicDBObject have following fields B.append("FM_ID", 1); B.append("_id", 1); B.append("Area.$.$.images$.$.ImageType", 1); My requirement is only display the FM_ID,_id,and ImageType
tagged with: java
has title: Get only selective column in MongoDB
has comment: http://stackoverflow.com/comment/32760720
has answer: http://stackoverflow.com/a/21672995
type: Question
tagged with: mongodb
has comment: http://stackoverflow.com/comment/32811354

http://stackoverflow.com/a/21653918
type: Answer
has body: You're copying the messages in to the same folder they're already in. The Folder parameter is the destination folder, you need a second Folder object. And I can't tell how you're getting the Message objects from the source folder, so you may be doing something wrong there as well. Note that the destination folder does not need to be open.
has comment: http://stackoverflow.com/comment/32735831
has comment: http://stackoverflow.com/comment/32744844
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/32767299
has comment: http://stackoverflow.com/comment/32754895
has comment: http://stackoverflow.com/comment/32748692
has comment: http://stackoverflow.com/comment/32785642
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21645994
accepted answer of: http://stackoverflow.com/q/21645994

http://stackoverflow.com/comment/32591503
type: QuestionComment
comment on: http://stackoverflow.com/q/21576404
has text: Adding the `resources` folder as a source folder usually does the trick.
score: 0
type: Comment

http://stackoverflow.com/q/21623706
downvote count: 5
tagged with: inheritance
has comment: http://stackoverflow.com/comment/32674401
has comment: http://stackoverflow.com/comment/32674281
linked to: http://stackoverflow.com/q/2843755
answer count: 1
has comment: http://stackoverflow.com/comment/32674315
favorite count: 0
duplicate of: http://stackoverflow.com/q/2843755
linked to: http://stackoverflow.com/q/2515477
has body: Yeah the title pretty much describes the question. Are there any advantages to non allowing multiple inheritance in a programming language?
type: UnansweredQuestion
score: -5
has answer: http://stackoverflow.com/a/21623805
tagged with: oop
tagged with: java
has title: Why does Java not support multiple inheritance?
type: Question
has comment: http://stackoverflow.com/comment/32674318
upvote count: 0

http://stackoverflow.com/q/21619997
has answer: http://stackoverflow.com/a/21620899
has answer: http://stackoverflow.com/a/21621087
has title: How should I randomly generate two numbers at the same time without them being duplicated?
score: 0
has body: I am just wondering how should I generate two numbers in java that are different from each other. I want to choose two numbers between 1-3 randomly, however, I don't want them to be the same numbers? how should I do that? I tried to use a loop and I keep getting the same numbers this is what I did Random random = new Random(); for(int i =0; i&lt;3; i++){ int randomInteger = random.nextInt(); System.out.println("Random Integer in Java: " + randomInteger); }
tagged with: random
has answer: http://stackoverflow.com/a/21622161
has answer: http://stackoverflow.com/a/21622285
answer count: 5
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21619998
tagged with: java
tagged with: loops
type: Question

http://stackoverflow.com/a/21589324
has body: Not sure about windows, the best you can do here is to write a minimal batch file that greps the file name and puts it right there for unix: you could do something like java -jar *.jar this works well in unix
type: Answer
has comment: http://stackoverflow.com/comment/32615439
has comment: http://stackoverflow.com/comment/32615421
score: 5
has comment: http://stackoverflow.com/comment/32615453
downvote count: 0
upvote count: 5
answers question: http://stackoverflow.com/q/21589278

http://stackoverflow.com/a/21609116
score: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21609078
type: Answer
has body: Your code is OK. It seems that it covers the issue.
answers question: http://stackoverflow.com/q/21609078
has comment: http://stackoverflow.com/comment/32648899

http://stackoverflow.com/comment/32502941
score: 3
comment on: http://stackoverflow.com/q/21526528
type: Comment
type: QuestionComment
has text: FindBugs is asking you to make this static text "Select" into a dynamic one which gets its value from a `ResourceBundle` that changes based on the language specific to the user. Something like *messages_en.properties has the text Select* whereas *messages_fr.properties has the text sélectionner* because you don't want to show English static texts to a French User.

boolean
tags question: http://stackoverflow.com/q/21640027
tags question: http://stackoverflow.com/q/21562192
tags question: http://stackoverflow.com/q/21671280
tags question: http://stackoverflow.com/q/21535228
tags question: http://stackoverflow.com/q/21668288
tags question: http://stackoverflow.com/q/21562590
tag name: boolean
tags question: http://stackoverflow.com/q/21631760
tags question: http://stackoverflow.com/q/21541243
tags question: http://stackoverflow.com/q/21653836
tags question: http://stackoverflow.com/q/21559718
tags question: http://stackoverflow.com/q/21563040
tags question: http://stackoverflow.com/q/21570991
type: Tag

http://stackoverflow.com/q/21668372
tagged with: http://stackoverflow.com/tag/html
accepted answer: http://stackoverflow.com/a/21668557
has title: Difference between two ways of reading a web page (html) using Java
tagged with: httpurlconnection
has comment: http://stackoverflow.com/comment/32753375
upvote count: 1
has body: First way is just to url.openStream, then InputStreamReader, StringBuffer temp = new StringBuffer(); URL url = new URL(addr); BufferedReader bf = new BufferedReader(new InputStreamReader(url.openStream(),"ISO-8859-1"), BUFFER_SIZE ); int charsRead; char[] copyBuffer = new char[BUFFER_SIZE]; while ((charsRead = bf.read(copyBuffer, 0, BUFFER_SIZE)) != -1) { temp.append(copyBuffer, 0, charsRead); } bf.close(); I found that the result differ from that from IE/Chrome. Second way is to use HttpURLConnection first, then getInputStream, then InputStreamReader URL url = new URL(addr); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setRequestMethod("GET"); con.setRequestProperty("User-Agent", USER_AGENT); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer temp = new StringBuffer(); while ((inputLine = in.readLine()) != null) { temp.append(inputLine); } in.close(); This returns exactly what's in the IE if I view source. So my questions are: Why sometimes the first method using url.openStream returns a different html than the one I read from IE? There are tags missing, number of carriages returns are different (which is questions 2) I noticed that the html from first method have reasonable carriage returns. The one from second method had no carriage return. IE view source shows even more carriage returns than the first method. Why is this? Thanks!
tagged with: http
type: AnsweredQuestion
tagged with: internet-explorer
tagged with: java
has answer: http://stackoverflow.com/a/21668557
type: Question
answer count: 1
downvote count: 0
score: 1
favorite count: 0

http://stackoverflow.com/comment/32760838
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21672531
has text: Mr.Arvind, there was spelling mistake in column name which i corrected but still i am getting same errors.
score: 0

tomcat
tags question: http://stackoverflow.com/q/21550369
tags question: http://stackoverflow.com/q/21633070
tags question: http://stackoverflow.com/q/21530484
tags question: http://stackoverflow.com/q/21634490
tags question: http://stackoverflow.com/q/21565598
tags question: http://stackoverflow.com/q/21622254
tags question: http://stackoverflow.com/q/21523693
tags question: http://stackoverflow.com/q/21628887
tags question: http://stackoverflow.com/q/21523996
tags question: http://stackoverflow.com/q/21662588
tags question: http://stackoverflow.com/q/21531500
tags question: http://stackoverflow.com/q/21615049
tags question: http://stackoverflow.com/q/21623143
tags question: http://stackoverflow.com/q/21600153
tags question: http://stackoverflow.com/q/21584134
tags question: http://stackoverflow.com/q/21530724
tags question: http://stackoverflow.com/q/21575348
tags question: http://stackoverflow.com/q/21549991
tags question: http://stackoverflow.com/q/21605068
tags question: http://stackoverflow.com/q/21584669
tags question: http://stackoverflow.com/q/21515392
tags question: http://stackoverflow.com/q/21516628
tags question: http://stackoverflow.com/q/21647362
tags question: http://stackoverflow.com/q/21552913
tag name: tomcat
tags question: http://stackoverflow.com/q/21567374
tags question: http://stackoverflow.com/q/21678082
tags question: http://stackoverflow.com/q/21551604
tags question: http://stackoverflow.com/q/21605298
tags question: http://stackoverflow.com/q/21569352
tags question: http://stackoverflow.com/q/21527289
tags question: http://stackoverflow.com/q/21673759
tags question: http://stackoverflow.com/q/21624643
tags question: http://stackoverflow.com/q/21620620
tags question: http://stackoverflow.com/q/21548506
tags question: http://stackoverflow.com/q/21606710
tags question: http://stackoverflow.com/q/21546388
tags question: http://stackoverflow.com/q/21669127
tags question: http://stackoverflow.com/q/21541015
tags question: http://stackoverflow.com/q/21520106
tags question: http://stackoverflow.com/q/21621845
tags question: http://stackoverflow.com/q/21517792
tags question: http://stackoverflow.com/q/21614812
tags question: http://stackoverflow.com/q/21614507
tags question: http://stackoverflow.com/q/21673034
tags question: http://stackoverflow.com/q/21523966
tags question: http://stackoverflow.com/q/21571582
tags question: http://stackoverflow.com/q/21557529
tags question: http://stackoverflow.com/q/21610186
tags question: http://stackoverflow.com/q/21633548
tags question: http://stackoverflow.com/q/21545009
tags question: http://stackoverflow.com/q/21602338
tags question: http://stackoverflow.com/q/21578522
tags question: http://stackoverflow.com/q/21568188
tags question: http://stackoverflow.com/q/21553108
tags question: http://stackoverflow.com/q/21615627
tags question: http://stackoverflow.com/q/21523186
type: Tag
tags question: http://stackoverflow.com/q/21649998
tags question: http://stackoverflow.com/q/21550532
tags question: http://stackoverflow.com/q/21571320
tags question: http://stackoverflow.com/q/21652581
tags question: http://stackoverflow.com/q/21677984
tags question: http://stackoverflow.com/q/21556961
tags question: http://stackoverflow.com/q/21638890
tags question: http://stackoverflow.com/q/21532645
tags question: http://stackoverflow.com/q/21554671
tags question: http://stackoverflow.com/q/21561157
tags question: http://stackoverflow.com/q/21676119
tags question: http://stackoverflow.com/q/21604892
tags question: http://stackoverflow.com/q/21615850
tags question: http://stackoverflow.com/q/21639254
tags question: http://stackoverflow.com/q/21562000
tags question: http://stackoverflow.com/q/21551072
tags question: http://stackoverflow.com/q/21638751
tags question: http://stackoverflow.com/q/21585857
tags question: http://stackoverflow.com/q/21655137
tags question: http://stackoverflow.com/q/21536191
tags question: http://stackoverflow.com/q/21574186
tags question: http://stackoverflow.com/q/21522518

http://stackoverflow.com/a/30050012
type: Answer
answers question: http://stackoverflow.com/q/21653995
has body: I think I would separate out the concepts of message fetching (if I understand your problem correctly) and expiring. So something along the lines of injecting an ExpirationPolicy. During your unit tests you can control this discretely by providing a fake version that you can have complete control over. In your production code you can use a TimedExpirationPolicy which will work on timers that you can test completely independently from this class. Not only are you going to make it so your tests can be made less flaky, but you are better adhering to Single Responsibility Principle.
score: 0

http://stackoverflow.com/comment/32490958
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21519424
has text: possible duplicate of [No more data to read from socket](http://stackoverflow.com/questions/12605835/no-more-data-to-read-from-socket)
score: 0

http://stackoverflow.com/q/21523958
has comment: http://stackoverflow.com/comment/32544094
favorite count: 0
has comment: http://stackoverflow.com/comment/32521387
has comment: http://stackoverflow.com/comment/32522687
score: 9
type: Question
has comment: http://stackoverflow.com/comment/32522973
has comment: http://stackoverflow.com/comment/32543872
has comment: http://stackoverflow.com/comment/32516397
has comment: http://stackoverflow.com/comment/32584643
has answer: http://stackoverflow.com/a/21525039
tagged with: java
has comment: http://stackoverflow.com/comment/32583349
has comment: http://stackoverflow.com/comment/32583678
tagged with: garbage-collection
has comment: http://stackoverflow.com/comment/32522637
answer count: 1
has comment: http://stackoverflow.com/comment/32544009
tagged with: microbenchmark
upvote count: 9
has title: What can explain the huge performance penalty of writing a reference to a heap location?
has body: While investigating the subtler consequences of generational garbage collectors on application performance, I have hit a quite staggering discrepancy in the performance of a very basic operation &ndash; a simple write to a heap location &ndash; with respect to whether the value written is primitive or a reference. The microbenchmark @OutputTimeUnit(TimeUnit.NANOSECONDS) @BenchmarkMode(Mode.AverageTime) @Warmup(iterations = 1, time = 1) @Measurement(iterations = 3, time = 1) @State(Scope.Thread) @Threads(1) @Fork(2) public class Writing { static final int TARGET_SIZE = 1024; static final int[] primitiveArray = new int[TARGET_SIZE]; static final Object[] referenceArray = new Object[TARGET_SIZE]; int val = 1; @GenerateMicroBenchmark public void fillPrimitiveArray() { final int primitiveValue = val++; for (int i = 0; i &lt; TARGET_SIZE; i++) primitiveArray[i] = primitiveValue; } @GenerateMicroBenchmark public void fillReferenceArray() { final Object referenceValue = new Object(); for (int i = 0; i &lt; TARGET_SIZE; i++) referenceArray[i] = referenceValue; } } The results Benchmark Mode Thr Cnt Sec Mean Mean error Units fillPrimitiveArray avgt 1 6 1 87.891 1.610 nsec/op fillReferenceArray avgt 1 6 1 640.287 8.368 nsec/op Since the whole loop is almost 8 times slower, the write itself is probably more than 10 times slower. What could possibly explain such a slowdown? The speed of writing out the primitive array is more than 10 writes per nanosecond. Perhaps I should ask the flip-side of my question: what makes primitive writing so fast? (BTW I've checked, the times scale linearly with array size.) Note that this is all single-threaded; specifying @Threads(2) will increase both measurements, but the ratio will be similar. A bit of background: the card table and the associated write barrier An object in the Young Generation could happen to be reachable only from an object in the Old Generation. To avoid collecting live objects, the YG collector must know about any reference…
has comment: http://stackoverflow.com/comment/32544012
has comment: http://stackoverflow.com/comment/32521157
accepted answer: http://stackoverflow.com/a/21525039
has comment: http://stackoverflow.com/comment/32543933
tagged with: jmh
type: AnsweredQuestion
downvote count: 0
has comment: http://stackoverflow.com/comment/32520469

http://stackoverflow.com/q/21572614
accepted answer: http://stackoverflow.com/a/21572657
linked to: http://stackoverflow.com/q/11180866
has answer: http://stackoverflow.com/a/21572690
downvote count: 0
tagged with: string
has comment: http://stackoverflow.com/comment/32585304
favorite count: 0
has answer: http://stackoverflow.com/a/21572977
answer count: 5
has answer: http://stackoverflow.com/a/21572689
linked to: http://stackoverflow.com/q/6578133
has answer: http://stackoverflow.com/a/21572657
upvote count: 3
has body: I came across two code snippets which were creating a query to be executed further: StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("SELECT * FROM EMPLOYEE "); stringBuilder.append("WHERE SALARY &gt; ? "); stringBuilder.append("GROUP BY DEPT"); And String string = "SELECT * FROM EMPLOYEE " + "WHERE SALARY &gt; ? " + "GROUP BY DEPT"; According to my analysis, both the snippets create 4 objects. First snippet creates a StringBuilder object and 3 string objects while the second snippet creates 4 String objects. Is my analysis correct? How snippet one is more efficient than snippet 2?
duplicate of: http://stackoverflow.com/q/6578133
possible better answer: http://stackoverflow.com/a/21572675
type: Question
type: AnsweredQuestion
score: 3
tagged with: stringbuilder
has answer: http://stackoverflow.com/a/21572675
linked to: http://stackoverflow.com/q/21526747
has title: String vs StringBuilder - Number of objects
tagged with: java
linked to: http://stackoverflow.com/q/10045147

http://stackoverflow.com/a/61306344
upvote count: 3
has body: In java, we have float and double as floating point literals, where double is the default data type of floating point literals and not the float. This is the reason why java is telling you that 0.5 is a double. Possible conversion: 1) float a = (float) 0.5; 2) float a = 0.5f; And reason for lossy conversion is because, double is bigger than float. When you try to fit-in the bigger one into the smaller one, you will get this error.
type: Answer
downvote count: 0
score: 3
answers question: http://stackoverflow.com/q/21645783

android
tags question: http://stackoverflow.com/q/21572303
tags question: http://stackoverflow.com/q/21634112
tags question: http://stackoverflow.com/q/21593318
tags question: http://stackoverflow.com/q/21590363
tags question: http://stackoverflow.com/q/21582683
tags question: http://stackoverflow.com/q/21659204
tags question: http://stackoverflow.com/q/21585989
tags question: http://stackoverflow.com/q/21667616
tags question: http://stackoverflow.com/q/21635342
tags question: http://stackoverflow.com/q/21526647
tags question: http://stackoverflow.com/q/21577447
tags question: http://stackoverflow.com/q/21653023
tags question: http://stackoverflow.com/q/21662546
tags question: http://stackoverflow.com/q/21673293
tags question: http://stackoverflow.com/q/21642956
tags question: http://stackoverflow.com/q/21560164
tags question: http://stackoverflow.com/q/21590377
tags question: http://stackoverflow.com/q/21559287
tags question: http://stackoverflow.com/q/21666727
tags question: http://stackoverflow.com/q/21623076
tags question: http://stackoverflow.com/q/21549248
tags question: http://stackoverflow.com/q/21663672
tags question: http://stackoverflow.com/q/21562502
tags question: http://stackoverflow.com/q/21575959
tags question: http://stackoverflow.com/q/21530750
tags question: http://stackoverflow.com/q/21595879
tags question: http://stackoverflow.com/q/21604680
tags question: http://stackoverflow.com/q/21574566
tags question: http://stackoverflow.com/q/21647419
tags question: http://stackoverflow.com/q/21570318
tags question: http://stackoverflow.com/q/21661095
tags question: http://stackoverflow.com/q/21592952
tags question: http://stackoverflow.com/q/21551167
tags question: http://stackoverflow.com/q/21629153
tags question: http://stackoverflow.com/q/21531475
tags question: http://stackoverflow.com/q/21524748
tags question: http://stackoverflow.com/q/21516020
tags question: http://stackoverflow.com/q/21606607
tags question: http://stackoverflow.com/q/21573863
tags question: http://stackoverflow.com/q/21670512
tags question: http://stackoverflow.com/q/21614602
tags question: http://stackoverflow.com/q/21578476
tags question: http://stackoverflow.com/q/21568683
tags question: http://stackoverflow.com/q/21578301
tags question: http://stackoverflow.com/q/21585440
tags question: http://stackoverflow.com/q/21525993
tags question: http://stackoverflow.com/q/21615957
tags question: http://stackoverflow.com/q/21591377
tags question: http://stackoverflow.com/q/21550695
tags question: http://stackoverflow.com/q/21549059
tags question: http://stackoverflow.com/q/21631930
tags question: http://stackoverflow.com/q/21638716
tags question: http://stackoverflow.com/q/21563099
tags question: http://stackoverflow.com/q/21653000
tags question: http://stackoverflow.com/q/21658410
tags question: http://stackoverflow.com/q/21618118
tags question: http://stackoverflow.com/q/21541748
tags question: http://stackoverflow.com/q/21665733
tags question: http://stackoverflow.com/q/21675201
tags question: http://stackoverflow.com/q/21571227
tags question: http://stackoverflow.com/q/21574385
tags question: http://stackoverflow.com/q/21667484
tags question: http://stackoverflow.com/q/21625561
tags question: http://stackoverflow.com/q/21662252
tags question: http://stackoverflow.com/q/21618628
tags question: http://stackoverflow.com/q/21581977
tags question: http://stackoverflow.com/q/21677518
tags question: http://stackoverflow.com/q/21592547
tags question: http://stackoverflow.com/q/21595050
tags question: http://stackoverflow.com/q/21656721
tags question: http://stackoverflow.com/q/21637691
tags question: http://stackoverflow.com/q/21651542
tags question: http://stackoverflow.com/q/21581347
tags question: http://stackoverflow.com/q/21628146
tags question: http://stackoverflow.com/q/21591783
tags question: http://stackoverflow.com/q/21552451
tags question: http://stackoverflow.com/q/21563581
tags question: http://stackoverflow.com/q/21602442
tags question: http://stackoverflow.com/q/21595078
tags question: http://stackoverflow.com/q/21612415

http://stackoverflow.com/comment/32614667
has text: @Cruncher Oops. You're both right. It's `getClass().getName() + '@' + Integer.toHexString(hashCode())`
type: Comment
comment on: http://stackoverflow.com/a/21588750
score: 0
type: AnswerComment

http://stackoverflow.com/q/21528449
answer count: 1
tagged with: moxy
favorite count: 0
score: 2
downvote count: 0
accepted answer: http://stackoverflow.com/a/21538381
tagged with: java
tagged with: jaxb
has comment: http://stackoverflow.com/comment/32506474
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21538381
has body: I'm trying to get MOXy or JAXB RI to marshal null collections to an xsi:nil element like so: &lt;element xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/&gt; The use case is: Axis2 SOAP endpoint I have no control of I'm on the client side Endpoint expects xsi:nil elements for null collections but does not allow them to be wrapped (using @XmlElementWrapper) which would generate the required xsi:nil element for the wrapping element. I can only use JAX-WS RI as of JDK 6 r4+ or the latest Metro implementation. I can use the JAXB RI or the MOXy implementation. I'm on EclipseLink 2.5.1 The bound types are generated from the service WSDL by wsimport at build time. So any solution not requiring post-processing the generated sources for annotation modification would be preferable. I'm aware that JAXB RI as of 2.2.6 probably has no way of doing that, but maybe I missed something. I checked the sources and it basically says, non-parametrized: "If it's a List and if it's null, only ever output anything if @XmlElementWrapper is present on field". But unfortunately this is not a solution for this case. I tried MOXy and the use of its @XmlNullPolicy annotation but it seems to have no effect on collection properties. Is there another way to make MOXy output xsi:nil elements for emtpty collections? I created a test case to give an example of what happens. First and second are the actual result and the result I need. Third is the jaxb.properties file required to enable MOXy for the actual use case in the fourth code block. This is what I get when executing the test case at the bottom: &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;model&gt; &lt;nonCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/&gt; &lt;nonCollectionEmptyNode/&gt; &lt;wrappedNullCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/&gt; &lt;/model&gt; This is what I need: &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;model&gt; &lt;non…
upvote count: 2
has title: Any way to marshal @XmlElement List<String> fieldName to <fieldName xsi:nil="true".../> instead of an absent node?
tagged with: eclipselink

http://stackoverflow.com/q/21530689
has answer: http://stackoverflow.com/a/21530886
has comment: http://stackoverflow.com/comment/32510731
tagged with: android
has answer: http://stackoverflow.com/a/21530891
accepted answer: http://stackoverflow.com/a/21530891
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32510405
has body: I have an enumeration that contains elements like DOT_BLUE, DOT_YELLOW, SQUARE_BLUE, SQUARE_YELLOW etc. I also have a string, say String string = "DOT_BLUE". Now I want to access the enum depending on what the string is. I'm too lazy to write all the if else statements (there are a lot more elements) and using reflection in Java is tricky becuase I want to run this code on android aswell. So is there any other more elegant way to access my enum depending on what the string is? I don't know of any, but I'm not a Java expert. So I'd be happy about a clear answer, even if it's "Nope".
possible better answer: http://stackoverflow.com/a/21530886
has title: Call enum type with string
type: Question
has answer: http://stackoverflow.com/a/21530888
tagged with: enums
tagged with: java
has comment: http://stackoverflow.com/comment/32510683
score: 0
answer count: 3
has comment: http://stackoverflow.com/comment/32510446

http://stackoverflow.com/q/21564033
has title: java increment/decrement operator inside call
score: 0
has comment: http://stackoverflow.com/comment/32569622
has answer: http://stackoverflow.com/a/21564359
has answer: http://stackoverflow.com/a/21564120
has body: We're learning about quickSort. The book provides the code at the end of my question. I'm curious about this call at the end of the findPivot method: swap(array, left++, right--); Why have the "++" and "--" in there? It's not incrementing/decrementing either variable (before or after the swap) and it's not accessing (for example) array[left + 1]. So what gives? EDIT So before I posted the question I wrote the following test code: public static void main(String[] args) { int a = 0; int b = 2; int[] array = {1,10,20,30}; swap(array, a++,b--); } public static void swap(int[]array,int a, int b) { for(int i = 0; i &lt; 10; i++) { Integer temp = array[a]; array[a] = array[b]; array[b] = temp; System.out.println("a = " + a + "\nb = " + b + "\narray a: " + array[a] + "\narray b: " + array[b]); } The results are as follows: a = 0 b = 2 array a: 20 array b: 1 a = 0 b = 2 array a: 1 array b: 20 a = 0 b = 2 array a: 20 array b: 1 The variable isn't post-incrementing at all when used in the method. That's why I asked the question. Thanks. Here's the code: private static void swap(Integer[] array, int i, int j) { Integer temp = array[i]; array[i] = array[j]; array[j] = temp; } public static void quickSort(Integer[] array, int left, int right) { if(left &lt; right) { int pivot = findPivot(array, left, right); quickSort(array, left, pivot - 1); quickSort(array, pivot + 1, right); } }//quickSort public static int findPivot(Integer[] array, int left, int right) { int first = left++; while (left &lt;= right) { while (left &lt;= right &amp;&amp; array[first].compareTo(array[left]) &gt; 0) { left++; } while (left &lt;= right &amp;&amp; array[first].compareTo(array[right]) &lt; 0) { right--; } if (left &lt; right) swap(array, left++, right--); } swap(array, first, right); return right; }
has answer: http://stackoverflow.com/a/21564091
possible better answer: http://stackoverflow.com/a/21564093
tagged with: increment
has answer: http://stackoverflow.com/a/21564093
has comment: http://stackoverflow.com/comment/32575258
tagged with: quicksort
answer count: 4
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/21564091
type: Question
has comment: http://stackoverflow.com/comment/32574702

http://stackoverflow.com/comment/80347996
has text: This didnt do the trick for me ! I am facing the exact same issue !
type: Comment
score: 1
comment on: http://stackoverflow.com/a/21612968
type: AnswerComment

http://stackoverflow.com/a/21527236
has body: If you want to access local variables for reading only, pass their values as parameters. If you want write access also, convert them into instance variables - either of the current class, or better create a new class.
score: 1
answers question: http://stackoverflow.com/q/21527099
downvote count: 0
type: Answer
upvote count: 1

http://stackoverflow.com/q/21598163
has comment: http://stackoverflow.com/comment/32636901
tagged with: multithreading
accepted answer: http://stackoverflow.com/a/21606130
has comment: http://stackoverflow.com/comment/32633939
type: Question
has comment: http://stackoverflow.com/comment/32776669
type: AnsweredQuestion
has body: Assume I have 3 bundles A, B and B1. Bundle A is the starting point of my application. Bundle B provides the API of the service used by A. Bundle B1 is an implementation of the service. Basically, bundle A has a set of records that it processes one after the other. There is no order for processing the records. I would like to improve performance of my application by processing subsets of records concurrently. I thought about two different ways: multiple instances of bundle A and, bundle A with multiple threads. AFAIK, it is not possible to add multiple instances of the same bundle (i.e. same OSGi identity) in an OSGi container. Regarding the second possibility, each thread created by bundle A would have its own identity. And the service exported by B1 needs to know the identity of the thread that uses it. Thus, I thought a ServiceFactoy would fit here. However, I've read that once a service instance is obtained by a bundle, it is cached. Therefore, all the threads would get the same service instance. Am I right? If yes, what is the "right way" to implement this model? Feel free to propose me a completely different approach that is more OSGi friendly. Thanks, Mickael EDIT: Another possibility would be to modify the Service interface to allow the service's consumers to pass their identity to the Service. The Service would then become "stateless" and the use of ServiceFactory would not be required. However, the fact the identity is required is an implementation detail (i.e. it is required only for this specific implementation), therefore for future implementations, the parameters added to the interface would not be used. This is why I prefer not to touch the interface.
has comment: http://stackoverflow.com/comment/32639886
tagged with: java
has comment: http://stackoverflow.com/comment/32630451
answer count: 1
has comment: http://stackoverflow.com/comment/32631028
score: 0
has comment: http://stackoverflow.com/comment/32630279
has comment: http://stackoverflow.com/comment/32637193
tagged with: osgi
has comment: http://stackoverflow.com/comment/32636976
has answer: http://stackoverflow.com/a/21606130
has title: Multithreaded bundle and service instances
has comment: http://stackoverflow.com/comment/32634421

http://stackoverflow.com/a/21615490
upvote count: 2
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/51363240
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21613811
downvote count: 0
has body: Both ShardedJedisPool and JedisPool are intended to be created only once for the entire life of the application. And you destroy them when the application shutsdown. Both ShardedJedisPool and JedisPool are thread-safe, meanning that it is safe to use the same instance across threads (in your case requests) and get an instance of ShardedJedis or Jedis. After using ShardedJedis or Jedis, you should return them to the pool, or else the pool will get exhausted (depending on how you configured it).
answers question: http://stackoverflow.com/q/21613811

http://stackoverflow.com/a/21542359
answers question: http://stackoverflow.com/q/21542276
has comment: http://stackoverflow.com/comment/32608830
has body: The basic problem is you are re-creating the Random with the same seed each time, which is generally creating the same random sequence over and over again. Instead try using... do { newIndex = (int) Math.round(Math.random() * (fortune.length - 1)); } while (newIndex == oldIndex); You also don't need the second loop, it's just clutter that confuses the situation. You may also find that... displayTa.append(fortune[newIndex] + "\n"); produces nicer output (IMHO) You may also wish to take a look at How to use Scroll Panes
score: 0
type: Answer

http://stackoverflow.com/a/21542737
type: Answer
has body: android:name=".MainActivity" You should specify the whole class name including package Example android:name="com.example.MainActivity" where com.example is your package Otherwise it cant identify your class
answers question: http://stackoverflow.com/q/21542067
has comment: http://stackoverflow.com/comment/32532910
score: 0

http://stackoverflow.com/comment/32538982
type: AnswerComment
comment on: http://stackoverflow.com/a/21546996
type: Comment
has text: I don't see how your later edit would work... You'd substring from the index which is the length of the 10th interval between @s? Should that not be the sum of the lengths of the first 10 intervals?
score: 0

http://stackoverflow.com/a/21517017
has comment: http://stackoverflow.com/comment/32597886
upvote count: 3
has comment: http://stackoverflow.com/comment/32601329
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32601118
has comment: http://stackoverflow.com/comment/32598018
has comment: http://stackoverflow.com/comment/32600537
has comment: http://stackoverflow.com/comment/32486919
has comment: http://stackoverflow.com/comment/32597745
accepted answer of: http://stackoverflow.com/q/21516299
has body: Don't set bounds. Learn to use Layout Managers. Paint the image on a JPanel instead of using a JLabel Put the JButton on the JPanel. Give that JPanel a GridBadLayout Override the getPreferredSize() of the JPanel. To switch between images you can use a flag like boolean icon1, icon2, icon3;. and repaint the JPanel the mouseXxx. Something like this public void mouseClicked(MouseEvent e) { icon1 = true; icon2 = false; icon3 = false; imagePanel.repaint(); } .... protected void paintComponent(Graphics g) { if (icon1) { g.drawImage(image1, .....); } if (icon2) { ... } if (icon3) { ... } } pack() your frame. Use Java naming convention. variables start with lower case letters. Here's an example import java.awt.*; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.*; import java.util.logging.*; import javax.imageio.ImageIO; import javax.swing.*; public class TestButtonOverImage { public TestButtonOverImage() { JFrame frame = new JFrame("Test Card"); frame.add(new ImagePanel()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable(){ public void run() { new TestButtonOverImage(); } }); } public class ImagePanel extends JPanel { BufferedImage img; public ImagePanel() { setLayout(new GridBagLayout()); add(new JButton("StackOverflow Button")); try { img = ImageIO.read(new URL("http://d8u1nmttd4enu.cloudfront.net/designs/logo-stackoverflow-logo-design-99designs_447080~36d200d82d83d7b2e738cebd2a48de07180cef3a_largecrop")); } catch (MalformedURLException ex) { Logger.getLogger(TestButtonOverImage.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(TestButtonOverImage.class.getName()).log(Level.SEVERE, null, ex); } } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(img, 100, 100, 300, 300, this); } public Dimension getPreferredSize() { return new Dimensio…
answers question: http://stackoverflow.com/q/21516299
has comment: http://stackoverflow.com/comment/32598861
type: Answer
score: 3
has comment: http://stackoverflow.com/comment/32601042

http://stackoverflow.com/q/21567464
has comment: http://stackoverflow.com/comment/32576396
answer count: 1
has body: The problem comes in the toString method of the following code: import java.util.*; public class LinkedDeque&lt;T&gt; // implements Deque&lt;T&gt; { private Node head; private Node tail; private int size; private class Node // Node class { T info; Node next; Node prev; private Node (T info, Node prev, Node next) { this.info = info; this.prev = prev; this.next = next; } private T getInfo() { return this.info; } private Node getNext() { return this.next; } private Node getPrev() { return this.prev; } } public LinkedDeque () { this.head = null; this.tail = null; this.size = 0; } public static void main() { } public int size () { Node count = head; while(count.getNext() != null) { size++; count = count.getNext(); } return size; } public String toString() { return this.getInfo(); } public boolean isEmpty() { return size() == 0; } } My compiler keeps giving me an error saying that the getInfo method is missing. Any help would be appreciated! Initially, I thought this was due to the fact that the Node class was private, but the Node getNext() method works fine in the method size().
score: 0
tagged with: java
has answer: http://stackoverflow.com/a/21567542
accepted answer: http://stackoverflow.com/a/21567542
type: AnsweredQuestion
has title: Method getInfo() not found?
type: Question

http://stackoverflow.com/a/56312839
has body: I have similar problem but i have a little bit diffrent JSON and i have problem to use your solution with Map. Example (Map>). My JSON structure: { "2019-05-26": { "lastUpdate": "2019-05-26 06:05:02", "routes":[ { "routeId": 107, "agencyId": 18 }, { "routeId": 222, "agencyId": 22 } ] }, "2019-05-27": { "lastUpdate": "2019-05-27 06:05:02", "routes":[ { "routeId": 33, "agencyId": 14 }, { "routeId": 345, "agencyId": 2232 } ] } } How to use this JSON ? I would like to parse it to my POJOs.
type: Answer
score: 0
answers question: http://stackoverflow.com/q/21536987

http://stackoverflow.com/comment/32708702
type: QuestionComment
comment on: http://stackoverflow.com/q/21642997
type: Comment
score: 0
has text: `smtp.gmail.com`? I found this by googling the text of your question...

servlets
tags question: http://stackoverflow.com/q/21548428
tags question: http://stackoverflow.com/q/21598778
tags question: http://stackoverflow.com/q/21522831
tags question: http://stackoverflow.com/q/21552253
tags question: http://stackoverflow.com/q/21557794
tags question: http://stackoverflow.com/q/21600622
tags question: http://stackoverflow.com/q/21594859
tags question: http://stackoverflow.com/q/21609774
tags question: http://stackoverflow.com/q/21590995
tags question: http://stackoverflow.com/q/21670915
tags question: http://stackoverflow.com/q/21621313
tags question: http://stackoverflow.com/q/21626465
tags question: http://stackoverflow.com/q/21540057
tags question: http://stackoverflow.com/q/21638734
tags question: http://stackoverflow.com/q/21558861
tags question: http://stackoverflow.com/q/21668148
tags question: http://stackoverflow.com/q/21573035
tags question: http://stackoverflow.com/q/21524205
tags question: http://stackoverflow.com/q/21647331
tags question: http://stackoverflow.com/q/21600101
tags question: http://stackoverflow.com/q/21530998
tags question: http://stackoverflow.com/q/21614268
tags question: http://stackoverflow.com/q/21645164
tags question: http://stackoverflow.com/q/21533321
tags question: http://stackoverflow.com/q/21568759
tags question: http://stackoverflow.com/q/21647785
tags question: http://stackoverflow.com/q/21525941
tags question: http://stackoverflow.com/q/21551715
tags question: http://stackoverflow.com/q/21583317
tags question: http://stackoverflow.com/q/21523751
tags question: http://stackoverflow.com/q/21535903
tags question: http://stackoverflow.com/q/21659278
tags question: http://stackoverflow.com/q/21673034
tags question: http://stackoverflow.com/q/21569343
tags question: http://stackoverflow.com/q/21646012
tags question: http://stackoverflow.com/q/21622463
tags question: http://stackoverflow.com/q/21676212
tags question: http://stackoverflow.com/q/21617417
tags question: http://stackoverflow.com/q/21553697
tags question: http://stackoverflow.com/q/21573450
tags question: http://stackoverflow.com/q/21626841
tags question: http://stackoverflow.com/q/21601780
tags question: http://stackoverflow.com/q/21531351
tags question: http://stackoverflow.com/q/21582266
tags question: http://stackoverflow.com/q/21660483
tags question: http://stackoverflow.com/q/21622206
tags question: http://stackoverflow.com/q/21601698
tags question: http://stackoverflow.com/q/21539197
tags question: http://stackoverflow.com/q/21653762
tags question: http://stackoverflow.com/q/21672981
tags question: http://stackoverflow.com/q/21571542
tags question: http://stackoverflow.com/q/21661471
tags question: http://stackoverflow.com/q/21548712
tags question: http://stackoverflow.com/q/21639465
tags question: http://stackoverflow.com/q/21621819
tags question: http://stackoverflow.com/q/21660068
tags question: http://stackoverflow.com/q/21615714
tags question: http://stackoverflow.com/q/21554026
tags question: http://stackoverflow.com/q/21529018
tags question: http://stackoverflow.com/q/21570898
tags question: http://stackoverflow.com/q/21587114
tags question: http://stackoverflow.com/q/21655010
tags question: http://stackoverflow.com/q/21529597
tags question: http://stackoverflow.com/q/21644593
tags question: http://stackoverflow.com/q/21638751
tags question: http://stackoverflow.com/q/21583462
tags question: http://stackoverflow.com/q/21659230
tags question: http://stackoverflow.com/q/21550532
tags question: http://stackoverflow.com/q/21643934
tags question: http://stackoverflow.com/q/21635518
tags question: http://stackoverflow.com/q/21645350
tags question: http://stackoverflow.com/q/21537827
tags question: http://stackoverflow.com/q/21638890
tag name: servlets
tags question: http://stackoverflow.com/q/21674304
tags question: http://stackoverflow.com/q/21655800
tags question: http://stackoverflow.com/q/21672602
tags question: http://stackoverflow.com/q/21562046
tags question: http://stackoverflow.com/q/21628464
type: Tag

http://stackoverflow.com/a/21556463
answers question: http://stackoverflow.com/q/21555968
score: 0
has body: Playing around.... import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JPanel; public class PanelResize extends JFrame { private static final long serialVersionUID = 1L; public static void main(String[] args) { new PanelResize(); } private JPanel panel; public PanelResize() { panel = new MyJPanel(); getContentPane().add(panel); JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("Resize"); JMenuItem menuItem = new JMenuItem("Resize"); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { panel.setPreferredSize(new Dimension(500,500)); pack(); } }); menu.add(menuItem); menuBar.add(menu); this.setJMenuBar(menuBar); pack(); setDefaultCloseOperation(EXIT_ON_CLOSE); setLocation(100,50); setResizable(false); setVisible(true); } } class MyJPanel extends JPanel { public MyJPanel() { setPreferredSize(new Dimension(400,400)); } }
has comment: http://stackoverflow.com/comment/32558051
type: Answer
has comment: http://stackoverflow.com/comment/32557896
has comment: http://stackoverflow.com/comment/32555483
has comment: http://stackoverflow.com/comment/32555619
has comment: http://stackoverflow.com/comment/32556760

http://stackoverflow.com/q/21532761
answer count: 2
has title: How do I draw the same moving image multiple times?
downvote count: 0
has answer: http://stackoverflow.com/a/21534549
score: 4
has comment: http://stackoverflow.com/comment/32553165
has comment: http://stackoverflow.com/comment/32514415
possible better answer: http://stackoverflow.com/a/21534585
has answer: http://stackoverflow.com/a/21534585
favorite count: 0
accepted answer: http://stackoverflow.com/a/21534549
tagged with: animation
tagged with: swing
has comment: http://stackoverflow.com/comment/32514472
type: AnsweredQuestion
has body: Hello I'm making a platformer game and when you press space the character shoots a fireball that moves across the screen but when you press space again the fireball's coordinates are set back to the player's coordinates rather than drawing another fireball which is what I want. import java.awt.*; import javax.swing.*; public class Fire extends JPanel{ Image fireball; private int x=155000,y=155000; Player player = new Player(); public void paint(Graphics g){ g.drawImage(fireball, x, y, null); } public Fire(){ } public void update(){ fireball = new ImageIcon("C:\\Users\\steven.greens10\\Desktop\\Programs\\Raw Java\\Platform\\res\\fireball.png").getImage(); x+=5; if(x &gt; 640){ x=155000; } } public void shoot(Player p){ x = p.getX(); y = p.getY(); repaint(); } }
tagged with: java
tagged with: image
tagged with: sprite
type: Question
upvote count: 4

jsp
tags question: http://stackoverflow.com/q/21644822
tags question: http://stackoverflow.com/q/21621423
tags question: http://stackoverflow.com/q/21641391
tags question: http://stackoverflow.com/q/21601624
tags question: http://stackoverflow.com/q/21659278
tags question: http://stackoverflow.com/q/21598778
tags question: http://stackoverflow.com/q/21673034
tags question: http://stackoverflow.com/q/21628036
tags question: http://stackoverflow.com/q/21574040
tags question: http://stackoverflow.com/q/21578625
tags question: http://stackoverflow.com/q/21617082
tags question: http://stackoverflow.com/q/21622463
tags question: http://stackoverflow.com/q/21676212
tags question: http://stackoverflow.com/q/21550575
tags question: http://stackoverflow.com/q/21536833
tags question: http://stackoverflow.com/q/21553697
tags question: http://stackoverflow.com/q/21577131
tags question: http://stackoverflow.com/q/21569398
tags question: http://stackoverflow.com/q/21573450
tags question: http://stackoverflow.com/q/21595635
tags question: http://stackoverflow.com/q/21644682
tags question: http://stackoverflow.com/q/21626841
tags question: http://stackoverflow.com/q/21645188
tags question: http://stackoverflow.com/q/21601780
tags question: http://stackoverflow.com/q/21678082
tags question: http://stackoverflow.com/q/21609077
tags question: http://stackoverflow.com/q/21531351
tags question: http://stackoverflow.com/q/21625279
tags question: http://stackoverflow.com/q/21655997
tags question: http://stackoverflow.com/q/21519956
tags question: http://stackoverflow.com/q/21594979
tags question: http://stackoverflow.com/q/21653762
tags question: http://stackoverflow.com/q/21672981
tags question: http://stackoverflow.com/q/21548712
tags question: http://stackoverflow.com/q/21621819
tags question: http://stackoverflow.com/q/21660068
tags question: http://stackoverflow.com/q/21666849
tags question: http://stackoverflow.com/q/21600898
tags question: http://stackoverflow.com/q/21570898
tags question: http://stackoverflow.com/q/21619661
tags question: http://stackoverflow.com/q/21655010
tags question: http://stackoverflow.com/q/21529597
tags question: http://stackoverflow.com/q/21596702
tags question: http://stackoverflow.com/q/21676119
tags question: http://stackoverflow.com/q/21571582
tags question: http://stackoverflow.com/q/21638751
tags question: http://stackoverflow.com/q/21521336
tags question: http://stackoverflow.com/q/21575029
tags question: http://stackoverflow.com/q/21674440
tags question: http://stackoverflow.com/q/21662644
tags question: http://stackoverflow.com/q/21547637
tags question: http://stackoverflow.com/q/21659230
tags question: http://stackoverflow.com/q/21565795
type: Tag
tags question: http://stackoverflow.com/q/21545977
tags question: http://stackoverflow.com/q/21671445
tags question: http://stackoverflow.com/q/21622570
tags question: http://stackoverflow.com/q/21656949
tags question: http://stackoverflow.com/q/21635518
tags question: http://stackoverflow.com/q/21677984
tags question: http://stackoverflow.com/q/21537827
tags question: http://stackoverflow.com/q/21653344
tags question: http://stackoverflow.com/q/21653453
tags question: http://stackoverflow.com/q/21614681
tags question: http://stackoverflow.com/q/21534467
tags question: http://stackoverflow.com/q/21599133
tags question: http://stackoverflow.com/q/21631399
tag name: jsp
tags question: http://stackoverflow.com/q/21647217
tags question: http://stackoverflow.com/q/21520419
tags question: http://stackoverflow.com/q/21551072
tags question: http://stackoverflow.com/q/21593878
tags question: http://stackoverflow.com/q/21636719
tags question: http://stackoverflow.com/q/21608863
tags question: http://stackoverflow.com/q/21536191
tags question: http://stackoverflow.com/q/21518930
tags question: http://stackoverflow.com/q/21578764
tags question: http://stackoverflow.com/q/21522518
tags question: http://stackoverflow.com/q/21521238
tags question: http://stackoverflow.com/q/21548270

http://stackoverflow.com/a/21516336
answers question: http://stackoverflow.com/q/21516303
has comment: http://stackoverflow.com/comment/32486753
type: Answer
has comment: http://stackoverflow.com/comment/32485477
score: 3
downvote count: 0
has body: The problem is that this toString will produce a big block of code. Lets say it is called Student. If you wanted to log: Student X linked to student Y because of Z. Then the X and Y are going to become massive, and the whole line gets split out and unreadable. You might have a "toFullDescription" or something method that looks like your current toString, but the toString should just have a few meaningful elements, probably just the name and Id inside curly braces.
has comment: http://stackoverflow.com/comment/32485407
upvote count: 3
accepted answer of: http://stackoverflow.com/q/21516303
type: AcceptedAnswer

http://stackoverflow.com/q/21583474
has body: I have the following Java code snipped: def offer = new OfferBuilder().id(1) .rulesId(1) .secondaryRulesId(0L) .code("test code") .characteristics([characteristics]) .build() I would like to replace it with the following Groovy: def offer = new Offer(id: 1, rulesId: 1, secondaryRulesId: 0L, code: "test code", characteristics: [characteristics]) I'm using Intellij built-in regex to replace: new (\w+)Builder\((\)\s?\.(\w+)\(([a-zA-Z0-9\" \[\]]+))+\).build\(\) Replacement string: new $1($3: $4) The problem is that I can only replace last occurrence of matched groups, so that it outputs: def offer = new Offer(characteristics: [characteristics]) I've been trying to use capturing on repeated gruoup, but still can't make it work. Can you please advise what's missing?
tagged with: java
tagged with: intellij-idea
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/32630677
has comment: http://stackoverflow.com/comment/32707092
favorite count: 0
tagged with: groovy
tagged with: regex
has comment: http://stackoverflow.com/comment/34837323
has answer: http://stackoverflow.com/a/23442600
has title: Regex replace with capturing a repeated group
upvote count: 3
type: UnansweredQuestion
type: Question
score: 3

http://stackoverflow.com/a/21585986
score: 2
downvote count: 0
has body: The optional keyword was the right choice. To test, whether or not a particular optional field is set or not, use the isset flags: struct MyBean { 1: i32 IntValue } gives public class MyBean implements org.apache.thrift.TBase&lt;MyBean, MyBean._Fields&gt;, java.io.Serializable, Cloneable, Comparable&lt;MyBean&gt; { // ... lots of other code omitted ... // isset id assignments private static final int __INTVALUE_ISSET_ID = 0; private byte __isset_bitfield = 0; // ... lots of other code omitted ... /** Returns true if field IntValue is set (has been assigned a value) and false otherwise */ public boolean isSetIntValue() { return EncodingUtils.testBit(__isset_bitfield, __INTVALUE_ISSET_ID); } public void setIntValueIsSet(boolean value) { __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __INTVALUE_ISSET_ID, value); } // ... even more code omitted ... }
upvote count: 2
answers question: http://stackoverflow.com/q/21576060
type: Answer

http://stackoverflow.com/a/21653267
type: Answer
answers question: http://stackoverflow.com/q/21652931
score: 0
has body: I think the best aproach in this case would be create a task for every server since they will be executed by the threads in the pull and then use tge future objects to retrieve server information returned by the task.

http://stackoverflow.com/comment/32651668
comment on: http://stackoverflow.com/q/21610545
has text: I'm no expert but you could check http://itext-general.2136553.n4.nabble.com/iText-how-to-remove-the-layer-watermark-td3576811.html for info. However, it will not be a trivial task.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21647643
favorite count: 0
has answer: http://stackoverflow.com/a/21647874
has comment: http://stackoverflow.com/comment/32717118
has body: Pre-notes: Yes, this is homework. Our school's tutor is out for the day My book is useless I'm not exactly sure what to search for on google for help with my confusion... Question: Anyway - The question / confusion that I have involves the first bit of code that I have in my program to test the compareTo method. Would I use the variables at the top of the code as my variables in the static void main area, or assign new variables, like I do have? The values in public Date()... &lt;-- Is that the date that my code in static void main is comparing to? (If so, I have a piece of code that I want to use that uses the current date, rather than what's in Date()). I may have more questions later on, but I hope that someone can clear up my confusion better than my book or google has proven thus far. Code: package date; import java.util.*; public class Date implements Comparable { static Scanner console = new Scanner(System.in); private int dMonth; //Part a of confusion 1 private int dDay; private int dYear; public Date() { dMonth = 1; //Confusion 2 dDay = 1; dYear = 1900; } public Date(int month, int day, int year) { dMonth = month; dDay = day; dYear = year; } public void setDate(int month, int day, int year) { dMonth = month; dDay = day; dYear = year; } public int getMonth() { return dMonth; } public int getDay() { return dDay; } public int getYear() { return dYear; } public String toString() { return (dMonth + "." + dDay + "." + dYear); } public boolean equals(Object otherDate) { Date temp = (Date) otherDate; return (dYear == temp.dYear &amp;&amp; dMonth == temp.dMonth &amp;&amp; dDay == temp.dDay); } public int compareTo(Object otherDate) { Date temp = (Date) otherDate; int yrDiff = dYear - temp.dYear; if (yrDiff !=0) return yrDiff; int monthDiff = dMonth - temp.dMonth; if (monthDiff !=0) return monthDiff; return dDay - temp.dDay; } public static void main(String[] args) //Part b of confusion 1 { int month; int day; int year; Date temp; System.out.print("Enter date in the …
has comment: http://stackoverflow.com/comment/32718265
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32716613
upvote count: 1
has answer: http://stackoverflow.com/a/21647873
has title: Confusion about java dates comparison
tagged with: compareto
has comment: http://stackoverflow.com/comment/32716499
score: 1
tagged with: java
type: Question
downvote count: 0
has comment: http://stackoverflow.com/comment/32717251
answer count: 2
has comment: http://stackoverflow.com/comment/32716596

http://stackoverflow.com/a/21687504
answers question: http://stackoverflow.com/q/21587202
has body: I fixed my problem, here's the updated makefile: SRC=DCDTsrc TGT=obj INCLUDES=-IDCDTsrc DCDTWrapper.h SearchAlgorithms.h FLAGS=-stdlib=libstdc++ -std=c++0x -D GS_SYSTEM_RAND_LIBS -lm -fPIC -I/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/ -v SOURCES=$(wildcard $(SRC)/*.cpp) DCDTWrapper.cpp SearchAlgorithms.cpp OBJS=$(addprefix $(TGT)/, $(notdir $(SOURCES:.cpp=.o))) CC=g++ # Define a variable for classpath CLASS_PATH = ../bin # Define a virtual path for .class in the bin directory vpath %.class $(CLASS_PATH) $(TGT)/%.o: $(SRC)/%.cpp $(CC) $(FLAGS) -c $&lt; -o $@ $(TGT)/%.o: %.cpp $(CC) $(FLAGS) -c $&lt; -o $@ # $@ matches the target, $&lt; matches the first dependancy libsearchalgorithms.dylib: $(OBJS) libtool -lc -lstdc++ -ldl -macosx_version_min 10.9 -lm -dynamic -lSystem $(OBJS) -o libsearchalgorithms.dylib SearchAlgorithms.h : SearchAlgorithms.class javah -classpath $(CLASS_PATH) $* clean: rm -rf $(TGT) mkdir $(TGT) if [ -a SearchAlgorithms.h ] ; \ then \ rm SearchAlgorithms.h ; \ fi; if [ -a libsearchalgorithms.o ] ; \ then \ rm libsearchalgorithms.o ; \ fi; if [ -a libsearchalgorithms.dylib ] ; \ then \ rm libsearchalgorithms.dylib ; \ fi; all:clean SearchAlgorithms.h libsearchalgorithms.dylib
score: 0
type: Answer

http://stackoverflow.com/comment/32536855
comment on: http://stackoverflow.com/q/21545734
score: 1
type: Comment
type: QuestionComment
has text: Based on the logcat output, it looks like your password is wrong. Just compare "kongkong" with "f10343d1dc8d44c8935b356aa3f8aae2"

http://stackoverflow.com/comment/32767137
has text: JSONObject jsonObject = new JSONObject(result);
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21676256

http://stackoverflow.com/comment/32639785
comment on: http://stackoverflow.com/a/21603472
has text: what does that mean ?
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/21586008
upvote count: 1
accepted answer of: http://stackoverflow.com/q/21584217
type: AcceptedAnswer
downvote count: 1
answers question: http://stackoverflow.com/q/21584217
has comment: http://stackoverflow.com/comment/32701337
type: Answer
has body: You probably want to take a look at android:layout_weight, which allows you to abstract the specific devices' screens and it will scale appropriately. See here for more info and some examples. From the link above (the android docs): LinearLayout also supports assigning a weight to individual children with the android:layout_weight attribute. This attribute assigns an "importance" value to a view in terms of how much space is should occupy on the screen. A larger weight value allows it to expand to fill any remaining space in the parent view. Child views can specify a weight value, and then any remaining space in the view group is assigned to children in the proportion of their declared weight. Default weight is zero. For example, if there are three text fields and two of them declare a weight of 1, while the other is given no weight, the third text field without weight will not grow and will only occupy the area required by its content. The other two will expand equally to fill the space remaining after all three fields are measured. If the third field is then given a weight of 2 (instead of 0), then it is now declared more important than both the others, so it gets half the total remaining space, while the first two share the rest equally.
score: 0

http://stackoverflow.com/a/21549462
has body: Create PrintWriter instance out of your while loop.
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21549379
upvote count: 1
score: 1

http://stackoverflow.com/a/78521042
upvote count: 1
has comment: http://stackoverflow.com/comment/139108293
downvote count: 0
has body: The official PostgreSQL JDBC driver now has support for LISTEN and NOTIFY, see https://jdbc.postgresql.org/documentation/server-prepare/#listen--notify
type: Answer
score: 1
answers question: http://stackoverflow.com/q/21632243

http://stackoverflow.com/comment/32702124
type: Comment
has text: is there other way? I can't do this because I am using many methods.
comment on: http://stackoverflow.com/a/21638962
score: 0
type: AnswerComment

http://stackoverflow.com/q/21673270
type: AnsweredQuestion
has title: Java - String input in textField - search arrayList - include partial matches
tagged with: jtextfield
type: Question
has answer: http://stackoverflow.com/a/21673560
accepted answer: http://stackoverflow.com/a/21673560
tagged with: java
score: 0
has body: Have been at this for a while so I think it's time for some much needed help. I have the following if statement in an action listener('but' - being the Search button that gets clicked for the following to happen).I have an arrayList(used to save data from database) in my class, calling a specific record works perfectly. I am trying to create a search textField(named 'tf' below). I have been able to search only by typing an exact match to what ever is being searched, but I want to be able to use partial matching on any String in tf. Everything that's commented out is different stuff that I have been testing, therefore can be ignored. The statement: if( srch.getText().equals("You have chosen to search by movie: " ) ... this is used to make sure that the person is searching only when the panel includes this title, as there is a genre search as well on the same panel. Only the title changes. if(source.equals(but)){ //String b = a.get(0).get(1); String result = tf.getText(); Pattern pat = Pattern.compile("[a-z]+"); Matcher m = pat.matcher(result); //boolean bool = m.matches(); int i = 0; //al.contains(result) &amp;&amp; pat.matcher(a.get(i).get()).matches()) // &amp;&amp; z.contains(result) if( srch.getText().equals("You have chosen to search by movie: " )){ for (ArrayList&lt;String&gt; al : a){ if (pat.m(a.get(i).get(0)).matches()){ System.out.println(a.get(i).get(0)); //movie name System.out.println(a.get(i).get(1)); //movie desc } i++; } //ta.setText(b); } else{ ta.setText("Please try searching by movie"); } } In summary, everything works fine. I just need a regex code to find partial matches as well and a way to add that into my loops. I've added as little code as possible as not to waste anyone's time, so please let me know if any other is needed.Many thanks in advance. Eventually any full or partial matches will display the movie name and description.
answer count: 1
tagged with: arraylist
tagged with: regex

http://stackoverflow.com/a/21698983
type: Answer
answers question: http://stackoverflow.com/q/21641431
has body: I would keep monitoring and scheduling separate. Quartz is good, as another answer suggests. For monitoring try http://metrics.codahale.com/ or http://jamonapi.sourceforge.net/
score: 0

http://stackoverflow.com/q/21559811
has comment: http://stackoverflow.com/comment/32561910
has comment: http://stackoverflow.com/comment/32561913
downvote count: 1
type: Question
tagged with: hashmap
has comment: http://stackoverflow.com/comment/32562183
has comment: http://stackoverflow.com/comment/32562354
score: 0
has comment: http://stackoverflow.com/comment/32562043
answer count: 1
has comment: http://stackoverflow.com/comment/32562179
favorite count: 0
has answer: http://stackoverflow.com/a/21559901
has body: Lets say I have two maps: Map mapA = new HashMap(); Map mapB = new HashMap(); mapA.put("JEETENDRA", "24"); mapA.put("AHUJA", "24"); --1A mapA.put("AHUJA", "25");---2A mapA.put("PAL", "24"); mapB.put("AHUJA", "24"); mapB.put("JEETENDRA", "24");---1B mapB.put("PAL", "24"); Now i want to compare both maps by both key and value since 2A and 1A have key common. I know ideally its wrong since key should be unique for map but in code I am retrieving two column record and storing it as map. MapA is before operations. MapB is after some operations.
upvote count: 1
accepted answer: http://stackoverflow.com/a/21559901
tagged with: dictionary
has comment: http://stackoverflow.com/comment/32562474
has title: How to compare two maps by both key and value and storing difference map in resultant map
has comment: http://stackoverflow.com/comment/32562282
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32562213
tagged with: java

http://stackoverflow.com/comment/32512211
has text: Switch statements on Strings requires Java 7. Android only supports up to Java 6
type: Comment
score: 3
type: AnswerComment
comment on: http://stackoverflow.com/a/21530777

http://stackoverflow.com/a/39175216
has body: The JdbcTemplate class does not support named parameters. You have to use the 'NamedParameterJdbcTemplate' class for this task. See bellow the source code to do what you want: final NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(dataSource); final Date d = new Date("2014-02-06"); int count = template.queryForObject( "SELECT COUNT(load_starttime) FROM Load WHERE load_starttime=:load_starttime", new MapSqlParameterSource().addValue("load_starttime", new java.sql.Date(d.getTime())), Integer.class );
type: Answer
answers question: http://stackoverflow.com/q/21605645
score: 0

http://stackoverflow.com/q/21607000
has comment: http://stackoverflow.com/comment/32645153
has answer: http://stackoverflow.com/a/21607059
type: UnansweredQuestion
downvote count: 2
has title: Searching in the browser through java
has body: I have this code and I was wondering if it was possible to input a search into google through my java program. For example when the user inputs google it will open google.com and the program will automatically fill the search in from another string they entered. For example if the userInput string was google.com:what year is it? How could I make the program search "what year is it?" in the browser? else if(userInput.contains("google.com")) { try { Desktop.getDesktop().browse(new URL("http://google.com").toURI()); } catch (Exception e) {} }
tagged with: java
type: Question
upvote count: 0
score: -2
has comment: http://stackoverflow.com/comment/32645204
favorite count: 0
linked to: http://stackoverflow.com/q/10967451
answer count: 1
has comment: http://stackoverflow.com/comment/32645292
has comment: http://stackoverflow.com/comment/32645138

http://stackoverflow.com/a/21572514
upvote count: 2
accepted answer of: http://stackoverflow.com/q/21565787
has comment: http://stackoverflow.com/comment/89283478
type: AcceptedAnswer
downvote count: 0
has body: Often when transferring models from Blender to something like JME, the textures will be upside down. Where you load the texture: barrelMat.setTexture(“DiffuseMap”, assetManager.loadTexture(“models/barrel/Barrel.jpg”)); Instead use the TextureKey form of the loadTexture() method and pass yFlip false since true is the default. assetManager.loadTexture(new TextureKey(“models/barrel/Barrel.jpg”, false)); That should fix your issue. References: loadTexture() : http://hub.jmonkeyengine.org/javadoc/com/jme3/asset/AssetManager.html#loadTexture(com.jme3.asset.TextureKey) TextureKey : http://hub.jmonkeyengine.org/javadoc/com/jme3/asset/TextureKey.html#TextureKey(java.lang.String,%20boolean)
answers question: http://stackoverflow.com/q/21565787
type: Answer
score: 2

http://stackoverflow.com/q/21537993
type: Question
has title: Modifying a WritebleWorkbook already exits with java
tagged with: jxl
score: 0
has answer: http://stackoverflow.com/a/21538079
answer count: 1
type: UnansweredQuestion
has body: My problem is to write on an Excel workbook! But my program controls if the file already exists! If the file exists then write on the next free cell, else create the file! I tried with: private WritableWorkbook wwb; try { file = new File(filename); System.out.println("File" + file.toString()); if(file.exists()) { JOptionPane.showMessageDialog(null, "Il file esiste!"); wwb.setOutputFile(file); fileExist=true; } else { JOptionPane.showMessageDialog(null, "Il file non esiste!Quindi lo creo"); fileExist=false; WorkbookSettings wbSettings = new WorkbookSettings(); wbSettings.setLocale(new Locale("it", "IT")); wwb = Workbook.createWorkbook(new File((filename)), wbSettings); wwb.createSheet("Ticket", 0); } } catch(Exception ex) { System.out.println(ex.getStackTrace()); } The problem is a NullPointerException that I think is on the line: wwb.setOutputFile(file); I tried to search javadocs on WritableWorkbook but I see that there aren't constructors! How can i do this? Please help. I'm using the jxl API.
tagged with: java
tagged with: excel

http://stackoverflow.com/q/21626843
tagged with: maven-3
favorite count: 0
tagged with: javaagents
type: Question
has title: Use Jolokia JVM agent directly in a Maven Java project
has answer: http://stackoverflow.com/a/21631866
has body: I have a simple Java Maven project and want to use the JVM agent from Jolokia to fetch JMX values. It works when I manually download the jolokia-jvm-1.1.5-agent.jar and add the absolute path to the java-arguments like -javaagent:/absolute/path/to/jolokia-jvm-1.1.5-agent.jar. As the Jolokia Download page also lists maven dependencies (jolokia-core) I wonder if I can include this directly into my Maven build without manually downloading the JVM agent? How can I run my program with this javaagent?
score: 4
tagged with: maven
answer count: 1
accepted answer: http://stackoverflow.com/a/21631866
tagged with: java
upvote count: 4
type: AnsweredQuestion
tagged with: jolokia
downvote count: 0

probability
tags question: http://stackoverflow.com/q/21591096
type: Tag
tag name: probability

http://stackoverflow.com/comment/32703443
type: QuestionComment
comment on: http://stackoverflow.com/q/21639667
has text: the name was set up incorrectly, it was data3, changed it and I still got the same problem, unfortunately im not getting a stack trace, just the exception I placed above
score: 0
type: Comment

http://stackoverflow.com/a/21581501
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21580638
type: Answer
has comment: http://stackoverflow.com/comment/32629988
answers question: http://stackoverflow.com/q/21580638
upvote count: 1
has body: To load a message bundle you can call: ResourceBundle.getBundle(baseName, locale, loader); As specified in javadoc: ... getBundle attempts to locate a property resource file. It generates a path name from the candidate bundle name by replacing all "." characters with "/" and appending the string ".properties". It attempts to find a "resource" with this name using ClassLoader.getResource So the main thing is that your bundles are visible to the classloader. You can create in your project a package, say resource, and put your bundles inside it. Suppose that your bundle name is mycomponent.properties the baseName should be: resource.mycomponent The content of this package should seem something like a list of i18n files: mycomponent.properties (this is the defualt bundle when no locale is specified) mycomponent_en.properties mycomponent_it.properties ... This package is distributed in your jar within you code. A web module that use your component has your jar in its WEB-INF\lib (or in a shared folder of the application server) and your i18n exception messages too.
score: 1
has comment: http://stackoverflow.com/comment/32650527
type: AcceptedAnswer

http://stackoverflow.com/a/21548559
score: 0
has comment: http://stackoverflow.com/comment/32541741
type: AcceptedAnswer
has body: If the size is constant then arrays would be fine . Since they might be objects at later so better to use List implementations.
type: Answer
accepted answer of: http://stackoverflow.com/q/21548413
answers question: http://stackoverflow.com/q/21548413
has comment: http://stackoverflow.com/comment/32541948

http://stackoverflow.com/q/21676860
has answer: http://stackoverflow.com/a/22279410
has answer: http://stackoverflow.com/a/21679252
has body: I never used Spring AOP and trying to configure my first bean. It seems that I configured it properly, but I get an exception that the bean is not found. My aspect is – @Aspect @Component public class IdentificationAspect { @Before("execution(* ru.sbt.filial.cards.aspect.SomeBean.*(..))") public void logBefore(JoinPoint joinPoint) throws Throwable { System.out.println("logBefore() is running!"); System.out.println("hijacked : " + joinPoint.getSignature().getName()); System.out.println("******"); } } And my bean that AOP doesn't find is - package ru.sbt.filial.cards.aspect; import org.springframework.stereotype.Component; @Component public class SomeBean { public void printSmth() { System.out.println("!!!!!!!!!!!"); } } I've got the following exception - Caused by: java.lang.IllegalArgumentException: warning no match for this type name: ru.sbt.filial.cards.aspect.SomeBean [Xlint:invalidAbsoluteTypeName] at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:301) at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:207) at org.springframework.aop.aspectj.AspectJExpressionPointcut.getFallbackPointcutExpression(AspectJExpressionPointcut.java:358) at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:255) at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:208) at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:262) at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:294) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvi…
answer count: 3
tagged with: java
type: UnansweredQuestion
upvote count: 18
has answer: http://stackoverflow.com/a/52638952
has comment: http://stackoverflow.com/comment/32771141
downvote count: 0
favorite count: 0
has title: java.lang.IllegalArgumentException: warning no match for this type name: ru.sbt.filial.cards.aspect.SomeBean [Xlint:invalidAbsoluteTypeName]
tagged with: spring-aop
type: Question
tagged with: spring
score: 18

http://stackoverflow.com/comment/85638805
type: Comment
score: 0
comment on: http://stackoverflow.com/a/21650037
type: AnswerComment
has text: @wypieprz quot method returns quotient. How to get division of two expressions?

http://stackoverflow.com/q/21659598
has comment: http://stackoverflow.com/comment/33226601
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21794250
has comment: http://stackoverflow.com/comment/32976874
tagged with: java
downvote count: 3
tagged with: smpp
type: Question
score: -2
answer count: 1
has body: I have created a smpp server from logica. It was worked fine. But the client wanto delivery status,now how can I send thre delivery_sm response to client. please suggest.
has title: How to send delivery_sm response to a client from a smpp server
has answer: http://stackoverflow.com/a/21794250
favorite count: 0
upvote count: 1
has comment: http://stackoverflow.com/comment/32976776

http://stackoverflow.com/comment/32576455
comment on: http://stackoverflow.com/a/21565874
score: 0
type: AnswerComment
has text: thanks I was looking for some Guide. Thanks a ton again for you inputs :)
type: Comment

http://stackoverflow.com/comment/32667100
score: 0
comment on: http://stackoverflow.com/a/21618968
type: AnswerComment
type: Comment
has text: Hi @user3242955. That's what it looks like when you do the `name.insert(3...`. But I'm not sure how the `FBArrayList()` is implemented...

http://stackoverflow.com/q/21579845
score: 5
has comment: http://stackoverflow.com/comment/39645778
has answer: http://stackoverflow.com/a/25293831
has comment: http://stackoverflow.com/comment/39612636
answer count: 3
has answer: http://stackoverflow.com/a/25318671
has answer: http://stackoverflow.com/a/21580144
has title: PermGen space with jetty
tagged with: maven-3
favorite count: 0
has body: I'm developing a java web application where I'm using mavenlike tool of project managment. Now my trouble is that if i setted jetty for autoscan each 20 second in this way: org.mortbay.jetty jetty-maven-plugin ${maven-jetty-plugin.version} 10 /${project.name} target/classes;../services/target/classes; target/classes ../services/target/classes Jetty starts in a correct way in fact i get: [INFO] Started Jetty Server [INFO] Starting scanner at interval of 20 seconds. But at the first scan i get the following error: ERROR ContextLoader - Context initialization failed java.lang.OutOfMemoryError: PermGen space How can I do to fix it? Update 1 I try to increse a PermGen space from my Eclipse Ide in this way: but after the first scan i get back the same error. How can I do to fix it?
upvote count: 5
type: UnansweredQuestion
tagged with: jetty
tagged with: maven
has comment: http://stackoverflow.com/comment/39639284
downvote count: 0
tagged with: java
type: Question

http://stackoverflow.com/a/21674058
has body: There you go, just check your divisor using something like this first if (testcase11 != 0 &amp;&amp; testcase12 != 0 &amp;&amp; testcase13 != 0)
score: 0
answers question: http://stackoverflow.com/q/21673802
type: Answer

http://stackoverflow.com/q/21592979
has body: I'd like to get the value of a specific key when my web server detects a POST request. The best method I found is : String content = request.getContent(); Example of POST data : field1=some-data&amp;field2=other-data I need to get : "some-data" from a given field "field1" I tried to use : String value = request.getParameter("field1"); But it works only if I pass my data into the URL .. I wonder if I should use regex. If it is the case, what is the best pattern ? Thanks in advance!
tagged with: java
type: Question
has title: Web Server : retrieve POST data values
has comment: http://stackoverflow.com/comment/32621357
tagged with: webserver
tagged with: post
has comment: http://stackoverflow.com/comment/32621331
score: 0
has comment: http://stackoverflow.com/comment/32621405
has comment: http://stackoverflow.com/comment/32621517
type: UnansweredQuestion
tagged with: regex
answer count: 0

http://stackoverflow.com/comment/33206632
comment on: http://stackoverflow.com/a/21876381
has text: FetchType.EAGER means you will be eagerly fetching country's entire structure, not good for performance. Let's say this data is displayed on a page that lists's all countries, that means you'll be retrieving the entire world (whatever is stored in those tables) just to show a few records. If you need to fetch it eagerly, then do it just for a single country, use a JPQL's JOIN FETCH to control when to lazy/eager fetch.
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32573924
has text: I know that some will definitely not need it but the interface has also other methods which will be needed. In any case, does aspectj support this?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21565850

http://stackoverflow.com/q/21622336
tagged with: android
has title: How to play audio continuously while orientation going to change in android
has answer: http://stackoverflow.com/a/21622674
has body: I have develop application like media player to use for playing audio file from source but issue when I am change the orientation portrait to landscape button and other widget not working and other that is when I am again change orientation landscape to portrait so same issue button and seek bar is not working my code is here public class Aarati_Activity extends Fragment { private ImageButton btnplay; private SeekBar seekbar; MediaPlayer mp; private ImageButton btnstop; private int finalTime = 0; private int startTime = 0; private int oneTimeOnly = 0; Handler handler=new Handler(); public Aarati_Activity() {} int audiocurrent; int audiomax; private int mp_progress; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.activity_aarti_fragment, container, false); btnplay=(ImageButton)v.findViewById(R.id.btnplay); btnstop=(ImageButton)v.findViewById(R.id.btnstop); seekbar=(SeekBar)v.findViewById(R.id.seekbar); seekbar.setClickable(true); seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { seekchange(); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { } }); mp = MediaPlayer.create(getActivity(), R.raw.arti); audiomax=mp.getDuration(); audiocurrent=mp.getCurrentPosition(); btnstop.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if(mp.isPlaying()) { mp.stop(); Toast.makeText(getActivity(), "Stop",Toast.LENGTH_LONG).show(); btnplay.setImageResource(R.drawable.ic_action_play); try { mp.prepare(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else { Toast.makeText(getActivity(),"Aarti Currently not playing",Toast.LENGTH_SHORT).show(); } } }); btnplay.setOnClickListener(new OnClickListener() { @Override public …
tagged with: java
type: Question
tagged with: android-mediaplayer
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/21622372
tagged with: android-orientation
type: UnansweredQuestion

http://stackoverflow.com/q/21598674
tagged with: beanshell
score: 1
tagged with: java
upvote count: 1
type: Question
has body: I would like to create a command to use with the BeanShell library. I created a class like this: package org.manu.bshformulas; import bsh.CallStack; import bsh.Interpreter; public class IfNegative { public static double invoke(Interpreter env, CallStack callstack, double x, double y, double z) { if(x &lt; 0) { return y; } return z; } } And I want to use it in this main class: package org.manu; // imports.... public class TestFormulaParser { private static final String COMMAND = "IfNotNegative(x, y, y / x)"; public static void main(String[] args) throws Exception { double x=3; double y=2; Interpreter interprete = new Interpreter(); interprete.set("x", x); interprete.set("y", y); double output = Double.valueOf(interprete.eval(COMMAND).toString()); return output; } But it says to me that it does not recognize the IfNegative command. How can I import the command?
answer count: 2
downvote count: 0
favorite count: 0
has title: Create a Compiled Java Command for BeanShell
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21704888
linked to: http://stackoverflow.com/q/14213600
has answer: http://stackoverflow.com/a/24132053

http://stackoverflow.com/comment/32628227
comment on: http://stackoverflow.com/q/21593084
score: 0
has text: you should really use scene2d! It is much easier and with this (http://code.google.com/p/libgdx/wiki/scene2d) tutorial i think you understand it soon.
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21583961
upvote count: 3
tagged with: asynchronous
favorite count: 0
answer count: 0
has title: Rabbitmq asynchronous queue consumption
has body: I'm working on this tutorial : http://www.rabbitmq.com/tutorials/tutorial-five-java.html And if I execute the following instructions : 1 &gt; java java -cp $CP ReceiveLogsTopic 1 2 &gt; java java -cp $CP ReceiveLogsTopic 2 3 &gt; java -cp $CP EmitLogTopic 1 a The message "a" is received by the consumer and displayed. But if I do this : 1 &gt; java java -cp $CP ReceiveLogsTopic 1 2 &gt; java -cp $CP EmitLogTopic 1 a 3 &gt; java java -cp $CP ReceiveLogsTopic 2 4 &gt; java -cp $CP EmitLogTopic 2 b Only message "b" is displayed because the consumer is declared before the producer. So my question is, is there a way to declare a queue "asychronous" and force it to keeps messages in the queue until a consumer read it ? Sincerely
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/39655198
tagged with: rabbitmq
has comment: http://stackoverflow.com/comment/39655711
score: 3
tagged with: java
tagged with: queue
type: Question
downvote count: 0

http://stackoverflow.com/a/21632068
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32689464
type: Answer
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/21631720
accepted answer of: http://stackoverflow.com/q/21631720
has body: You're dealing with a JSONArray - the [ ] - that contains two separate JSONObject. The way you extract values from this structure is simply to go piece by piece, first getting the nested objects from the array and then extracting their internal values. You can then repackage it as you wish. For example: int numObject = jsonArray.length(); JSONArray repackArray = new JSONArray(); for(int i = 0; i &lt; numObject; i++){ JSONObject nested = jsonArray.getJsonObject(i); //get values you need String email = nested.getString("email"); String language = nested.getString("language"); String name = nested.getString("name"); //add values to new object JSONObject repack = new JSONObject(); repack.put("email", email); repack.put("language", language); repack.name("name", name); //add to new array repackArray.put(repack); } Alternatively if put doesn't work for you, you can always create your own String in JSON format and then simply create a new JSONObject using that string as an argument in the constructor. I assumed you were working with a JSONArray in the above example. If you're starting with a JSONObject the process is the same. Just get the JSONArray out of the object first before unpacking.
has comment: http://stackoverflow.com/comment/32689711
upvote count: 2

http://stackoverflow.com/comment/32750874
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21666666
score: 0
has text: And note that this applies to all object-oriented languages. It isn't specific to Java and in fact it predates Java considerably.

http://stackoverflow.com/a/21641187
has comment: http://stackoverflow.com/comment/32706063
has body: Works for me. String in = "3:2 2:26 1:11 8:4 4:25"; String[] split = in.split(" "); int sum = 0; for(int i = 0; i &lt; split.length; i++) { try { sum += Integer.parseInt(split[i].split(":")[1]); } catch(NumberFormatException e) { System.out.println("Input not a number"); } } System.out.println(sum);
score: 1
accepted answer of: http://stackoverflow.com/q/21641152
upvote count: 1
answers question: http://stackoverflow.com/q/21641152
type: AcceptedAnswer
downvote count: 0
type: Answer

http://stackoverflow.com/comment/96699093
has text: You should serve the images direct to the output on demand via ` ` URLs. There's no reason to be loading them into memory at the server, and especially not to construct them as images.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21572999
type: Comment

http://stackoverflow.com/q/21579452
has body: The project, on which i am working,is integrated on spring3, hibernate, jsf2.0, also using annotations.The project have different modules and each module have different processes and each process contains Master Details screens.In module, All Processes are dependent/related to one another from top to bottom.Custom search is developed throughout the module in each process.Now on the project requirements,it needs to develop global search throughout the Module.Each module has 90 database tables with huge data inside and there is a "Item Table" which is used throughout the Module(all processes details screens revised that item). Through global search user will enter an item and search it.Searching should returns all processes details in result(output) within seconds. As i already told above that each table also have huge data inside.What should be the mechanism to develop fast searching feature to avoid from System hanging or going down. Overview: Searching Flow:Suppose Item No:1234--&gt; Module--&gt;Each process --&gt;Each process details--&gt;items details found Developing Tools: eclipse-jee-juno-win32 , Microsoft SQL Server. please help
duplicate of: http://stackoverflow.com/q/21347995
has comment: http://stackoverflow.com/comment/32598736
score: 0
has comment: http://stackoverflow.com/comment/32597172
has comment: http://stackoverflow.com/comment/32598311
answer count: 0
type: UnansweredQuestion
tagged with: spring
tagged with: jsf
tagged with: java
tagged with: hibernate
linked to: http://stackoverflow.com/q/21347995
has comment: http://stackoverflow.com/comment/32597329
has title: fast global search (jsf, spring, hibernate)
type: Question

http://stackoverflow.com/a/21562268
downvote count: 0
has comment: http://stackoverflow.com/comment/32568831
has comment: http://stackoverflow.com/comment/32566325
type: Answer
has comment: http://stackoverflow.com/comment/32567837
has comment: http://stackoverflow.com/comment/32568916
has body: Add bracket for IF condition if (inList(in,numbersArray)) { numbersArray[n]=in; n++; }
upvote count: 1
accepted answer of: http://stackoverflow.com/q/21562192
answers question: http://stackoverflow.com/q/21562192
has comment: http://stackoverflow.com/comment/32566365
score: 1
has comment: http://stackoverflow.com/comment/32567618
type: AcceptedAnswer

http://stackoverflow.com/a/44711011
type: Answer
answers question: http://stackoverflow.com/q/21578953
score: 0
has body: try to remove this line in run method of listenthread class. intosockb.close(); that is closing the stream, which is closing the socket.

http://stackoverflow.com/a/21618597
answers question: http://stackoverflow.com/q/21618538
has comment: http://stackoverflow.com/comment/32666757
upvote count: 5
type: AcceptedAnswer
downvote count: 0
score: 5
has body: If you have a string with a length of 6 then the last index you can access is 5. When you used this for(int v = 1; v &lt;= c.length(); v++) you end up trying to access an index of 6 which does not exist. Just change to for(int v = 0; v &lt; c.length(); v++) // Notice &lt; instead of &lt;= Also, notice I changed v = 1 to v = 0. Java Strings are indexed starting at 0 so you need to start there to access the first character of your string.
type: Answer
accepted answer of: http://stackoverflow.com/q/21618538

http://stackoverflow.com/comment/32737989
score: 0
comment on: http://stackoverflow.com/q/21658907
type: Comment
type: QuestionComment
has text: Okay thanks, is that what people mean by normalize then, in the context of SAT?

http://stackoverflow.com/comment/32676890
comment on: http://stackoverflow.com/q/21625214
score: 1
has text: At first place, you should think if returning `null` is good practice. :)
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32565320
score: 0
has text: you don't see how 2014-1-1 and 2014-12-31 cannot be compared as date given that they are strings ? do you know how string comparison is performed?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21559984

http://stackoverflow.com/comment/32715218
comment on: http://stackoverflow.com/q/21646913
score: 1
has text: you don't `return` when you call your recursive methods, is this what you intend?
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21632243
has comment: http://stackoverflow.com/comment/32692293
has answer: http://stackoverflow.com/a/36063163
upvote count: 52
has title: How do I get asynchronous / event-driven LISTEN/NOTIFY support in Java using a Postgres database?
has comment: http://stackoverflow.com/comment/32694715
downvote count: 1
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32701837
tagged with: java
has answer: http://stackoverflow.com/a/22380005
type: Question
has answer: http://stackoverflow.com/a/78521042
accepted answer: http://stackoverflow.com/a/23352527
has comment: http://stackoverflow.com/comment/32692584
has body: From what I can tell, the JDBC drivers for LISTEN/NOTIFY in Java do NOT support true event-driven notifications. You have to poll the database every so often to see if there's a new notification. What options do I have in Java (possibly something other than JDBC?), if any, to get notifications asynchronously in a true event-driven manner without polling?
tagged with: postgresql
possible better answer: http://stackoverflow.com/a/36063163
has answer: http://stackoverflow.com/a/23352527
has comment: http://stackoverflow.com/comment/32783419
answer count: 4
favorite count: 0
has comment: http://stackoverflow.com/comment/32692398
score: 51
linked to: http://stackoverflow.com/q/37916489

http://stackoverflow.com/comment/32703233
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21639458
has text: @user3125076: OK fair enough. You now know what tool you need to use, you have links to the tutorials. I wish you god-speed at finding a decent solution. Good luck.

http://stackoverflow.com/comment/32650860
type: AnswerComment
comment on: http://stackoverflow.com/a/21590597
score: 0
type: Comment
has text: From what I can tell, when I had `HTTP/1.0` originally, that *may* have invoked some "leniency" on the part of the host (figuring things out heuristically for lack of a "Host" header). Thus, originally I happened to get away without the Host header. With `HTTP/1.1` it appears to be required.

http://stackoverflow.com/comment/32728064
type: QuestionComment
comment on: http://stackoverflow.com/q/21654170
has text: Hint: `Character.isLetter('a')` always returns true, because 'a' is a letter :-)
score: 0
type: Comment

http://stackoverflow.com/q/21614743
has comment: http://stackoverflow.com/comment/32660216
has comment: http://stackoverflow.com/comment/32660591
tagged with: android
has comment: http://stackoverflow.com/comment/32661079
has comment: http://stackoverflow.com/comment/32660576
has comment: http://stackoverflow.com/comment/32660732
has comment: http://stackoverflow.com/comment/32660041
type: AnsweredQuestion
tagged with: cordova
accepted answer: http://stackoverflow.com/a/21616222
has comment: http://stackoverflow.com/comment/32660980
type: Question
has comment: http://stackoverflow.com/comment/32660327
has comment: http://stackoverflow.com/comment/32659859
has comment: http://stackoverflow.com/comment/32662207
has comment: http://stackoverflow.com/comment/32660689
tagged with: java
has title: FileTransfer "Saved file:" followed by FileNotFoundException
has comment: http://stackoverflow.com/comment/32660610
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/21616222
has body: My app downloads a zip file from a remote webserver, then extracts it. The javascript successfully calls FileTransfer, which logs: FileTransfer Saved file: file:///data/data/com.yadda.yadda/update.zip As part of the success function, javascript calls my custom update plugin which immediately tests for the file: Context ctx = this.cordova.getActivity().getBaseContext(); File update = new File(ctx.getFilesDir(),"update.zip"); if(!update.exists()) Log.w("File not found",update.getAbsolutePath()); The log for that last line is: File Not Found /data/data/com.yadda.yadda/update.zip Later in a try/catch block I have an InputStream variable created and one of the catch blocks is a FileNotFoundException which is firing every time. Begin edit - more info The FileNotFoundException has an interesting bit. The file path is wrong - even though I'm sending the same "update" variable to create the FileInputStream InputStream fileis = new FileInputStream(update); And the interesting bit of the exception: Caused by: java.io.FileNotFoundException: /data/data/com.yadda.yadda/files/update.zip End edit What is going wrong here? Cordova logs that the file transfer completed and the file was saved, but then the file doesn't exist when I test for it! When I create the FileInputStream, why is the path different, causing the exception? What am I missing? Everything works fine in the IOS version of the app. Edit 2: per request, I browsed the device filesystem and found that update.zip does indeed exist in /data/user/0/com.yadda.yadda

http://stackoverflow.com/q/21669503
has title: How to store data in file date wise in java(Android)
accepted answer: http://stackoverflow.com/a/21669577
has comment: http://stackoverflow.com/comment/32755680
has comment: http://stackoverflow.com/comment/32853482
tagged with: android
tagged with: storage
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32755638
has answer: http://stackoverflow.com/a/21669561
has comment: http://stackoverflow.com/comment/32765922
type: Question
has comment: http://stackoverflow.com/comment/32755079
has answer: http://stackoverflow.com/a/21669577
possible better answer: http://stackoverflow.com/a/21669561
tagged with: java
score: 0
answer count: 2
has body: I want to store data in android application date wise, i.e different data for different day. The data will be just integer values and meanwhile want to retrieve it date wise only. i want to store it in a single file. and then want to display it in a chart format in android datewise.. so is there any way i can do it. or can anyone guide me. Thanks
has comment: http://stackoverflow.com/comment/32755435

recursion
type: Tag
tags question: http://stackoverflow.com/q/21619114
tags question: http://stackoverflow.com/q/21661745
tags question: http://stackoverflow.com/q/21593799
tags question: http://stackoverflow.com/q/21646683
tag name: recursion
tags question: http://stackoverflow.com/q/21644186
tags question: http://stackoverflow.com/q/21665058
tags question: http://stackoverflow.com/q/21597991
tags question: http://stackoverflow.com/q/21593825
tags question: http://stackoverflow.com/q/21616685
tags question: http://stackoverflow.com/q/21671778
tags question: http://stackoverflow.com/q/21562568
tags question: http://stackoverflow.com/q/21568271
tags question: http://stackoverflow.com/q/21545137
tags question: http://stackoverflow.com/q/21516125
tags question: http://stackoverflow.com/q/21642771
tags question: http://stackoverflow.com/q/21544374
tags question: http://stackoverflow.com/q/21540971
tags question: http://stackoverflow.com/q/21562318
tags question: http://stackoverflow.com/q/21610208
tags question: http://stackoverflow.com/q/21635545
tags question: http://stackoverflow.com/q/21653994
tags question: http://stackoverflow.com/q/21539734
tags question: http://stackoverflow.com/q/21641800
tags question: http://stackoverflow.com/q/21545046
tags question: http://stackoverflow.com/q/21592186
tags question: http://stackoverflow.com/q/21556949
tags question: http://stackoverflow.com/q/21624671
tags question: http://stackoverflow.com/q/21670732
tags question: http://stackoverflow.com/q/21661046
tags question: http://stackoverflow.com/q/21615767
tags question: http://stackoverflow.com/q/21618050
tags question: http://stackoverflow.com/q/21545787
tags question: http://stackoverflow.com/q/21556993
tags question: http://stackoverflow.com/q/21633726
tags question: http://stackoverflow.com/q/21517726
tags question: http://stackoverflow.com/q/21570138
tags question: http://stackoverflow.com/q/21568612
tags question: http://stackoverflow.com/q/21646913

http://stackoverflow.com/comment/32577670
type: Comment
has text: load may be null... LOGGER may be null...
score: 4
comment on: http://stackoverflow.com/q/21568095
type: QuestionComment

http://stackoverflow.com/comment/32564463
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21560892
has text: What's the new exception that you are getting? I mean what's the compiler complaining this time about?
type: AnswerComment

http://stackoverflow.com/comment/32675957
type: Comment
type: QuestionComment
has text: I have multiple named queries (create table, insert, analyze table, etc.) run always together and I wondered if I could grouped them into one. I checked and it worked but I was not able to find any information about this in hibernate's manual. I agree correct operation may depend on the target database. Currently hibernate does not interfere in such queries, just send them to db,
comment on: http://stackoverflow.com/q/21611545
score: 0

http://stackoverflow.com/comment/32721744
comment on: http://stackoverflow.com/q/21650334
score: 0
type: Comment
type: QuestionComment
has text: Keep them member if you need to access in multiple unrelated methods (to avoid multiple expensive findViewById calls), local otherwise. Simple as that.

http://stackoverflow.com/comment/41479113
comment on: http://stackoverflow.com/q/21547175
score: 0
has text: Has your question been answered yet?
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21543089
has comment: http://stackoverflow.com/comment/32534373
has comment: http://stackoverflow.com/comment/32543215
has body: I am trying to read a JSON File and do some operations. This JSON file is in Amazon S3 and it is 500MB in size. Future files will be in TeraBytes. Below is my code. public void createHash() throws IOException { System.out.println("Hash Creation Started"); strBuffer = new StringBuffer(""); try { //List all the Buckets List&lt;Bucket&gt;buckets = s3.listBuckets(); for(int i=0;i&lt;buckets.size();i++) { System.out.println("- "+(buckets.get(i)).getName()); } //Downloading the Object System.out.println("Downloading Object"); S3Object s3Object = s3.getObject(new GetObjectRequest(inputBucket, inputFile)); System.out.println("Content-Type: " + s3Object.getObjectMetadata().getContentType()); //Read the JSON File /*BufferedReader reader = new BufferedReader(new InputStreamReader(s3Object.getObjectContent())); while (true) { String line = reader.readLine(); if (line == null) break; // System.out.println(" " + line); strBuffer.append(line); }*/ JSONTokener jTokener = new JSONTokener(new BufferedReader(new InputStreamReader(s3Object.getObjectContent()))); jsonArray = new JSONArray(jTokener); System.out.println("Json array length: "+jsonArray.length()); for(int i=0;i&lt;jsonArray.length();i++) { JSONObject jsonObject1 = jsonArray.getJSONObject(i); StringBuffer hashIndex = new StringBuffer(""); //Add Title and Body Together to the list String titleAndBodyContainer = jsonObject1.getString("title")+" "+jsonObject1.getString("body"); //Remove full stops and commas titleAndBodyContainer = titleAndBodyContainer.replaceAll("\\.(?=\\s|$)", " "); titleAndBodyContainer = titleAndBodyContainer.replaceAll(",", " "); titleAndBodyContainer = titleAndBodyContainer.toLowerCase(); //Create a word list without duplicated words StringBuilder result = new StringBuilder(); HashSet&lt;String&gt; set = new HashSet&lt;String&gt;(); for(String s : titleAndBodyContainer.split(" ")) { if (!set.contains(s)) { result.append(s); result.append(" "); set.add(s); } } //System.out.println(result.toString()); //Re…
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32535415
tagged with: io
has comment: http://stackoverflow.com/comment/32543454
has title: java.lang.OutOfMemoryError: Java heap space error in my code
has comment: http://stackoverflow.com/comment/32537933
has comment: http://stackoverflow.com/comment/32533090
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has comment: http://stackoverflow.com/comment/32537634
type: Question
tagged with: amazon-s3
tagged with: eclipse
has answer: http://stackoverflow.com/a/21544602
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/46226458

http://stackoverflow.com/comment/32657734
score: 0
type: AnswerComment
type: Comment
has text: I would add a note of explanation next to the download link, perhaps even with instructions on how to control-click, etc. Personally, if the website I download it from doesn't raise any red flags, I'd probably be comfortable enough to try it out. My guess is your app won't be the first unsigned your users have encountered.
comment on: http://stackoverflow.com/a/21610561

http://stackoverflow.com/comment/32640467
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21604280
has text: You are right, I didn't read the problem carefully enough. I assume the first snippet can be fixed by casting the single argument to IGrupoSituacoesPermitidas, but it doesn't seem like that should be necessary.
score: 0

http://stackoverflow.com/comment/32614390
comment on: http://stackoverflow.com/a/21588750
type: AnswerComment
type: Comment
score: 0
has text: Worked! Thanks a lot! I had no clue it did that.

azure
tags question: http://stackoverflow.com/q/21625826
tags question: http://stackoverflow.com/q/21558437
type: Tag
tags question: http://stackoverflow.com/q/21606710
tags question: http://stackoverflow.com/q/21648724
tag name: azure

cookies
tags question: http://stackoverflow.com/q/21520508
type: Tag
tags question: http://stackoverflow.com/q/21642268
tags question: http://stackoverflow.com/q/21622596
tag name: cookies
tags question: http://stackoverflow.com/q/21594859

http://stackoverflow.com/a/21539498
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21539409
type: Answer
answers question: http://stackoverflow.com/q/21539409
has body: It can be achieved using hadoop's distributedcache feature. DistributedCache is a facility provided by the Map-Reduce framework to cache files (text, archives, jars etc.) needed by applications.Google it and you can find code example.
score: 0

http://stackoverflow.com/a/21590597
has comment: http://stackoverflow.com/comment/32650860
has body: Most servers require the Host: header, to allow virtual hosting (multiple domains on one IP)
type: AcceptedAnswer
score: 0
has comment: http://stackoverflow.com/comment/32618167
type: Answer
accepted answer of: http://stackoverflow.com/q/21588937
answers question: http://stackoverflow.com/q/21588937

http://stackoverflow.com/comment/32682577
comment on: http://stackoverflow.com/q/21621492
score: 0
has text: I have used the sample that in facebook-android-sdk-3.5
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21580236
has comment: http://stackoverflow.com/comment/32598603
has answer: http://stackoverflow.com/a/21580301
has comment: http://stackoverflow.com/comment/32598492
favorite count: 0
type: UnansweredQuestion
score: -3
tagged with: swing
has title: How to measure time for maze generation?
tagged with: java
downvote count: 3
tagged with: eclipse
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/21580568
upvote count: 0
has body: How can I insert a timer to my code? My goal is to know how long it would take for my maze to generate because I am comparing it to the previous program for my thesis. Thanks for the big help. :) Here is the code that I used: public class Maze extends JPanel { private Room[][] rooms;// m x n matrix of rooms private ArrayList&lt;Wall&gt; walls; // List of walls private Random rand;// for random wall private int height;// height of matrix private int width;// width of matrix private int num;// incrementor private JoinRoom ds;// union paths // paint methods // private int x_cord; // x-axis rep private int y_cord;// y-axis rep private int roomSize; private int randomWall; public Maze(int height, int width) { this.height = height; this.width = width; rooms = new Room[height][width]; walls = new ArrayList&lt;Wall&gt;((height - 1) * (width - 1)); generateRandomMaze(); setPreferredSize(new Dimension(800, 700)); } private void generateRandomMaze() { generateInitialRooms();// see next method ds = new JoinRoom(width * height); rand = new Random(); // here is the random room generator num = width * height; while (num &gt; 1) { // when we pick a random wall we want to avoid the borders getting eliminated randomWall = rand.nextInt(walls.size()); Wall temp = walls.get(randomWall); // we will pick two rooms randomly int roomA = temp.currentRoom.y + temp.currentRoom.x * width; int roomB = temp.nextRoom.y + temp.nextRoom.x * width; // check roomA and roomB to see if they are already members if (ds.find(roomA) != ds.find(roomB)) { walls.remove(randomWall); ds.unionRooms(ds.find(roomA), ds.find(roomB)); temp.isGone = true; temp.currentRoom.adj.add(temp.nextRoom); temp.nextRoom.adj.add(temp.currentRoom); num--; }// end of if }// end of while } // name the room to display private int roomNumber = 0; /** * Sets the grid of rooms to be initially boxes * This is self explanitory, we are only creating an reverse L for all * The rooms and there is an L for the border */ private void generateI…

http://stackoverflow.com/comment/32729232
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/21654544
score: 0
has text: Thanks.. realised this myself after I kept trying to cast C instead of V for some reason.. It's late.. lol. Thanks again.

http://stackoverflow.com/q/21582936
type: Question
answer count: 2
upvote count: 0
has body: I have an error in my program on execution. The error was: --------------------Configuration: &lt;Default&gt;-------------------- Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 6 at java.lang.String.charAt(String.java:687) at codeinstaneous.main(codeinstaneous.java:19) Process completed. Why might this be occurring? This is my code: import javax.swing.*; public class codeinstaneous { public static void main (String[] args) { String theCode; theCode = JOptionPane.showInputDialog("Enter the code to decoded it :"); char theBit; char theSource='a'; int i=0; for(i=0;i &lt;= theCode.length() ;i++){ theBit = theCode.charAt(i); if(theBit=='0') i++; if(theBit=='0') theSource='1'; } JOptionPane.showMessageDialog(null,theSource); } }
tagged with: string-length
favorite count: 0
has comment: http://stackoverflow.com/comment/32603290
accepted answer: http://stackoverflow.com/a/21583045
has comment: http://stackoverflow.com/comment/32603483
has comment: http://stackoverflow.com/comment/32603250
has title: For loop with the length of a string doesn't work
possible better answer: http://stackoverflow.com/a/21583056
has comment: http://stackoverflow.com/comment/32610514
has comment: http://stackoverflow.com/comment/32603235
has answer: http://stackoverflow.com/a/21583056
downvote count: 1
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21583045
tagged with: java
score: -1

http://stackoverflow.com/comment/32603869
comment on: http://stackoverflow.com/q/21583042
score: 2
has text: With Ant you can use the [java task](http://ant.apache.org/manual/Tasks/java.html)
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/32739845
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21660888
has text: Just regular way. Click "green button with white triangle inside" on the top of menu. Like I would run any simple apps in Eclipse
type: AnswerComment

http://stackoverflow.com/a/21569090
type: Answer
downvote count: 0
score: 1
has body: The Graphics2d object contains an AffineTransform and has a call to set it directly to a rotation about given point. When using this, you often (not always) want to save a copy of the transform first and then restore it so the next use of g has the original transform rather than a pre- or post-multiplied version: AffineTransform savedTransform = g.getTransform(); g.rotate(theta, x_center_of_rotation, y_center_of_rotation); g.setTransform(savedTransform);
upvote count: 1
answers question: http://stackoverflow.com/q/21568361

http://stackoverflow.com/comment/32681319
has text: I want to copy to war root everything from `src/main/webapp` including `webapp/files/*.doc`, now it copies everything right, except that `*.doc` file. My problem is in ignoring that `*.doc` file only, I need it.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21607216

http://stackoverflow.com/q/21609076
has comment: http://stackoverflow.com/comment/32649597
type: Question
has comment: http://stackoverflow.com/comment/32649880
has body: For example, I have two classes: class Foo { protected void say() {...}; } class Bar extends Foo {.....} Can I somehow allow the "say" method to be called only from the Bar and other derived classes, but not from the other classes in Foo's package.
tagged with: java
has answer: http://stackoverflow.com/a/21609528
possible better answer: http://stackoverflow.com/a/21609322
tagged with: protected
has answer: http://stackoverflow.com/a/21609322
has title: Access to base class method only from the derived class
has answer: http://stackoverflow.com/a/21609217
answer count: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/32649350
accepted answer: http://stackoverflow.com/a/21609217
tagged with: inheritance
has comment: http://stackoverflow.com/comment/32648684
favorite count: 0
has comment: http://stackoverflow.com/comment/32649404
score: 2
type: AnsweredQuestion
upvote count: 2

http://stackoverflow.com/a/21556490
type: Answer
has body: I guess you are instantiating your Student class with an initial Subject argument "sub"? In this case you are missing to add the "sub" argument to the Vector: public Student(int registrationNumber,String firstName, String familyName, Subject sub) { this.registrationNumber = registrationNumber; this.firstName = firstName; this.familyName = familyName; this.sub = new Vector&lt;Subject&gt;(); this.sub.add(sub); // &lt;-- here } Otherwise the sub argument is discarded...
score: 0
answers question: http://stackoverflow.com/q/21555916

http://stackoverflow.com/comment/32553038
comment on: http://stackoverflow.com/q/21555040
type: Comment
has text: Side-note: If you're using the old Google Collections library, don't, it's not supported anymore. Use the new and shiny [Google Guava](http://code.google.com/p/guava-libraries/) which supersedes the Google Collections (and is actively developed).
type: QuestionComment
score: 1

http://stackoverflow.com/q/21655753
tagged with: java
score: 0
has comment: http://stackoverflow.com/comment/32730915
has body: I need to return several boolean values from one class to another, here's the class that's creating the value : public class Units { public static boolean unit1A; public static void mainPanel(final JFrame mainMenuFrame){ unit1A = true; } } And the class that I want to return the value to public class UnitsTesting{ public static void main(String[] args) { System.out.println(Units.unit1A); } } Unfortunately because of my poor project design i'm keeping the final JFrame in to switch out my frames when needed, so that needs to stay in, otherwise I would know how to do this. Edit : For anyone interested looking at this i'm just going to return an array of booleans, as suggested by Ashis Kumar Sahoo.
tagged with: inheritance
has comment: http://stackoverflow.com/comment/32730944
has comment: http://stackoverflow.com/comment/32730945
has comment: http://stackoverflow.com/comment/32730911
has comment: http://stackoverflow.com/comment/32730973
answer count: 0
type: UnansweredQuestion
tagged with: swing
type: Question
has title: Return multiple values from one class to another

http://stackoverflow.com/comment/32606897
has text: is it throws any ERROR or EXCEPTION ?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21584587

http://stackoverflow.com/comment/32563300
score: 0
comment on: http://stackoverflow.com/q/21560566
type: Comment
type: QuestionComment
has text: are you sure that's the correct value for unique name? Sita, Hari and Krishna are the only Employee names with only one value.

http://stackoverflow.com/q/21515313
favorite count: 0
has body: I'm trying to get metadata about the service beans that are managed by CXF in the current context. Due to WADL auto-generation limitations (I don't want to create a message body reader for each type we add) I don't want to use that. I can manually parse the cxf servlet xml file but would much rather avoid doing so. Is there some way through the API I can get a list of the service beans in the current context? I've tried searching for hours and can't find it. The servlet is using Spring, by the way. Thanks!
has answer: http://stackoverflow.com/a/54204368
type: UnansweredQuestion
tagged with: spring
has title: CXF Servlet API method to list all service beans?
tagged with: cxf
score: 1
tagged with: java
type: Question
answer count: 1
downvote count: 0
upvote count: 1

http://stackoverflow.com/comment/32740620
has text: It gives that input _excatly_ or input _like_ that?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21661492

http://stackoverflow.com/q/21524447
has answer: http://stackoverflow.com/a/21524687
has body: I'm using netbeans and there is a table there. I just want to add data to it using a textfield and a button click. I'm just exploring. Please help.
type: Question
answer count: 2
downvote count: 4
accepted answer: http://stackoverflow.com/a/21525009
possible better answer: http://stackoverflow.com/a/21524687
tagged with: jtable
has comment: http://stackoverflow.com/comment/32499323
has comment: http://stackoverflow.com/comment/32499617
linked to: http://stackoverflow.com/q/10904316
favorite count: 0
has title: How to add a data in JTable?
has comment: http://stackoverflow.com/comment/32499497
has comment: http://stackoverflow.com/comment/32499274
score: -3
has answer: http://stackoverflow.com/a/21525009
has comment: http://stackoverflow.com/comment/32499373
has comment: http://stackoverflow.com/comment/32499510
type: AnsweredQuestion
tagged with: netbeans
has comment: http://stackoverflow.com/comment/32499541
tagged with: java
upvote count: 1

http://stackoverflow.com/q/21578226
has comment: http://stackoverflow.com/comment/32594726
has answer: http://stackoverflow.com/a/21578288
type: AnsweredQuestion
has title: Why does my object not need to call the .toString method?
tagged with: java
possible better answer: http://stackoverflow.com/a/21578291
has answer: http://stackoverflow.com/a/21578291
type: Question
tagged with: object
has comment: http://stackoverflow.com/comment/32594627
accepted answer: http://stackoverflow.com/a/21578288
score: 0
answer count: 3
has body: In my test class at the bottom of my code you can see a bunch of system.out.print's. My question is: why doesn't the stack object need to be written as stack.toString() (It's written system.out.print(stack) instead). Does the print statement dynamically call the toString() method because it is the only string method available in the class....or is it something else gong on? public class Char_Stack { private char [] array = new char[10]; private int top = 0; public int size() { return top; } public boolean isEmpty() { return top == 0; } public void push(char value) throws StackFullException { if (top == array.length) throw new StackFullException("StackFullException"); array[top++] = value; } public double top() throws StackEmptyException { if (top == 0) throw new StackEmptyException("StackEmptyException"); return array[top-1]; } public double pop() throws StackEmptyException { if (top == 0) throw new StackEmptyException("StackEmptyException"); return array[--top]; } public String toString() { String out = "[" + top + " / " + array.length + "]"; for (int i=0;i&lt;array.length; i++) { out += " " + array[i]; } return out; } public static void main(String[] args) throws StackFullException,StackEmptyException { Char_Stack stack = new Char_Stack(); stack.push('Y'); System.out.println(stack); stack.push('P'); System.out.println(stack); stack.push('P'); System.out.println(stack); stack.push('A'); System.out.println(stack); stack.push('H'); System.out.println(stack); stack.pop(); System.out.println(stack); stack.pop(); System.out.println(stack); stack.pop(); System.out.println(stack); stack.pop(); System.out.println(stack); stack.pop(); System.out.println(stack); } }
has answer: http://stackoverflow.com/a/21579346
tagged with: polymorphism
has comment: http://stackoverflow.com/comment/32594813

http://stackoverflow.com/q/21658669
has comment: http://stackoverflow.com/comment/32736196
has body: Hello I have the following code in an Activity: public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); NamazTimesManager nt = NamazTimesManager.getInstance(lm); ... } } and getInstance() is a static method in a normal Java class (same package as the activity): public static NamazTimesManager getInstance(LocationManager lm) { if (instance == null) { instance = new NamazTimesManager(lm); } return instance; } I have debugged everything, but he never gets to the static method. Instead I get some source not found, classloader etc.. exceptions. LocationManager is also initialized correctly....I dont know what to do. Please help! I get the following exceptions: 02-09 11:51:34.463: W/dalvikvm(12270): threadid=1: thread exiting with uncaught exception (group=0x41f9a600) 02-09 11:51:34.533: E/AndroidRuntime(12270): FATAL EXCEPTION: main 02-09 11:51:34.533: E/AndroidRuntime(12270): java.lang.RuntimeException: Unable to start activity ComponentInfo{de.khuddam.namazapp/de.khuddam.namazapp.MainActivity}: java.lang.NullPointerException 02-09 11:51:34.533: E/AndroidRuntime(12270): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332) 02-09 11:51:34.533: E/AndroidRuntime(12270): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2368) 02-09 11:51:34.533: E/AndroidRuntime(12270): at android.app.ActivityThread.access$600(ActivityThread.java:151) 02-09 11:51:34.533: E/AndroidRuntime(12270): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1330) 02-09 11:51:34.533: E/AndroidRuntime(12270): at android.os.Handler.dispatchMessage(Handler.java:99) 02-09 11:51:34.533: E/AndroidRuntime(12270): at android.os.Looper.loop(Looper.java:155) 02-09 11:51:34.533: E/AndroidRuntime(12270): at android.app.ActivityThread.main(ActivityTh…
has comment: http://stackoverflow.com/comment/32735841
downvote count: 0
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32736331
has comment: http://stackoverflow.com/comment/32735692
tagged with: methods
has comment: http://stackoverflow.com/comment/32735932
type: Question
has comment: http://stackoverflow.com/comment/32736260
has comment: http://stackoverflow.com/comment/32735897
has comment: http://stackoverflow.com/comment/32736144
has comment: http://stackoverflow.com/comment/32736190
tagged with: class
has answer: http://stackoverflow.com/a/21662346
upvote count: 1
answer count: 1
has comment: http://stackoverflow.com/comment/32736022
has comment: http://stackoverflow.com/comment/32736236
has comment: http://stackoverflow.com/comment/32736058
favorite count: 0
has comment: http://stackoverflow.com/comment/32736620
tagged with: static
has comment: http://stackoverflow.com/comment/32735821
has title: Android doesnt execute normal Java class
type: UnansweredQuestion
tagged with: android
has comment: http://stackoverflow.com/comment/32736223

http://stackoverflow.com/a/21693041
upvote count: 2
has comment: http://stackoverflow.com/comment/32801399
answers question: http://stackoverflow.com/q/21664730
type: Answer
has body: Congrats on solving it. However to progress and learn, you must understand what went wrong. The error occurred because the program cannot find the cascade classifier. I thought you declared the location of the classifier wrongly, but turns out you didn't have the classifier in the first place. You solved that by downloading a sample classifier and using it. You do not necessarily have to put the classifier in the folder containing the program. You can also put it somewhere else and state the path of where the classifier is located. I would also recommend you to train your own haar-classifier if you are really into object detection. This will help you understand better how cascade classifier works.
has comment: http://stackoverflow.com/comment/32800321
has comment: http://stackoverflow.com/comment/32800304
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/32800272
has comment: http://stackoverflow.com/comment/32799999
has comment: http://stackoverflow.com/comment/32799687

http://stackoverflow.com/comment/32764223
score: 2
has text: yes. Always access static member variables from the class not an instance. Helps avoid issues like this.
type: AnswerComment
comment on: http://stackoverflow.com/a/21675150
type: Comment

http://stackoverflow.com/comment/32762811
type: Comment
comment on: http://stackoverflow.com/a/21628947
type: AnswerComment
has text: Normally it works fine (without CAS). I think CAS filter changes something. Maybe it reuses existed server side session for second login attempt?
score: 0

http://stackoverflow.com/a/21618443
accepted answer of: http://stackoverflow.com/q/21618378
has comment: http://stackoverflow.com/comment/53699057
answers question: http://stackoverflow.com/q/21618378
type: AcceptedAnswer
downvote count: 0
has body: You can try the following, i create 2 more variable iMin &amp; iMax, and before checking num3 is in rank, we define max value and min value: int num1 = -10; int num2 = 100; int num3 = 5; if (num3 &gt; Math.min(num1, num2) &amp;&amp; num3 &lt; Math.max(num1, num2)) { }
type: Answer
has comment: http://stackoverflow.com/comment/32666126
score: 1
upvote count: 1

http://stackoverflow.com/comment/32701714
type: Comment
has text: why `cast(.. as char)`? Why not `varchar`?
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21634703

http://stackoverflow.com/comment/32613008
score: 0
type: AnswerComment
has text: @Hannes Ahh cool, let me know. It's nice to be able to localize stuff.
comment on: http://stackoverflow.com/a/21587425
type: Comment

http://stackoverflow.com/comment/32534336
comment on: http://stackoverflow.com/a/21544135
score: 0
type: AnswerComment
has text: if I am initialing it there its terminating the program on before starting the above activity
type: Comment

http://stackoverflow.com/comment/32666636
has text: I'm not quite sure what you mean by someObject, is it possible to ask for an example of this?
comment on: http://stackoverflow.com/a/21618313
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32703435
type: QuestionComment
comment on: http://stackoverflow.com/q/21639695
has text: This is not a duplicate. Actually I asked this question based on the answer to http://stackoverflow.com/posts/21639695/edit
score: 0
type: Comment

http://stackoverflow.com/comment/32597762
type: AnswerComment
type: Comment
score: 1
comment on: http://stackoverflow.com/a/21567499
has text: @maaartinus: It is `long` but initialized with a value coming from an `int`. The other values are even coming from `short`s. That’s what I already wrote; it’s the *perfect* situation for that optimization as the JVM can prove that the upper bits of the `long` are unused. Maybe that’s the only reason for using `long` for `y` and `m` at this place.

http://stackoverflow.com/comment/32647572
type: QuestionComment
has text: 1) The reason your last question was not answered is because you provide to little information to go off of. Look at [**How to create a Minimal, Complete, Tested and Readable example**](http://stackoverflow.com/help/mcve). 2) Use Java naming convention. Varaibles start with lower case letters.
comment on: http://stackoverflow.com/q/21608328
score: 0
type: Comment

http://stackoverflow.com/a/21524183
downvote count: 0
upvote count: 2
type: AcceptedAnswer
has body: There's no difference in the way it is executed. Just in the first case you access a static field through a JFrame instance (frame). In the second case you access it by the class name itself (JFrame).
type: Answer
accepted answer of: http://stackoverflow.com/q/21524128
answers question: http://stackoverflow.com/q/21524128
score: 2

http://stackoverflow.com/comment/32626086
has text: `<xs:simpleType name="swiftType"> <xs:restriction base="xs:string"> <xs:pattern value="[A-Z0-9]{0}|[A-Z0-9]{8}" /> <xs:whiteSpace value="collapse" /> </xs:restriction> </xs:simpleType>` This error is not based on `swiftType` because I deleted this row from xml and after this I get the same error for `name` element.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21595419
type: Comment

containskey
tag name: containskey
tags question: http://stackoverflow.com/q/21600344
type: Tag

http://stackoverflow.com/a/21670584
upvote count: 3
score: 3
has body: There is absolutely no need to call the super. It just helps you to call the logic contained within super class method if you require that. Many times you want the exact logic to run and then provide your additional logic. Overriding always does not mean providing brand new logic. Sometimes you want to provide a slight variation. For e.g., if the method returns a value, then you call the super class method and get the value. Then you make some slight modification in that object using logic in the sub class method and return it back to caller.
downvote count: 0
answers question: http://stackoverflow.com/q/21670525
type: Answer

http://stackoverflow.com/q/21567468
tagged with: java
tagged with: int
has answer: http://stackoverflow.com/a/21567526
tagged with: arrays
downvote count: 0
score: 1
favorite count: 0
has body: I am new to Programming so bear with me if I do not properly present my issue. I have an assignment to create a program to assign integer values 1-25 to a 25 element integer array. I need to print the array as five separate lines with each line containing 5 elements separated by commas. The last element does not have a comma following it. The final output should be as follows: 1,2,3,4,5 6,7,8,9,10 11,12,13,14,15 16,17,18,19,20 21,22,23,24,25 The code that I came up with comes close, but it's not quite right. The code that I came up with is: public class Test2 { /** * @param args * the command line arguments */ public static void main(String[] args) { int[] numbers = new int[25]; for (int i = 0; i &lt; numbers.length; i++) { numbers[i] = i + 1; System.out.print(numbers[i] + ","); if (i % 5 == 0 &amp;&amp; i &gt; 0) System.out.println(); } } } The printout that I get from my code is as follows: 1,2,3,4,5,6, 7,8,9,10,11, 12,13,14,15,16, 17,18,19,20,21, 22,23,24,25, I am not sure why I am getting 1-6 on the first line as well as how to remove the comma at the end of each line. Any help pointing out my errors would be appreciated.
accepted answer: http://stackoverflow.com/a/21567744
has answer: http://stackoverflow.com/a/21567715
has title: Trying to properly print an array in Java
possible better answer: http://stackoverflow.com/a/21567520
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21567520
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/21567744

http://stackoverflow.com/a/21672988
downvote count: 0
has body: Both map1 and map2 contain the same list. They both contain the reference to the same list. So, if the list is modified the change will be reflected in both the maps. map1 --------------&gt;t1&lt;----------------map2 If you want them to have separate copies of the list create a new list. map1 --------------&gt;t1 map2 --------------&gt;t1` //where t1` is a new copy of t1
type: Answer
upvote count: 4
answers question: http://stackoverflow.com/q/21672909
score: 4

http://stackoverflow.com/comment/32773282
has text: Hi. Thanks for taking the time to answer! Unfortunately it didn't work. I tried to use @PostConstruct (I've edited my post), however the postConstruct() method is never executed.
type: AnswerComment
comment on: http://stackoverflow.com/a/21678404
score: 0
type: Comment

http://stackoverflow.com/comment/32581560
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21570026
has text: @ADi It returns the current time in milliseconds.This method returns the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC(coordinated universal time).
score: 0

http://stackoverflow.com/q/21677315
accepted answer: http://stackoverflow.com/a/21678454
favorite count: 0
has title: Assert inequality for float in junit
has comment: http://stackoverflow.com/comment/32769923
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21677429
has answer: http://stackoverflow.com/a/21677429
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/21678454
has body: I´v just migrated to a newer version of JUnit where Assert.assertNotEquals has been removed so now i´m struggling to rewrite a test. Original code: Double givenLongitude = new Double(13); assertNotEquals(givenLongitude, extract("position.longitude", eventDataJson, Float.class), 0.01d); Where the extract method is a generic method that returns Float in this case. My problem is that I would like to use Assert.assertFalse like this Double givenLongitude = new Double(13); assertFalse(givenLongitude.equals(extract("position.longitude", eventDataJson, Float.class)), 0.01d); But since the assertFalse doesnt have a delta value i´m not sure how to accomplish this without losing the delta value in the comparison? Any suggestions?
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32768096
answer count: 2
has comment: http://stackoverflow.com/comment/32768610
tagged with: junit
downvote count: 0

http://stackoverflow.com/comment/32695067
has text: That did the trick. Guess I need to take a look at those lookbehinds and aheads :)
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/21634828
score: 0

http://stackoverflow.com/comment/32677408
type: AnswerComment
score: 0
type: Comment
has text: Yes, and then summing them up.
comment on: http://stackoverflow.com/a/21625505

http://stackoverflow.com/comment/32617025
score: 0
type: Comment
has text: In the current form, this question will be closed on SO. Please provide details about what problems occurred when you tried to incorporate Tdil's POS tagger with Java.
type: QuestionComment
comment on: http://stackoverflow.com/q/21515277

git
tags question: http://stackoverflow.com/q/21672635
tags question: http://stackoverflow.com/q/21530450
tag name: git
tags question: http://stackoverflow.com/q/21674284
type: Tag
tags question: http://stackoverflow.com/q/21519780
tags question: http://stackoverflow.com/q/21676677
tags question: http://stackoverflow.com/q/21587804
tags question: http://stackoverflow.com/q/21632947

string
tags question: http://stackoverflow.com/q/21571279
tags question: http://stackoverflow.com/q/21646212
tags question: http://stackoverflow.com/q/21572614
tags question: http://stackoverflow.com/q/21654601
tags question: http://stackoverflow.com/q/21638784
tags question: http://stackoverflow.com/q/21612593
tags question: http://stackoverflow.com/q/21662444
tags question: http://stackoverflow.com/q/21528931
tags question: http://stackoverflow.com/q/21583987
tags question: http://stackoverflow.com/q/21574735
tags question: http://stackoverflow.com/q/21669092
tags question: http://stackoverflow.com/q/21583832
tags question: http://stackoverflow.com/q/21645155
tags question: http://stackoverflow.com/q/21592109
tags question: http://stackoverflow.com/q/21612503
tags question: http://stackoverflow.com/q/21594842
tags question: http://stackoverflow.com/q/21630732
tags question: http://stackoverflow.com/q/21539734
tags question: http://stackoverflow.com/q/21662774
tags question: http://stackoverflow.com/q/21641152
tags question: http://stackoverflow.com/q/21583706
tags question: http://stackoverflow.com/q/21651547
tags question: http://stackoverflow.com/q/21656835
tags question: http://stackoverflow.com/q/21676143
tags question: http://stackoverflow.com/q/21641800
tags question: http://stackoverflow.com/q/21574730
tags question: http://stackoverflow.com/q/21639577
tags question: http://stackoverflow.com/q/21611976
tags question: http://stackoverflow.com/q/21605904
tags question: http://stackoverflow.com/q/21669459
tags question: http://stackoverflow.com/q/21641572
tags question: http://stackoverflow.com/q/21614621
tags question: http://stackoverflow.com/q/21570278
tags question: http://stackoverflow.com/q/21617469
tags question: http://stackoverflow.com/q/21536621
tags question: http://stackoverflow.com/q/21641180
tags question: http://stackoverflow.com/q/21615767
tags question: http://stackoverflow.com/q/21593170
tags question: http://stackoverflow.com/q/21677710
tags question: http://stackoverflow.com/q/21589971
tags question: http://stackoverflow.com/q/21652919
tag name: string
tags question: http://stackoverflow.com/q/21531089
tags question: http://stackoverflow.com/q/21602434
tags question: http://stackoverflow.com/q/21635681
tags question: http://stackoverflow.com/q/21545933
tags question: http://stackoverflow.com/q/21650925
tags question: http://stackoverflow.com/q/21535737
tags question: http://stackoverflow.com/q/21621067
tags question: http://stackoverflow.com/q/21572202
tags question: http://stackoverflow.com/q/21551267
tags question: http://stackoverflow.com/q/21530642
tags question: http://stackoverflow.com/q/21602130
tags question: http://stackoverflow.com/q/21636205
tags question: http://stackoverflow.com/q/21521520
tags question: http://stackoverflow.com/q/21669743
type: Tag
tags question: http://stackoverflow.com/q/21644970
tags question: http://stackoverflow.com/q/21548741
tags question: http://stackoverflow.com/q/21621958
tags question: http://stackoverflow.com/q/21632924
tags question: http://stackoverflow.com/q/21638634
tags question: http://stackoverflow.com/q/21590272
tags question: http://stackoverflow.com/q/21610104
tags question: http://stackoverflow.com/q/21578266
tags question: http://stackoverflow.com/q/21596566
tags question: http://stackoverflow.com/q/21517025
tags question: http://stackoverflow.com/q/21638316
tags question: http://stackoverflow.com/q/21522762
tags question: http://stackoverflow.com/q/21657602
tags question: http://stackoverflow.com/q/21642170
tags question: http://stackoverflow.com/q/21519702
tags question: http://stackoverflow.com/q/21587848
tags question: http://stackoverflow.com/q/21576584
tags question: http://stackoverflow.com/q/21629232
tags question: http://stackoverflow.com/q/21585941
tags question: http://stackoverflow.com/q/21671280
tags question: http://stackoverflow.com/q/21660394
tags question: http://stackoverflow.com/q/21575452
tags question: http://stackoverflow.com/q/21542079

http://stackoverflow.com/q/21642143
has comment: http://stackoverflow.com/comment/32707405
answer count: 3
has answer: http://stackoverflow.com/a/21642175
type: UnansweredQuestion
has title: NullPointerException in if statement
has comment: http://stackoverflow.com/comment/32707302
has comment: http://stackoverflow.com/comment/32707429
tagged with: if-statement
score: 0
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21642174
has comment: http://stackoverflow.com/comment/32707315
has body: I'm trying to compare the slot inside the table with the variable f to see if there is a repeat or if the slot is empty. It complies but ends up giving me a NullPointerException. Here is my code, issues are marked with //this one import java.awt.*; import java.util.*; import javax.swing.*; import javax.swing.table.*; public class Journal extends JPanel { public Journal() { String colN1 = "Date"; String colN2 = "Student"; int a = 20; int b = 5; int c = a*2/b; int col = c*2; String[] columnNames = new String[col]; for(int colF = 0; colF &lt; col; colF++) { if(colF%2 == 0) { columnNames[colF] = colN1; } else { columnNames[colF] = colN2; } } int row = b; int d = 1; Object[][] data = new Object[row][col]; for (int row1 = 0; row1 &lt; data.length; row1++) { for (int col1 = 0; col1&lt;data[0].length; col1++) { if(col1%2 != 0) { data[row1][col1]= "day" + d; d++; } else { Integer f = new Integer(1); int col2 = 0; int row3 = 0; boolean rows; for (int row2 = 0; row2 &lt; data.length; row2++) { if(data[row2][col2].equals(null))//this one { rows = true; } else if(data[row2][col2].equals(f))//this one { rows = false; } else { rows = true; } col2++; if(col2 &gt;= col) { col2 = 0; } for (int col3 = 0; col3&lt;data[0].length; col3++) { if(f &gt; a) { f = 1; } else if(rows == true &amp;&amp; data[row3][col3].equals(f))//this oen { data[row3][col3]= f; } f++; row3++; if(row3 &gt;= row) { row3 = 0; } } } } } } JTable table = new JTable(data, columnNames) { public Class getColumnClass(int column) { for (int row4 = 0; row4 &lt; getRowCount(); row4++) { Object o = getValueAt(row4, column); if (o != null) return o.getClass(); } return Object.class; } }; table.setPreferredScrollableViewportSize(table.getPreferredSize()); JScrollPane scrollPane = new JScrollPane(table); add(scrollPane); } private static void gui() { JFrame gui = new JFrame(); gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); gui.setTitle("Journal List"); gui.setSize(700,200); gui.setLocationRelativeTo(null); gui.setVisible…
has comment: http://stackoverflow.com/comment/32707312
has answer: http://stackoverflow.com/a/21642202

http://stackoverflow.com/comment/32483668
type: AnswerComment
has text: none of the 2 suggestions I've given require the said constructor
comment on: http://stackoverflow.com/a/21515233
score: 0
type: Comment

http://stackoverflow.com/q/21613098
has comment: http://stackoverflow.com/comment/32656109
has answer: http://stackoverflow.com/a/21614028
has comment: http://stackoverflow.com/comment/32656951
has title: Java local vs instance variable access speed
linked to: http://stackoverflow.com/q/21567248
upvote count: 21
has comment: http://stackoverflow.com/comment/32656369
has answer: http://stackoverflow.com/a/21613759
has comment: http://stackoverflow.com/comment/32656206
linked to: http://stackoverflow.com/q/504103
has comment: http://stackoverflow.com/comment/105473753
has comment: http://stackoverflow.com/comment/32658001
has comment: http://stackoverflow.com/comment/32657752
has comment: http://stackoverflow.com/comment/32657644
has comment: http://stackoverflow.com/comment/32656144
has answer: http://stackoverflow.com/a/21614413
accepted answer: http://stackoverflow.com/a/21614413
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32656271
has comment: http://stackoverflow.com/comment/32657060
tagged with: performance
has comment: http://stackoverflow.com/comment/32658738
tagged with: java
linked to: http://stackoverflow.com/q/4761681
has answer: http://stackoverflow.com/a/47658714
has comment: http://stackoverflow.com/comment/32657136
has answer: http://stackoverflow.com/a/21613479
tagged with: optimization
type: Question
score: 20
has answer: http://stackoverflow.com/a/21613519
possible better answer: http://stackoverflow.com/a/21614028
downvote count: 1
answer count: 7
has body: So my question is about variable accessing speed in Java. Today in my "CS" (if you can call it that) the teacher presented a similar example to the following of a List: public class ListExample&lt;T&gt; { private Node&lt;T&gt; head; private Node&lt;T&gt; tail; private class Node&lt;T&gt; { /* ... */ } public void append(T content) { if (!isEmpty()) { Node&lt;T&gt; dummy = new Node&lt;T&gt;(content); head = dummy; tail = dummy; head.setNext(head); // or this dummy.setNext(dummy); } else { /* ... */ } } // more methods // ... } My question is: Would the call to head.setNext(head) be slower than dummy.setNext(dummy) ? Even if it's not noticeable. I was wondering this since head is obviously and instance var of the class and dummy is local, so would the local access be faster?
has comment: http://stackoverflow.com/comment/32656113
has answer: http://stackoverflow.com/a/21613307
tagged with: variables
favorite count: 0

http://stackoverflow.com/comment/32713318
comment on: http://stackoverflow.com/a/21556858
score: 0
type: AnswerComment
type: Comment
has text: I am able to solve this using tomcat7:run which forced maven to download right version of tomcat. Thx Paul.

http://stackoverflow.com/comment/32631720
has text: The problem is that B is used in different package of my lib. Can ProGaurd can be a help for this problem or is there an easier way ?
comment on: http://stackoverflow.com/q/21578791
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32559761
score: 0
type: AnswerComment
type: Comment
has text: That's very strange. ModelDriven should push it for you :|
comment on: http://stackoverflow.com/a/21557605

http://stackoverflow.com/q/21668268
answer count: 1
favorite count: 0
has title: Using polymorphism to display output of a arraylist
has comment: http://stackoverflow.com/comment/32753014
has comment: http://stackoverflow.com/comment/32772654
type: AnsweredQuestion
has body: I need to display the first and last names of all contact entered when user selected Display contacts from the menu. I also need to display all details of the contacts when the user inputs the Contact ID entered into the ArrayList. All I can get to display is the last contact entered. Am I not keeping the ArrayList once I go through once then go back to the menu and enter another contact? Or am I just not calling the print function right still to print all contacts in the arraylist. If I enter 3 now it just goes back to the first line of the array and wants me to enter a contact ID, and goes through creating a contact again, not displaying what is already there. package ooo1; import java.util.ArrayList; import java.util.Scanner; public class ContactList { public static void main(String[] args) { Scanner input1 = new Scanner(System.in); int type = 0; while(type != 4){ System.out.println("Please select an option:"); System.out.println("Personal Contact: Enter 1"); System.out.println("Business Contact: Enter 2"); System.out.println("Display Contacts List: Enter 3"); System.out.println("4 to quit"); type = input1.nextInt(); if(type == 4){ System.out.println("Goodbye"); break; } ArrayList&lt;Contact&gt; contacts = new ArrayList&lt;Contact&gt;(); Scanner input = new Scanner(System.in); System.out.println("Please enter ContactId : "); String contactId = input.nextLine(); System.out.println("Please enter First Name : "); String firstName = input.nextLine(); System.out.println("Please enter Last Name : "); String lastName = input.nextLine(); System.out.println("Please enter Address : "); String address = input.nextLine(); System.out.println("Please enter Phone Number : "); String phoneNumber = input.nextLine(); System.out.println("Please enter Email Address : "); String emailAddress = input.nextLine(); if(type == 1){ System.out.println("Please enter Birthday: "); String dateofBirth = input.nextLine(); Contact pcontact = new PersonalContact(contactId, firstName, lastName, add…
tagged with: oop
tagged with: java
downvote count: 3
type: Question
has answer: http://stackoverflow.com/a/21682593
score: -3
accepted answer: http://stackoverflow.com/a/21682593
tagged with: arraylist
upvote count: 0

http://stackoverflow.com/q/21632560
type: AnsweredQuestion
tagged with: java
tagged with: http://stackoverflow.com/tag/json
tagged with: gson
type: Question
has title: JSON to GSON Objects
score: 0
answer count: 1
has body: I am new to GSON and thus far have been successfully using it in my project. This JSON has been problematic for me... { "status": "6000", "action": "getProducts", "categories": { "type1": [ { "name": "name1", "subtitle": "subtitle1" }, { "name": "name2", "subtitle": "subtitle2" } ], "type2": [ { "name": "name3", "subtitle": "name3" } ] } } What's throwing me off is that I don't want to have to know the names "type1", "type2", etc. They will be used to dynamically populate a list view. What should my GSON objects looks like? or should my JSON be refactored? I have full control over the backend.
tagged with: android
has answer: http://stackoverflow.com/a/21632668
accepted answer: http://stackoverflow.com/a/21632668

cucumber-jvm
tag name: cucumber-jvm
tags question: http://stackoverflow.com/q/21573141
type: Tag
tags question: http://stackoverflow.com/q/21515382

graphics
tag name: graphics
tags question: http://stackoverflow.com/q/21609676
tags question: http://stackoverflow.com/q/21668016
tags question: http://stackoverflow.com/q/21651837
tags question: http://stackoverflow.com/q/21615203
type: Tag
tags question: http://stackoverflow.com/q/21652527
tags question: http://stackoverflow.com/q/21612733
tags question: http://stackoverflow.com/q/21566269
tags question: http://stackoverflow.com/q/21519250
tags question: http://stackoverflow.com/q/21533083
tags question: http://stackoverflow.com/q/21587812
tags question: http://stackoverflow.com/q/21652914
tags question: http://stackoverflow.com/q/21584703
tags question: http://stackoverflow.com/q/21651537
tags question: http://stackoverflow.com/q/21653372
tags question: http://stackoverflow.com/q/21611679
tags question: http://stackoverflow.com/q/21666404
tags question: http://stackoverflow.com/q/21641260

http://stackoverflow.com/comment/32491679
type: AnswerComment
has text: I apologise, but I'm still not getting it - I'm bombarded with errors when I try to use `(E[]) new Object[size*2]`. I know there's something really obvious I must be missing here but I can't figure out what it is.
type: Comment
comment on: http://stackoverflow.com/a/21519768
score: 0

http://stackoverflow.com/a/21563658
answers question: http://stackoverflow.com/q/21562958
score: 0
type: Answer
has body: A List is ordered, but its members are not guaranteed to be unique. So if you want the unique set of members from both collections you need to use a Set to filter them out. import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; public class TestRetainAll { public static void main(String[] args) { List&lt;Double&gt; list1 = new ArrayList&lt;&gt;(); list1.addAll(Arrays.asList(new Double[] {2.4, 5.6, 9.0, 3.1, 5.6})); List&lt;Double&gt; list2 = Arrays.asList(new Double[] {9.0, 3.1, 5.6, 5.6}); list1.retainAll(list2); System.out.println("List (which may contain duplicates)"); for (Double d : list1) { System.out.println(d); } Set&lt;Double&gt; set = new HashSet&lt;&gt;(); set.addAll(list1); System.out.println("Set (which cannot contain duplicates)"); for (Double d : set) { System.out.println(d); } } } Produces this output: List (which may contain duplicates) 5.6 9.0 3.1 5.6 Set (which cannot contain duplicates) 5.6 3.1 9.0

input
tags question: http://stackoverflow.com/q/21540761
tags question: http://stackoverflow.com/q/21663472
tags question: http://stackoverflow.com/q/21640759
tags question: http://stackoverflow.com/q/21597600
tags question: http://stackoverflow.com/q/21593084
tags question: http://stackoverflow.com/q/21656142
tags question: http://stackoverflow.com/q/21566221
tags question: http://stackoverflow.com/q/21633912
tags question: http://stackoverflow.com/q/21671003
tag name: input
tags question: http://stackoverflow.com/q/21640493
tags question: http://stackoverflow.com/q/21541403
type: Tag
tags question: http://stackoverflow.com/q/21590991

http://stackoverflow.com/comment/32581403
comment on: http://stackoverflow.com/a/21569843
score: 0
type: AnswerComment
type: Comment
has text: Oh, forgot about that. Sorry, new to Stack Overflow. Email me on kris91268@gmail.com, and we can also continue our conversation there (this reply thread is getting a bit long)

http://stackoverflow.com/a/21582250
has comment: http://stackoverflow.com/comment/32609322
type: Answer
answers question: http://stackoverflow.com/q/21581253
has body: Seems like a classpath issue. Try to locate the jar containing oracle.jdbc.OracleDriver class in the runtime. You can use the following statement: println oracle.jdbc.OracleDriver.class.protectionDomain.codeSource.location.path It will show the path to the jar used to load the Oracle driver. This will probably be different to your required jar. You can get the whole classpath from a system property: System.getProperty("java.class.path")
score: 2
upvote count: 2
accepted answer of: http://stackoverflow.com/q/21581253
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/21621859
type: Answer
answers question: http://stackoverflow.com/q/21621803
has body: Please read the documentation of ConcurrentHashMap.putIfAbsent: Returns: the previous value associated with the specified key, or null if there was no mapping for the key As there was no previous value for the key "key 3", it returns null.
downvote count: 0
score: 3
upvote count: 3

http://stackoverflow.com/a/21556681
score: 1
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/21556415
has body: You can have an additional initializeUser(User user) method, which fills all fields. createUser creates a new User and calls initializeUser with it. createEmployer creates a new Employer and calls initializeEmployer which calls initializeUser and then adds its Employer stuff. To make it invisible to the outside user, declare both initalize methods protected so they're only visible inside the package. Another design would be to have an own factory class which holds all create and initialize methods.
downvote count: 0

http://stackoverflow.com/comment/32670428
type: QuestionComment
has text: I wonder if you need to specify a "remote" connect instead. Take a look at this post: http://varraa.wordpress.com/2011/09/21/my-first-example-of-orientdb/ , otherwise, do you know for sure that path is correct?
comment on: http://stackoverflow.com/q/21620622
score: 0
type: Comment

http://stackoverflow.com/comment/32618691
type: QuestionComment
comment on: http://stackoverflow.com/q/21591005
type: Comment
has text: Spring, Guava and commons-lang all have a `StopWatch` class. That may be useful.
score: 0

http://stackoverflow.com/q/21547757
possible better answer: http://stackoverflow.com/a/21547879
tagged with: android
has comment: http://stackoverflow.com/comment/32540283
favorite count: 0
accepted answer: http://stackoverflow.com/a/21547984
has comment: http://stackoverflow.com/comment/32540406
has body: Getting error as "The type new DialogInterface.OnClickListener(){} must implement the inherited abstract method DialogInterface.OnClickListener.onClick(DialogInterface, int)" package com.example.detectinternetconnection; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.Intent; import android.content.DialogInterface; import android.view.View.OnClickListener; import android.content.DialogInterface.OnClickListener; import android.os.Bundle; import android.view.View; import android.widget.Button; public class AndroidDetect extends Activity { // flag for Internet connection status Boolean isInternetPresent = false; // Connection detector class ConnectionDetector cd; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btnStatus = (Button) findViewById(R.id.btn_check); // creating connection detector class instance cd = new ConnectionDetector(getApplicationContext()); /** * Check Internet status button click event * */ btnStatus.setOnClickListener(new View.OnClickListener() { @SuppressWarnings("deprecation") @Override public void onClick(View v) { // get Internet status isInternetPresent = cd.isConnectingToInternet(); // check for Internet status if (isInternetPresent) { // Internet Connection is Present // make HTTP requests AlertDialog.Builder builder = new AlertDialog.Builder(AndroidDetectInternet.this); builder.setMessage("You have network connection.") .setTitle("Internet Connection") .setCancelable(false); AlertDialog alert = builder.create(); alert.setButton("Continue", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which){ // Do call some activity. Do what you wish to; startActivity(new Intent(AndroidDetectInternet.this,MainActivity2.class)); } }); alert.show(); } else { // Internet connection is not present // Ask user to connect to Internet AlertDialog.Builder builde…
type: AnsweredQuestion
score: -5
has answer: http://stackoverflow.com/a/21547879
tagged with: java
has answer: http://stackoverflow.com/a/21547984
has title: Android - Error says The type new DialogInterface.OnClickListener(){} must implement the inherited
type: Question
answer count: 2
upvote count: 0
downvote count: 5

http://stackoverflow.com/a/21609399
downvote count: 0
type: Answer
has body: You can test this by adding some more fields. public class TestCls { public static int test = getInt(); public static int moreJunk = initializeMoreJunk(); static{ System.out.println("Static initializer: test=" + test + ", moreJunk=" + moreJunk); } public static int getInt(){ System.out.println("giveInt func: " + test); System.out.println("moreJunk=" + moreJunk); return 10; } public static int initializeMoreJunk() { return -1; } public static void main(String... args){ System.out.println("Main: " + test); } } with output of: giveInt func: 0 moreJunk=0 Static initializer: test=10, moreJunk=-1 Main: 10 This shows that class variables get initialized to their default values first (primitive ints default to 0), then initialization blocks and methods get called, proceeding from the top of the class downward.
upvote count: 1
accepted answer of: http://stackoverflow.com/q/21609182
score: 1
answers question: http://stackoverflow.com/q/21609182
type: AcceptedAnswer

http://stackoverflow.com/comment/32521613
has text: @user3267256 wht width and height u give ?
type: QuestionComment
comment on: http://stackoverflow.com/q/21536350
type: Comment
score: 0

http://stackoverflow.com/q/21675829
score: 0
answer count: 3
has title: How to give a label position in Java?
accepted answer: http://stackoverflow.com/a/21675937
tagged with: jlabel
has answer: http://stackoverflow.com/a/21676023
type: AnsweredQuestion
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21675937
possible better answer: http://stackoverflow.com/a/21676011
has answer: http://stackoverflow.com/a/21676011
has body: I'm trying to give the label's a position but label1.setLocation(27, 20) doesn't work: label = new JLabel( "Voer dag in" ); label1 = new JLabel( "Voer dag in" ); I want them under eachother The whole code: http://pastebin.com/Gqtcqc9g Thanks
has comment: http://stackoverflow.com/comment/32765324

http://stackoverflow.com/q/21575156
has comment: http://stackoverflow.com/comment/32589880
has title: Catching String exceptions
type: AnsweredQuestion
tagged with: netbeans
has body: I'm making a jTextField restrict integer input in netbeans and I don't know what to do. I'm doing it like this: private void txtNameKeyReleased(java.awt.event.KeyEvent evt) { try { String j = (String) txtName.getText(); } catch ("Which Exception to Catch?") { if (!txtAge.getText().isEmpty()) { jOptionPane1.showMessageDialog(null, "Please enter string values"); txtAge.setText(txtAge.getText().replaceAll("[^a-z]", "")); } } } What should I put on the catch?
has comment: http://stackoverflow.com/comment/32589446
tagged with: java
possible better answer: http://stackoverflow.com/a/21575879
type: Question
accepted answer: http://stackoverflow.com/a/21575258
score: 0
answer count: 2
upvote count: 1
downvote count: 1
has answer: http://stackoverflow.com/a/21575879
has answer: http://stackoverflow.com/a/21575258
favorite count: 0
has comment: http://stackoverflow.com/comment/32589337
has comment: http://stackoverflow.com/comment/32590041

http://stackoverflow.com/comment/32665096
comment on: http://stackoverflow.com/q/21617828
score: 0
type: Comment
type: QuestionComment
has text: Remember that you can call your own methods from changeAddress().

http://stackoverflow.com/comment/32674318
comment on: http://stackoverflow.com/q/21623706
score: 0
type: Comment
type: QuestionComment
has text: Checkout this article: http://javarevisited.blogspot.com/2011/07/why-multiple-inheritances-are-not.html

http://stackoverflow.com/a/21529200
has comment: http://stackoverflow.com/comment/32507779
type: Answer
upvote count: 1
has body: StringBuffer guarantees that only one thread can enter append or any other method of the same instance. But this is all, there are no more guarantees.
score: 1
answers question: http://stackoverflow.com/q/21528968
has comment: http://stackoverflow.com/comment/32507689
downvote count: 0

http://stackoverflow.com/comment/32701418
comment on: http://stackoverflow.com/q/21638634
type: QuestionComment
has text: No. One is a literal value, and one is an object.
type: Comment
score: 0

http://stackoverflow.com/a/21677222
score: 1
upvote count: 1
has body: When I changed this.reportingModel.add(entry.getKey(), new MapPropertyConduit(entry.getKey(), Boolean.class)).dataType(Boolean.class.getName()); to this.reportingModel.add(entry.getKey(), new MapPropertyConduit(entry.getKey(), Boolean.class)).dataType("boolean"); it suddenly worked. Does anyone have a complete list of available data types?
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/32770868
answers question: http://stackoverflow.com/q/21675856

http://stackoverflow.com/q/21592430
answer count: 1
tagged with: modifiers
linked to: http://stackoverflow.com/q/1520887
has comment: http://stackoverflow.com/comment/32620926
has body: So I have this really weird problem that I simply cannot understand why it doesn't work. I am building a strobe light as part of my app and have created a separate Strobelight class. When I call the turnOn method or update method, the intervals never are changed. I guess it would make it easier to explain using some code: public class Strobelight{ private int delayOn, delayOff; public void turnStrobeOn(){...} public void update(int a_delayOn, int a_delayOff){ delayOn = a_delayOn; delayOff = a_delayOff; } public void turnOn(int a_delayOn, int a_delayOff){ delayOn = a_delayOn; delayOff = a_delayOff; this.turnStrobeOn(); } Depending on whether the strobe light is already on or not, one of these methods are called to change turn on the strobe light with the specified intervals or simply to change the intervals. Instead of changing the intervals to something custom, the application just uses the smallest possible intervals when calling Thread.sleep() for the flashlight being on or off EDIT: this is the thread code, and code that turns the flashlight on public void turnStrobeOn(){ for ( int i = 0; i &lt; 3; i++){ isInCycle = true; cam = Camera.open(); Parameters p = cam.getParameters(); p.setFlashMode(Parameters.FLASH_MODE_TORCH); cam.setParameters(p); cam.startPreview(); // the flashlight is now on lightIsOn = true; new Thread(new Runnable() { public void run() { try { Thread.sleep(delayOn); } catch (InterruptedException e) { e.printStackTrace(); } } }).start(); cam.stopPreview(); cam.release(); lightIsOn = false; new Thread(new Runnable() { public void run() { try { Thread.sleep(delayOff); } catch (InterruptedException e) { e.printStackTrace(); } } }).start(); } //end of for loop isInCycle = false; } // end of turnStrobeOn
tagged with: android
has answer: http://stackoverflow.com/a/21592804
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21592804
tagged with: java
type: Question
has title: How to update values while method is running - Java
tagged with: camera
tagged with: variables
has comment: http://stackoverflow.com/comment/32620638
score: 0

http://stackoverflow.com/comment/32671635
type: QuestionComment
has text: I have to keep a file because it is upto a user to chose only one, two or all the three as initial source. Then at any moment of time he can add on the sources. Also I am doing a data manipulation at a certain point of time each day from the original source (The file). The issue is that should I chose a file or a DB as the initial source? Also doing calculations in memory is not possible, it has to go hand in hand as in for each row in file three rows in three DB tables.
score: 0
type: Comment
comment on: http://stackoverflow.com/q/21621955

http://stackoverflow.com/a/21517697
downvote count: 0
answers question: http://stackoverflow.com/q/21517595
type: Answer
score: 4
has body: Yes, take a look at the MessageDigest class of Java: http://docs.oracle.com/javase/7/docs/api/java/security/MessageDigest.html It provides 3 hashing algorithms: -MD5 -SHA-1 -SHA-256 Example for hashing a file: MessageDigest md = MessageDigest.getInstance("SHA-256"); FileInputStream fis = new FileInputStream("~/Documents/Path/To/File.txt"); byte[] dataBytes = new byte[1024]; int nread = 0; while ((nread = fis.read(dataBytes)) != -1) { md.update(dataBytes, 0, nread); }; byte[] mdbytes = md.digest(); //Convert "mdbytes" to hex String: StringBuffer hexString = new StringBuffer(); for (int i=0;i&lt;mdbytes.length;i++) { hexString.append(Integer.toHexString(0xFF &amp; mdbytes[i])); } return hexString.toString(); Here is the example for hashing a String: String password = "123456"; MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update(password.getBytes()); byte byteData[] = md.digest(); //Convert "byteData" to hex String: StringBuffer sb = new StringBuffer(); for (int i = 0; i &lt; byteData.length; i++) { sb.append(Integer.toString((byteData[i] &amp; 0xff) + 0x100, 16).substring(1)); } return sb.toString();
upvote count: 4

http://stackoverflow.com/comment/32566862
type: QuestionComment
comment on: http://stackoverflow.com/q/21562432
has text: well, these things they don't teach us in college... I just wanted to be sure thats all.
score: 0
type: Comment

http://stackoverflow.com/a/21640662
upvote count: 1
score: 0
downvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/21640494
has body: 2D arrays are just an array of arrays. So to find out how many rows there are we would do arrayName.length and then to find out how many items are in each column we would have to go to the first row (array) and find out that length by arrayName[0].length. so as you can see the code you are using finds out how many rows there are twice. It should look something like this: double rowsize = 0.0; double columnsize= 0.0; rowsize = array.length; System.out.println("Print out the rowsize: " +rowsize); if(rowsize &gt;= 1){ columnsize = array[0].length; } System.out.println("Print out the columnsize: " +columnsize); I hope this has solved your issue :)

http://stackoverflow.com/comment/54955914
score: 3
type: Comment
has text: What is supposed to be `d1` and `d2`?
type: AnswerComment
comment on: http://stackoverflow.com/a/21668003

http://stackoverflow.com/comment/32681397
score: 0
type: QuestionComment
type: Comment
has text: I really expected something like this. Whenever you ask question - someone say something that doesn't solve your issue. I need an array of TextViews to set onClickListeners for some of them. Does that answer your question? Now I need an answer to mine.
comment on: http://stackoverflow.com/q/21625910

http://stackoverflow.com/comment/116413919
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21571894
has text: @hichamabdedaime there is one of the best explanation for such problem https://stackoverflow.com/a/46195656/5108737

http://stackoverflow.com/comment/32678584
comment on: http://stackoverflow.com/q/21625994
has text: is the name of your database atrics or test ? You might want to look at your database name again in the connection url.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32624398
has text: Huh? He asked for a URL. Thus my answer is a URL.
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21594284

http://stackoverflow.com/comment/32665682
score: 0
type: Comment
comment on: http://stackoverflow.com/q/21618009
type: QuestionComment
has text: How do I set it right then?

http://stackoverflow.com/comment/32680675
comment on: http://stackoverflow.com/a/21627399
score: 0
type: AnswerComment
type: Comment
has text: Is it really that simple? Cause I've been thinking about that being the solution seeing the assignment tells me to have a field NAMED tutor, and an object of TYPE Instructor. But when I put them up beside eachother like that, it just seemed like nonsense. It must've been the fact that they both sound like regular names that confused me..

http://stackoverflow.com/q/21647211
type: AnsweredQuestion
duplicate of: http://stackoverflow.com/q/4561587
has comment: http://stackoverflow.com/comment/32715701
has comment: http://stackoverflow.com/comment/32733186
tagged with: java
has comment: http://stackoverflow.com/comment/32719147
accepted answer: http://stackoverflow.com/a/21647251
has comment: http://stackoverflow.com/comment/32737069
type: Question
has comment: http://stackoverflow.com/comment/32715695
has answer: http://stackoverflow.com/a/21647268
tagged with: arrays
has answer: http://stackoverflow.com/a/21647251
has comment: http://stackoverflow.com/comment/32715720
score: -1
tagged with: sorting
answer count: 3
has body: I learned two ways of sorting an array: Bubble sorting: import java.io.*; class bubbles { int ctr; int ctr1; int a[]= new int[5]; int pos; int temp; int max; public void method () throws IOException { int max=0; BufferedReader obj= new BufferedReader (new InputStreamReader (System.in)); System.out.println ("Enter five numbers"); for (ctr=0; ctr&lt;5; ctr++) { a[ctr]= Integer.parseInt (obj.readLine ()); } for (ctr=0; ctr&lt;5; ctr++) { for (ctr1=1; ctr1&lt;4; ctr1++) { if (a[ctr1]&gt;a[ctr1+1]) { temp=a[ctr1]; a[ctr1]=a[ctr1+1]; a[ctr1+1]=temp; } } } for (ctr=0; ctr&lt;5; ctr++) { System.out.print (a[ctr1] +" "); } } } And selection sorting: import java.io.*; class selectionprocess { int ctr; int ctr1; int a[]= new int[5]; int pos; int temp; int max; public void method () throws IOException { int max=0; BufferedReader obj= new BufferedReader (new InputStreamReader (System.in)); System.out.println ("Enter five numbers"); for (ctr=0; ctr&lt;5; ctr++) { a[ctr]= Integer.parseInt (obj.readLine ()); } for (ctr=0; ctr&lt;5; ctr++) { max=a[ctr]; pos=ctr; for (ctr1=ctr+1; ctr1&lt;5; ctr1++) { if (a[ctr1]&gt;max) { max=a[ctr1]; pos=ctr1; } } temp=a[pos]; a[pos]=a[ctr]; a[ctr]=temp; } for (ctr=0; ctr&lt;5; ctr++) { System.out.print (a[ctr] +" "); } } } Logically speaking, what is the difference between these two methods? What are their uses and which one is faster and more efficient?
upvote count: 1
favorite count: 0
possible better answer: http://stackoverflow.com/a/21647268
has answer: http://stackoverflow.com/a/21647460
downvote count: 2
has title: Difference between array sorting

http://stackoverflow.com/a/23235009
accepted answer of: http://stackoverflow.com/q/21670510
answers question: http://stackoverflow.com/q/21670510
has comment: http://stackoverflow.com/comment/39091862
has comment: http://stackoverflow.com/comment/35931689
type: AcceptedAnswer
downvote count: 0
has body: Google App Engine has added support for EAR module development since SDK 1.8.2. You will have to create a new 'Enterprise Application Project' under Java EE in Eclipse and set Google App Engine as your target run time. You can find more information at: https://developers.google.com/appengine/docs/java/webtoolsplatform#enterprise_application_ear I hope this helps!
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/a/21662982
has body: You need to provide an implementation of ANTLRErrorListener to gather information about the errors that occur. For example, the IntelliJ plugin uses its SyntaxErrorListener to track this information. You can check Parser.getNumberOfSyntaxErrors() after the parse is complete to see if an error occurred. Note that this doesn't report errors from the lexer. The best way to make sure all errors are reported properly is to write your lexer in such a way that it can never encounter a syntax error itself, but instead passes invalid tokens on to the parser for handling.
type: AcceptedAnswer
downvote count: 0
score: 22
type: Answer
accepted answer of: http://stackoverflow.com/q/21661899
answers question: http://stackoverflow.com/q/21661899
upvote count: 22

http://stackoverflow.com/a/21628774
answers question: http://stackoverflow.com/q/21628652
score: 0
type: Answer
has body: public static ArrayList&lt;String&gt; getValuesOfSession(Context c) { SharedPreferences sPrefs=PreferenceManager.getDefaultSharedPreferences(c); ArrayList&lt;String&gt; myAList=new ArrayList&lt;String&gt;(); int size=sPrefs.getInt("size",0); for(int j=0;j&lt;size;j++) { // Log.i("MYlIST ADD",""+); myAList.add(sPrefs.getString("val"+j,"")); } return myAList; }

http://stackoverflow.com/comment/32531470
type: Comment
type: QuestionComment
has text: do you mean toArray() from Collections? Java has no built in getArray() method. There is one in JDBC but I don't think that is what you are looking for.
comment on: http://stackoverflow.com/q/21542080
score: 0

http://stackoverflow.com/a/21565847
has body: You can use a BitmapShader for this: // Define a method to generate a bitmap shader from a drawable resource private static Shader getDrawableShader(Context ctx, int resId) { Bitmap bmp = BitmapFactory.decodeResource(ctx.getResources(), resId); return new BitmapShader(bmp, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); } // Outside of onDraw(), preferably on a background thread if possible Shader shader = getDrawableShader(getContext(), R.drawable.my_image); // In onDraw() paint.setShader(shader); canvas.drawArc(rectF, 0, 360, true, paint);
answers question: http://stackoverflow.com/q/21564295
type: Answer
score: 1
upvote count: 1
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21564295

http://stackoverflow.com/comment/32554806
comment on: http://stackoverflow.com/q/21555615
score: 0
has text: possible duplicate of [Running a .exe file using Java](http://stackoverflow.com/questions/8612921/running-a-exe-file-using-java)
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32585318
has text: I even tried with empty `web.xml` and `@ApplicationPath("/rest")` but when deploying I get `No Servlet mappings found for JAX-RS application: com.technology.apiinterface.restful.service.JaxRsActivator either annotate it with @ApplicationPath or add a servlet-mapping in web.xml`
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21568983

http://stackoverflow.com/q/21572261
tagged with: java
has answer: http://stackoverflow.com/a/21794578
tagged with: mapreduce
type: Question
upvote count: 4
tagged with: hadoop
has comment: http://stackoverflow.com/comment/32625567
has comment: http://stackoverflow.com/comment/32907190
has body: I am really having a hard time struggling with running Hbase-MapReduce with Hadoop. I do use Hadoop Hortonwork 2 version. HBase version that I use is 0.96.1-hadoop2. Now when I try to run my MapReduce like this : hadoop jar target/invoice-aggregation-0.1.jar start="2014-02-01 01:00:00" end="2014-02-19 01:00:00" firstAccountId=0 lastAccountId=10 Hadoop tells me that is can not find the invoice-aggregation-0.1.jar in its file system ?! I am wondering why does it need to be there ? Here is the error I get 14/02/05 10:31:48 ERROR security.UserGroupInformation: PriviledgedActionException as:adio (auth:SIMPLE) cause:java.io.FileNotFoundException: File does not exist: hdfs://localhost:8020/home/adio/workspace/projects/invoice-aggregation/target/invoice-aggregation-0.1.jar java.io.FileNotFoundException: File does not exist: hdfs://localhost:8020/home/adio/workspace/projects/invoice-aggregation/target/invoice-aggregation-0.1.jar at org.apache.hadoop.hdfs.DistributedFileSystem$17.doCall(DistributedFileSystem.java:1110) at org.apache.hadoop.hdfs.DistributedFileSystem$17.doCall(DistributedFileSystem.java:1102) at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81) at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:1102) at org.apache.hadoop.mapreduce.filecache.ClientDistributedCacheManager.getFileStatus(ClientDistributedCacheManager.java:288) at org.apache.hadoop.mapreduce.filecache.ClientDistributedCacheManager.getFileStatus(ClientDistributedCacheManager.java:224) at org.apache.hadoop.mapreduce.filecache.ClientDistributedCacheManager.determineTimestamps(ClientDistributedCacheManager.java:93) at org.apache.hadoop.mapreduce.filecache.ClientDistributedCacheManager.determineTimestampsAndCacheVisibilities(ClientDistributedCacheManager.java:57) at org.apache.hadoop.mapreduce.JobSubmitter.copyAndConfigureFiles(JobSubmitter.java:264) at org.apache.hadoop.mapreduce.JobSubmitter.copyAndConfigureFiles(JobSubmitter.java…
downvote count: 0
has comment: http://stackoverflow.com/comment/32905735
has comment: http://stackoverflow.com/comment/32868484
has comment: http://stackoverflow.com/comment/32628650
has title: Error while trying to run HBase map reduce
answer count: 4
favorite count: 0
has comment: http://stackoverflow.com/comment/32612450
tagged with: hbase
has answer: http://stackoverflow.com/a/21784448
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32912600
has comment: http://stackoverflow.com/comment/32597556
has comment: http://stackoverflow.com/comment/32897893
score: 4
has answer: http://stackoverflow.com/a/21798521
has answer: http://stackoverflow.com/a/38141943
has comment: http://stackoverflow.com/comment/32896393

http://stackoverflow.com/comment/32696324
type: QuestionComment
type: Comment
has text: Now it makes sense. If both processes run on the same CPU and there's no free core, this could be bad. Or not. Measuring it surely helps. Giving the long running thread a lower priority could help too (so that users not needing it could be served faster). And maybe you could optimize your query... or what you store in the DB or whatever... *a long running query needed to process every order doesn't sound good*. But then we'd need the details.
score: 0
comment on: http://stackoverflow.com/q/21634411

http://stackoverflow.com/comment/32743664
has text: What Eclipse version do you use?
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21625572

http://stackoverflow.com/comment/32700207
has text: Try adding command line arguments when invoking the jar, you can then parse the arguments within the running JAR.
type: QuestionComment
type: Comment
score: 2
comment on: http://stackoverflow.com/q/21637917

http://stackoverflow.com/comment/32572671
has text: Got it now, thank you a lot. This will help me, thanks!
type: Comment
comment on: http://stackoverflow.com/a/21565398
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32649230
has text: you want implement to remove the first occurrence of the char in given string ?
score: 0
type: Comment
comment on: http://stackoverflow.com/q/21609212
type: QuestionComment

http://stackoverflow.com/a/21630218
upvote count: 1
accepted answer of: http://stackoverflow.com/q/21624299
answers question: http://stackoverflow.com/q/21624299
type: AcceptedAnswer
downvote count: 0
score: 1
type: Answer
has body: Based upon the logs seems that a bean with the id 'customUserDetailsService' is not defined. Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'customUserDetailsService' I see that your config you posted does have a bean named customUserDetailsService so I would check a few things. First ensure the configuration you posted matches your actual configuration. The configuration has the security configuration and the UserDetailsService in a single file. Is this actually how you have it configured? Are you using Global Method Security? If so, this has been known to trigger bugs with eager instantiation of beans relating to authentication. To figure it out, I will need to see this configuration as well. Randomly, try moving the customUserDetailsService bean before the rest of your security configuration. This really should not matter, but is more of an experiment.

http://stackoverflow.com/comment/32676377
comment on: http://stackoverflow.com/q/21620753
score: 0
type: QuestionComment
type: Comment
has text: It might be best if you describe what you have tried and where it goes wrong. Currently your question is a bit vague.

http://stackoverflow.com/comment/32570140
has text: If you change the reference held in `criteria` within the function, it won't change the reference the variable outside of the function held.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21564278
score: 0

http://stackoverflow.com/a/21866321
has body: If you need the performance, I would suggest to de-normalize your tables and create 4 entities with following attributes (columns): Country: id, name State: id, countryId, name County: id, countryId, stateId, name City: id, countryId, stateId, countyId, name (mapping is obvious) Then you will be able to build a simple SQL queries. If you need performance, prefer named queries as they are compiled at initialization time. E.g. select all cities by country: "SELECT id, name FROM city WHERE country_id=?" You may even not declare a references between entities using @ManyToOne, but just declare a simple @Columns. API call will, most likely, accept IDs (countryId, stateId), so you'll be better to pass that IDs as parameters to DAO. Most likely, you have a locations tables filled in once by sql script and the data should not be modified. Create foreign keys to guarantee data integrity. And do you really need a tree-like structure in memory? If so, create it by hand, it is not very complex.
type: Answer
answers question: http://stackoverflow.com/q/21675947
score: 1
upvote count: 1
downvote count: 0

http://stackoverflow.com/comment/32680169
score: 0
type: Comment
type: QuestionComment
has text: So there it is: The initial data sources are ready, the only thing my Async Task does is to fetch from a file, then add the records to the DB. The code reflects the DB operation minus the functions it uses to calculate values to be added.
comment on: http://stackoverflow.com/q/21621955

http://stackoverflow.com/q/21657034
type: Question
upvote count: 4
answer count: 2
downvote count: 0
accepted answer: http://stackoverflow.com/a/21741037
score: 4
has title: JavaFX KeyEvent propagation order
has answer: http://stackoverflow.com/a/21736845
tagged with: javafx-8
has comment: http://stackoverflow.com/comment/32877819
possible better answer: http://stackoverflow.com/a/21736845
favorite count: 0
has body: I want to listen to some KeyEvent in my scene, say KeyCode.ESCAPE(close the scene when pressed). scene.addEventHandler(KeyEvent.ANY, event -&gt; { if (event.isConsumed()) return; switch (event.getCode()) { case ESCAPE: stage.hide(); event.consume(); break; default: break; } }); Now, the nodes inside the scene could have listened to ESCAPE too. // .... someOtherNode.addEventHandler(KeyEvent.ANY, e -&gt; { if (e.getCode() == KeyCode.ESCAPE) { // do stuff e.consume(); } }); // .... How do I make sure that the KeyEvent will be consumed from the node and not the scene? Based on the diagram from Oracle, A workaround would be adding a dummy Node at the end of the Node hierarchy that listens to KeyCodes But is there a better solution, like inverting the propagation route? EDIT: The use case: A popup-like node that blocks other nodes would need to listens to the ESC key or focusProperty() so that it can close itself.
has answer: http://stackoverflow.com/a/21741037
tagged with: javafx-2
type: AnsweredQuestion
tagged with: java
tagged with: javafx

http://stackoverflow.com/comment/32604613
type: Comment
has text: @dnc253 Yes, the default constructor will always be added by the compiler, if you don't provide any constructor.
comment on: http://stackoverflow.com/a/21583458
score: 0
type: AnswerComment

http://stackoverflow.com/q/21540080
tagged with: jdbc
downvote count: 0
favorite count: 0
upvote count: 1
has title: Programatically configure two realms for glassfish auth
type: AnsweredQuestion
has body: For a current application, the customer has given us the following requirements: Use of Glassfish 4 Application Server JEE7 PrimeFaces Allowing for Authorization against both LDAP and JDBC database, which can be switched between after the application has been deployed I am wondering if anyone has any ideas about how I could accomplish this as I have only worked with glassfish using the predefined realms, never having to create one. The flow of this is that after the application has been deployed, the admins can choose whether the users accessing the site authenticate against an LDAP or a local JDBC Database. This decision should not effect the flow of the front end, meaning that there should only be one login page, that goes to one function, that would then, based on the configuration, determine which realm to use to authenticate against. Any help would be greatly appreciated.
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/21541042
type: Question
tagged with: jsf-2
has answer: http://stackoverflow.com/a/21541042
tagged with: glassfish
tagged with: ldap
answer count: 1

http://stackoverflow.com/a/29470089
upvote count: 32
answers question: http://stackoverflow.com/q/21535023
type: Answer
has body: One other easy way of doing it would be as follows (if you have a simple NetBeans project and not using maven for example). In Eclipse, Go to File -> New -> Java Project Give a name for your project and click finish to create your project When the project is created find the source folder in NetBeans project, drag and drop all the source files from the NetBeans project to 'src' folder of your new created project in eclipse. Move the java source files to respective package (if required) Now you should be able to run your NetBeans project in Eclipse.
score: 31
has comment: http://stackoverflow.com/comment/48400203
downvote count: 1
has comment: http://stackoverflow.com/comment/113403882
has comment: http://stackoverflow.com/comment/59705905

http://stackoverflow.com/q/21677703
has comment: http://stackoverflow.com/comment/32789287
type: Question
tagged with: aspectj
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/32774817
has comment: http://stackoverflow.com/comment/32774659
has comment: http://stackoverflow.com/comment/32802755
has title: Hibernate: permission checking on changing entity's fields
type: UnansweredQuestion
has body: I've got something like that Hibernate entity: @Entity @Table(name = "my_ent") public class MyEntity { private field String one; private field String two; private field String three; // and so on... } I've got a few user roles, each of them have different rights on MyEntity. For example admin has rights to modify the one and two fields, custom_user has rights to modify three and two fields and so on. Problem: I should check in my request handler if user modified only fields he has rights to modify. And I don't know the right way to do that. I suppose two possible escapes: Two write AspectJ annotations on each field, which enumerate the roles which have rights to modify the field. But it seems very ugly and complex (because I'll overhelm my code with AspectJ annotations). To get the entity's modified fields list. It seems very attractive but how could I achieved that? For example, can I write some interceptor which put all modified entity's fileds names to the list. Question: How can I write Hibernate entity permissions checking on changing entity fileds?
upvote count: 1
answer count: 0
score: 1
tagged with: java
tagged with: hibernate

http://stackoverflow.com/comment/32633853
type: QuestionComment
score: 19
has text: By not writing `al.add(null)`.
comment on: http://stackoverflow.com/q/21600559
type: Comment

http://stackoverflow.com/a/21627581
score: 2
accepted answer of: http://stackoverflow.com/q/21627544
has body: You could just do String sub = s.substring(s.indexOf("ora_pmon_") + 9);
upvote count: 2
answers question: http://stackoverflow.com/q/21627544
type: AcceptedAnswer
downvote count: 0
type: Answer

http://stackoverflow.com/a/21674261
type: AcceptedAnswer
type: Answer
answers question: http://stackoverflow.com/q/21673658
has body: Your onSaveInstanceState method should be this: @Override public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); savedInstanceState.putInt(CREATE_KEY, mCreate); savedInstanceState.putInt(RESTART_KEY, mRestart); savedInstanceState.putInt(START_KEY, mStart); savedInstanceState.putInt(RESUME_KEY, mResume); }
accepted answer of: http://stackoverflow.com/q/21673658
score: 0

http://stackoverflow.com/q/21664760
score: 0
answer count: 2
has body: I'm trying to make it so when I press down the right key a new picture pops up making it look like my character is walking, not quite sure how to do that though... Here's my code: import java.awt.*; public class Dude { int x, dx, y; Image still; public Dude() { ImageIcon i = new ImageIcon("Ken3.png"); ImageIcon ii = new ImageIcon("KenTurn1.png"); still = i.getImage(); x = 50; y = 785; } public void move() { x = x + dx; } public int getX() { return x; } public int getY() { return y; } public Image getImage() { return still; } public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_A) dx = -2; if (key == KeyEvent.VK_D) dx = 2; if (key == KeyEvent.VK_SPACE) dx = 5; } public void keyReleased(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_A) dx = 0; if (key == KeyEvent.VK_D) dx = 0; Any help would be awesome thanks!
has title: Failing to try to change an image when keypressed
tagged with: animation
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21740093
has comment: http://stackoverflow.com/comment/32747051
has answer: http://stackoverflow.com/a/21665066
tagged with: keyevent
tagged with: java
has comment: http://stackoverflow.com/comment/32747151
type: Question

http://stackoverflow.com/comment/32752252
comment on: http://stackoverflow.com/q/21667418
type: Comment
has text: Like on Facebook wall. If I click on publish date bottom the post, Facebook redirect me to page with only this post: https://www.facebook.com/9gag/posts/205093383022280
score: 0
type: QuestionComment

http://stackoverflow.com/q/21647562
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/21647603
upvote count: 1
has comment: http://stackoverflow.com/comment/32716343
type: Question
has comment: http://stackoverflow.com/comment/32716309
tagged with: inheritance
has title: Inheritance issue that i cannot understand
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/32716324
has answer: http://stackoverflow.com/a/21647603
favorite count: 0
has comment: http://stackoverflow.com/comment/32716363
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32716326
has body: I have this 2 classes: public class A { protected int _x; public A() { _x = 1; } public A(int x) { _x = x; } public void f(int x) { _x += x; } public String toString() { return "" + _x; } } public class B extends A { public B() { super(3); } public B(int x) { super.f(x); f(x); } public void f(int x) { _x -= x; super.f(x); } public static void main(String[] args) { A[] arr = new A[3]; arr[0] = new B(); arr[1] = new A(); arr[2] = new B(5); for (int i = 0; i &lt; arr.length; i++) { arr[i].f(2); System.out.print(arr[i] + " "); } } } The output is 3 3 6 and I am wonder why the third iteration is 6

http://stackoverflow.com/q/21523192
has answer: http://stackoverflow.com/a/21523239
has comment: http://stackoverflow.com/comment/32497769
type: AnsweredQuestion
tagged with: android-layout
has body: I am simply using LayoutInflater to get A View(Button) From a layout.xml file other then the activity_main.xml. but When I change the setText("") property of the button the button property does not updates. I am checking if I can change the text property of the button element in the testlayout.xml But when I set the property of the Button in onCreate and when I check for that property in call that was not changed... MainActivity.java public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); LayoutInflater inflater = (LayoutInflater)this.getSystemService (Context.LAYOUT_INFLATER_SERVICE); LinearLayout linearLayout = (LinearLayout) inflater.inflate(R.layout.testlayout, null); Button btn = (Button)linearLayout.findViewById(R.id.testbtn); btn.setText("Hello"); } public void call(View v){ Button btn = (Button)findViewById(R.id.testBtn); Toast.makeText(this, btn.getText(), Toast.LENGTH_SHORT).show(); } Activity_main.xml <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> testlayout.xml <?xml version="1.0" encoding="utf-8"?>
tagged with: java
has comment: http://stackoverflow.com/comment/32497670
type: Question
has comment: http://stackoverflow.com/comment/32497728
possible better answer: http://stackoverflow.com/a/21523239
accepted answer: http://stackoverflow.com/a/21523246
score: 0
answer count: 3
has comment: http://stackoverflow.com/comment/32496957
has comment: http://stackoverflow.com/comment/32497622
tagged with: android
has answer: http://stackoverflow.com/a/21523268
has answer: http://stackoverflow.com/a/21523246
tagged with: http://stackoverflow.com/tag/xml
has title: LayoutInflater not Updating the View Property

http://stackoverflow.com/a/21565767
has comment: http://stackoverflow.com/comment/32573188
type: Answer
has comment: http://stackoverflow.com/comment/32573260
has comment: http://stackoverflow.com/comment/32573222
upvote count: 3
has comment: http://stackoverflow.com/comment/32573358
answers question: http://stackoverflow.com/q/21565750
score: 3
has body: You are looking for the import keyword. For example: import java.util.ArrayList;
downvote count: 0

http://stackoverflow.com/a/21534589
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/34724862
type: Answer
accepted answer of: http://stackoverflow.com/q/21534224
score: 3
answers question: http://stackoverflow.com/q/21534224
has body: I believe you're supposed to use MultiValueMap.multiValueMap( new TreeMap&lt;String, Collection&lt;Pair&lt;Integer, String&gt;&gt;&gt;()); ...not referring to ArrayList, since presumably the library wants the freedom to choose which collection implementation it puts in the map. (That said: if you were to use Guava's Multimap instead, you could get this in the much simpler line MultimapBuilder.treeKeys().arrayListValues().build() and get the generics automatically inferred.)
upvote count: 3

http://stackoverflow.com/a/21568581
upvote count: 2
score: 2
accepted answer of: http://stackoverflow.com/q/21567181
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21567181
type: Answer
has body: By default, you will not be able to access it unless you add the --host parameter while starting up the dev server. So go ahead and add --host=0.0.0.0 while starting up the Dev Server. As per the documentation, you need to add --address=0.0.0.0 while starting up (https://developers.google.com/appengine/docs/java/tools/devserver#Command_Line_Arguments) but folks are reporting that starting from SDK 1.8.7, you need to replace --address with --host

http://stackoverflow.com/a/31196643
type: Answer
has body: You are correct about being able to spoof a MAC address. There are no machineId's you can't spoof one way or another, which is why machine specific identification is generally a bad idea. It is an even worse idea with Java since the whole point of Java is to be abstracted from the hardware. Which really only leaves you with the JVM and network stack to get details from. So the only two options I can see. First you could try generating a hash of some combination of the hostname, current classpath(s), system properties, and JVM values. Along that line you might see what values you are getting from System.getenv() or System.getProperties() The Second way would be to use native runtime API to return system specific values, but you would need to have specific commands to run for each OS type your client is trying to support. Example: Runtime.getRuntime().exec("some_command_line_prog_that_returns_sys_info");
answers question: http://stackoverflow.com/q/21608819
score: 0

http://stackoverflow.com/comment/32611789
comment on: http://stackoverflow.com/q/21587105
score: 0
type: Comment
type: QuestionComment
has text: @Simon People usually complain when there is only a fragment of code provided with an error like this. Which is why I provided my entire code on pastebin.

http://stackoverflow.com/comment/32754472
type: QuestionComment
comment on: http://stackoverflow.com/q/21667586
score: 0
has text: @PM77-1 If you were to answer it, I'd be able to choose yours as an accepted answer. I don't know how to do it otherwise
type: Comment

http://stackoverflow.com/comment/72614545
score: 0
comment on: http://stackoverflow.com/a/32489582
type: AnswerComment
has text: Wow, I forgot the dash. top cake.
type: Comment

http://stackoverflow.com/comment/38737147
has text: Muhammad let connect. We will do a teamviewer and see whats the probelm. Let me know if its ok for u
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21649085
type: Comment

http://stackoverflow.com/a/21635217
has comment: http://stackoverflow.com/comment/32695293
score: 0
answers question: http://stackoverflow.com/q/21634703
type: Answer
has comment: http://stackoverflow.com/comment/32694998
has comment: http://stackoverflow.com/comment/32695249
has body: what about this ? group_concat('CREATED_TIME:', CREATED_TIME) demo or use this by giving number of characters group_concat('CREATED_TIME:',cast(CREATED_TIME as char(255)) demo

http://stackoverflow.com/a/21582314
upvote count: 1
has comment: http://stackoverflow.com/comment/32602766
has comment: http://stackoverflow.com/comment/32602278
has comment: http://stackoverflow.com/comment/32602513
has comment: http://stackoverflow.com/comment/32602377
answers question: http://stackoverflow.com/q/21581898
has comment: http://stackoverflow.com/comment/32602588
downvote count: 0
score: 1
type: Answer
has comment: http://stackoverflow.com/comment/32602743
has comment: http://stackoverflow.com/comment/32602911
has body: In detail the JVM does simply add "magic code" to the final bytecode assembly during runtime that includes bounds checking as specified in the form of: if (i &lt; 0 || i &gt;= length) throw new ArrayIndexOutOfBoundsException(); This of course has to be done for each access and will with a simple implementation slow down array access a lot. However there are many attempts to circumvent that with more sophisticated ideas like this or this. Google can help you to find more. Some JVMs might already use more sophisticated methods, while others do simply add the check as above to every instruction that accesses an array index during the runtime execution/compilation of code.

http://stackoverflow.com/a/21601837
has body: Its the same short form as in += n |= toogle is the same as n = n | toogle the | is here the binary-or operator and ^ is the binary xor-operator
score: 4
type: Answer
upvote count: 4
answers question: http://stackoverflow.com/q/21601808
downvote count: 0

http://stackoverflow.com/comment/32600962
type: Comment
type: QuestionComment
score: 2
has text: Ahp!! There it is! Aw dammit. Gone again.
comment on: http://stackoverflow.com/q/21581369

http://stackoverflow.com/a/21609454
has body: There is no way to do what you are describing using @Value, but you can do this, which is the same thing pretty much: package com.acme.example; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @Component public class Example { private @Autowired Environment environment; public String getFlowerColor(String runTimeFlower) { return environment.resolvePlaceholders("${" + runTimeFlower + "}"); } }
upvote count: 24
has comment: http://stackoverflow.com/comment/32683495
type: Answer
score: 24
answers question: http://stackoverflow.com/q/21609271
downvote count: 0

http://stackoverflow.com/q/21586409
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
type: Question
tagged with: spring-junit
answer count: 2
has body: I want to get notified when a test fails. Ideally, I want to know if the test is passed or failed in my @After annotated method. I understand that their is a RunListener which can be used for this purpose but it works only if we run the test with JunitCore. Is there a way to get notified if a test case fails or something similar to RunListener which can be used with SpringJUnit4ClassRunner?
has title: How to use RunNotifier or RunListener using SpringJUnit4ClassRunner
has answer: http://stackoverflow.com/a/21614436
accepted answer: http://stackoverflow.com/a/21614436
upvote count: 1
tagged with: junit
has answer: http://stackoverflow.com/a/42476259
favorite count: 0
possible better answer: http://stackoverflow.com/a/42476259
tagged with: spring
tagged with: spring-test

http://stackoverflow.com/comment/32710027
type: Comment
type: QuestionComment
has text: The source page is now unreachable (probably caused by the SO traffic ;)). Anyway, my first guess would be that some of the filenames have upper-case file extensions, so changing the if statement to check for valid source files to: if (imgSrc != null && (imgSrc.toLowerCase().endsWith(".jpg") || (imgSrc.toLowerCase().endsWith(".png")) || etc... would fix that.
score: 0
comment on: http://stackoverflow.com/q/21643704

serialization
tags question: http://stackoverflow.com/q/21667712
tags question: http://stackoverflow.com/q/21540850
tags question: http://stackoverflow.com/q/21559750
tags question: http://stackoverflow.com/q/21555569
tag name: serialization
tags question: http://stackoverflow.com/q/21615957
tags question: http://stackoverflow.com/q/21552692
tags question: http://stackoverflow.com/q/21592731
tags question: http://stackoverflow.com/q/21651128
tags question: http://stackoverflow.com/q/21538405
tags question: http://stackoverflow.com/q/21672219
type: Tag
tags question: http://stackoverflow.com/q/21519955
tags question: http://stackoverflow.com/q/21535165
tags question: http://stackoverflow.com/q/21523050
tags question: http://stackoverflow.com/q/21553797
tags question: http://stackoverflow.com/q/21672245

http://stackoverflow.com/comment/32597859
type: QuestionComment
comment on: http://stackoverflow.com/q/21579944
has text: what the type of `c` and `base` array ??
score: 0
type: Comment

http://stackoverflow.com/comment/32549705
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21548506
has text: http://stackoverflow.com/questions/998737/integrating-tomcat-and-eclipse-as-a-hot-deploy-environment/6189031#6189031

http://stackoverflow.com/comment/32559336
has text: @user3052882 can you show us the content of your file
type: Comment
score: 0
comment on: http://stackoverflow.com/q/21558092
type: QuestionComment

http://stackoverflow.com/q/21567327
answer count: 1
downvote count: 0
has answer: http://stackoverflow.com/a/21567334
accepted answer: http://stackoverflow.com/a/21567334
favorite count: 0
tagged with: constructor
has comment: http://stackoverflow.com/comment/32576094
type: AnsweredQuestion
has body: The answer to this question explains the cause for the ambiguous constructor problem, but if I actually want to construct a third-party object which contains such constructors, and I want to pass the argument to be null, can I construct the object anyways by somehow telling java which constructor I mean? In particular, in this example: public Example(String name) { this.name = name; } public Example(SomeOther other) { this.other = other; } Suppose I want to actually construct a new Example(null) using the first constructor. Is there some syntax that will allow me to do this?
has comment: http://stackoverflow.com/comment/32576066
score: 7
tagged with: java
has comment: http://stackoverflow.com/comment/32576115
type: Question
has comment: http://stackoverflow.com/comment/32576078
has comment: http://stackoverflow.com/comment/32576172
has title: Is there a way to explicitly specify a constructor in Java?
has comment: http://stackoverflow.com/comment/32576051
has comment: http://stackoverflow.com/comment/32576105
linked to: http://stackoverflow.com/q/5636320
upvote count: 7

http://stackoverflow.com/comment/32515786
type: Comment
type: QuestionComment
has text: Distance between your two Point objects? It's just coordinates x,y - start points and x, y - end points
comment on: http://stackoverflow.com/q/21533310
score: 0

http://stackoverflow.com/q/21521149
tagged with: java
has comment: http://stackoverflow.com/comment/32493615
accepted answer: http://stackoverflow.com/a/21521244
has body: I read that "Every object in Java allocated in heap." I also came to know that "Every program, object is inherited by Object class" I am not sure of the class name though. So if our program that includes main method is also inherited by object class in Java Virtual Machine, does it mean that it is also an object? Is main method also allocated in heap? If it is then does it mean everything in Java is allocated in heap?
has comment: http://stackoverflow.com/comment/32494250
possible better answer: http://stackoverflow.com/a/21521294
tagged with: program-entry-point
downvote count: 0
tagged with: jvm
favorite count: 0
has comment: http://stackoverflow.com/comment/32493648
has title: Is main method also allocated in heap?
has answer: http://stackoverflow.com/a/21521244
answer count: 4
tagged with: memory-management
has answer: http://stackoverflow.com/a/21523291
upvote count: 3
has comment: http://stackoverflow.com/comment/32493628
has answer: http://stackoverflow.com/a/21548570
type: Question
type: AnsweredQuestion
score: 3
has comment: http://stackoverflow.com/comment/32493678
has comment: http://stackoverflow.com/comment/32493944
has answer: http://stackoverflow.com/a/21521294

http://stackoverflow.com/a/21582903
has body: Looks like Spring Batch would be a good one to consider. I would recommend it. You can schedule the jobs with spring integrated quartz scheduler. A job will be split into multiple steps (and parallelism can also be achieved). Jobs could be re-started and best of all everything is right there that you have minimal work. Most of the stuff goes in wiring it properly. I provided a bean configuration as example. &lt;bean id="threadPoolExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"&gt; &lt;property name="corePoolSize" value="20" /&gt; &lt;property name="maxPoolSize" value="25" /&gt; &lt;property name="queueCapacity" value="500" /&gt; &lt;/bean&gt; &lt;bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher"&gt; &lt;property name="jobRepository" ref="jobRepository" /&gt; &lt;property name="taskExecutor" ref="asyncTaskExecutor" /&gt; &lt;/bean&gt; &lt;batch:job id="batchjob" job-repository="jobRepository"&gt; &lt;batch:step id="step1" next="step2"&gt; &lt;batch:tasklet ref="start" /&gt; &lt;/batch:step&gt; &lt;batch:step id="step2" next="step3.master"&gt; &lt;batch:tasklet ref="fetchData" /&gt; &lt;/batch:step&gt; &lt;batch:step id="step3.master"&gt; &lt;batch:partition step="step3.slave" partitioner="processingPartitioner"&gt; &lt;batch:handler grid-size="20" task-executor="threadPoolExecutor" /&gt; &lt;/batch:partition&gt; &lt;/batch:step&gt; &lt;batch:listeners&gt; &lt;batch:listener ref="MyListener" /&gt; &lt;/batch:listeners&gt; &lt;/batch:job&gt; &lt;batch:step id="step3.slave"&gt; &lt;batch:tasklet ref="processFile" /&gt; &lt;/batch:step&gt; &lt;bean id="myLauncher" class="com.&lt;&gt;.batch.MyLauncher"&gt; &lt;property name="job" ref="batchJob" /&gt; &lt;property name="jobLauncher" ref="jobLauncher" /&gt; &lt;/bean&gt; &lt;task:scheduled-tasks&gt; &lt;task:scheduled ref="myLauncher" method="launch" cron="0 0 0 0 0 1" /&gt; &lt;/task:scheduled-tasks&gt; Each step could be defined and should impl…
answers question: http://stackoverflow.com/q/21582590
type: AcceptedAnswer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/32603529
type: Answer
upvote count: 1
accepted answer of: http://stackoverflow.com/q/21582590

http://stackoverflow.com/comment/32609222
score: 0
type: AnswerComment
type: Comment
has text: Don't know, I'm waiting for response. I've just made some investigation in code I have. This was the only difference I've found. BTW, this way of changing locales is NOT recommended.
comment on: http://stackoverflow.com/a/21585811

http://stackoverflow.com/comment/32632388
comment on: http://stackoverflow.com/a/21589020
has text: LoL. In terms of a workaround that doesn't require changes to RMI itself I've just found [this](http://conditional-logic.blogspot.dk/2010/10/jmx-over-nat-with-rmi-connector.html). I think it is quite clever. Only works in scenario 1 above and has lots of caveats .. but clever thinking.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/21821666
has body: For a requirement like yours, I would suggest to have a tree-like structure to maintain the hierarchical location data. It is relatively easy to implement &amp; maintain and is more scalable &amp; extensible. In order to implement tree you need to have 2 tables LOCATION_NODE (Location ID, Location Name, Location Type[country, state, county, city]) &amp; LOCATION_REL (Relation ID, Parent ID, Child ID). Below is the basic implementation of the tree idea. public class LocationRel&lt;T&gt; { private LocationNode&lt;T&gt; root; public LocationRel(T rootData) { root = new LocationNode&lt;T&gt;(); root.data = rootData; root.children = new ArrayList&lt;LocationNode&lt;T&gt;&gt;(); } public static class LocationNode&lt;T&gt; { private T data; private LocationNode&lt;T&gt; parent; private List&lt;LocationNode&lt;T&gt;&gt; children; } } This is the basic building block for a tree. You may need to add methods for add to, removing from, traversing, and constructors. But, once implemented, you have the freedom to add any new location type, change the hierarchy, add node, delete node etc with your hierarchical data. Think out of the box. Shishir
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21675947
score: 1
upvote count: 1

linux
tags question: http://stackoverflow.com/q/21593045
tags question: http://stackoverflow.com/q/21604458
tags question: http://stackoverflow.com/q/21561755
tags question: http://stackoverflow.com/q/21537792
tags question: http://stackoverflow.com/q/21551141
tags question: http://stackoverflow.com/q/21652581
tags question: http://stackoverflow.com/q/21618285
tags question: http://stackoverflow.com/q/21546278
tags question: http://stackoverflow.com/q/21568886
tags question: http://stackoverflow.com/q/21634510
tags question: http://stackoverflow.com/q/21588499
type: Tag
tags question: http://stackoverflow.com/q/21618487
tags question: http://stackoverflow.com/q/21551373
tags question: http://stackoverflow.com/q/21674512
tags question: http://stackoverflow.com/q/21538488
tags question: http://stackoverflow.com/q/21539712
tags question: http://stackoverflow.com/q/21658061
tags question: http://stackoverflow.com/q/21562423
tags question: http://stackoverflow.com/q/21561004
tags question: http://stackoverflow.com/q/21648335
tag name: linux
tags question: http://stackoverflow.com/q/21533540
tags question: http://stackoverflow.com/q/21596866
tags question: http://stackoverflow.com/q/21660149

http://stackoverflow.com/comment/32558148
comment on: http://stackoverflow.com/q/21557529
type: QuestionComment
type: Comment
has text: Not that, post what value you have given for JAVA_HOME? like C:\Program Files\Java ..
score: 0

http://stackoverflow.com/a/21599754
accepted answer of: http://stackoverflow.com/q/21599551
has comment: http://stackoverflow.com/comment/32633297
answers question: http://stackoverflow.com/q/21599551
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/32632653
has body: You can create two files with different properties and load both of them like this: <value="classpath:myproject-test.properties"/> <value="classpath:myproject.properties"/>
upvote count: 1
type: AcceptedAnswer

http://stackoverflow.com/q/21583911
has comment: http://stackoverflow.com/comment/32608308
has comment: http://stackoverflow.com/comment/32605433
favorite count: 0
has comment: http://stackoverflow.com/comment/32605444
has comment: http://stackoverflow.com/comment/32605516
type: Question
has answer: http://stackoverflow.com/a/21589228
has comment: http://stackoverflow.com/comment/32612746
has comment: http://stackoverflow.com/comment/32605383
tagged with: jdbc
has body: I have 15 prepared statements that I will be using very frequently throughout my application. A few of them will be called several million times during a single task. I have decided to use prepared statements since parsing a regular statement a million times does not seem like a good idea. I am planning to create a utility class that will manage all database-related things and all of the prepared statements. The statements will be stored as static members which I can call by passing in the appropriate arguments. Are there any issues with storing prepared statements as static members that I should be aware of? I am using sqlite-jdbc if that makes a difference. EDIT: This is how I'm planning to manage my prepared statements class DBUtils { private static PreparedStatement psInsertPerson; public static void createStatements() { // assuming a connection has been set up already psInsertPerson = conn.prepareStatement( ... ); } public static void insertPerson( ... ) { psInsertPerson.set... psInsert.addBatch(); // figure out when to perform batch insertion at some point } }
answer count: 1
has comment: http://stackoverflow.com/comment/32605248
upvote count: 3
tagged with: java
has comment: http://stackoverflow.com/comment/32605336
has comment: http://stackoverflow.com/comment/32605662
accepted answer: http://stackoverflow.com/a/21589228
has comment: http://stackoverflow.com/comment/32612481
downvote count: 0
has comment: http://stackoverflow.com/comment/32605115
has title: Storing prepared statements as static members
type: AnsweredQuestion
tagged with: sql
score: 3
has comment: http://stackoverflow.com/comment/32608846
tagged with: sqlite

http://stackoverflow.com/a/21641556
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21641542
type: Answer
has comment: http://stackoverflow.com/comment/32729104
has body: Your 5th JPanel should not be a JackPot object but rather it's own object, perhaps a PayoutPanel object or something similar. The key is that its behavior is intrinsically different from that of JackPot and so its code must be different to match. You need to get your program logic out of your paintComponent method. The logic should not be triggered by a repaint, but rather by an explicit method call, since you cannot fully control repaints. You should give your spinning components a method to allow other objects to extract their state, so that they all can be compared.
score: 4
has comment: http://stackoverflow.com/comment/32847495
upvote count: 4
accepted answer of: http://stackoverflow.com/q/21641542
has comment: http://stackoverflow.com/comment/32728971

http://stackoverflow.com/comment/32812692
has text: @dimadima Answered it for you, if you don't mind, as I do know why this made such a big difference. Please indicate if you made additional changes to your code to make this work.
score: 0
comment on: http://stackoverflow.com/a/21702421
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/32528053
comment on: http://stackoverflow.com/a/21539836
score: 0
type: AnswerComment
has text: Yes, you've nailed it! Thank you.
type: Comment

http://stackoverflow.com/q/21622382
answer count: 1
has answer: http://stackoverflow.com/a/21622528
tagged with: oracle-database
tagged with: windows
has title: Oracle 10g, Using Java for PDF creation hits Too Many Open Files
type: UnansweredQuestion
tagged with: file
tagged with: java
tagged with: database
type: Question
score: 0
has body: After about a month of usual workload system hits error when executing procedure. ora 29532 java.io.filenotfoundexception too many open files. I believe I close handles where I open them. OS: Win2003 x64 Oracle 10.0.2.1 Database EE java.io.FileNotFoundException: Too many open files at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.(FileInputStream.java:106) at java.io.FileInputStream.(FileInputStream.java:66) at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:69) at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:156) at java.net.URL.openStream(URL.java:924) at oracle.xml.parser.v2.XMLReader.openURL(XMLReader.java:2366) at oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:279) at oracle.xml.parser.v2.NonValidatingParser.pushExternalDTD(NonValidatingParser.java:542) at oracle.xml.parser.v2.NonValidatingParser.parseDoctypeDecl(NonValidatingParser.java:479) at oracle.xml.parser.v2.NonValidatingParser.parseProlog(NonValidatingParser.java:311) at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:290) at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:200) at oracle.xml.jaxp.JXDocumentBuilder.parse(JXDocumentBuilder.java:155) at oracle.xml.jaxp.JXDocumentBuilder.parse(JXDocumentBuilder.java:111) at domain.pdf.java_html_to_pdf.print_PDF(JAVA_HTML_TO_PDF:71) at domain.pdf.java_html_to_pdf.convetr_html_to_pdf(JAVA_HTML_TO_PDF:135) Too many open files create or replace and compile java source named WEB.java_html_to_pdf as package domain.pdf; import java.io.ByteArrayOutputStream; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileOutputStream; import java.io.FileInputStream; import java.io.InputStream; import java.io.OutputStream; import java.io.*; import oracle.sql.BLOB; import oracle.sql.CLOB; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import org.w3c.dom.Document; import javax.…

http://stackoverflow.com/q/21604850
tagged with: math
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21604940
downvote count: 0
has comment: http://stackoverflow.com/comment/32641286
has comment: http://stackoverflow.com/comment/32642035
has title: Hashtable, Hashfunction: Difference between Value, Key, Hashvalue?
has comment: http://stackoverflow.com/comment/32643361
has comment: http://stackoverflow.com/comment/32641346
tagged with: hash-function
answer count: 1
favorite count: 0
accepted answer: http://stackoverflow.com/a/21604940
tagged with: hash
upvote count: 2
has comment: http://stackoverflow.com/comment/32641373
has body: Lets imagine we have data we want to put in an Hashtable. The Hashfunction calculates an Hashvalue for each data object and put this hashvalues into a table (each value should get its own bucket). With the hashvalue we know the exact position of the data object in the table. What role does the key play here? The HashMap in Java wants a specific key for every value we put into the HashMap and with the key we can get the value. I am wondering whats the difference between the value we want to put into an Hashtable (in java Hashmap), the hashvalue and the key? What is the mathematic behind that?
linked to: http://stackoverflow.com/q/6493605
type: AnsweredQuestion
score: 2
has comment: http://stackoverflow.com/comment/32641375
has comment: http://stackoverflow.com/comment/32641903

http://stackoverflow.com/comment/32754539
comment on: http://stackoverflow.com/a/21583200
type: AnswerComment
score: 0
type: Comment
has text: Hi Thanks for your response. I tried the same and accessed String in this way InputStream in=ASMHelloWorld.class.getResourceAsStream("Test.class"); MyClassReader classReader=new MyClassReader(in); classReader.hasString("lang"); but its always gives false as a result even though string lang is present in test.class . please help....

http://stackoverflow.com/comment/32649542
has text: This would really serve better as a comment.
type: Comment
comment on: http://stackoverflow.com/a/21609542
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32536514
type: Comment
comment on: http://stackoverflow.com/a/21545290
type: AnswerComment
has text: Thanks for the ans. Actually i was debugging the old code and while printing it display a very long object. this was basically set as a date for a query string to fetch 4 years data (which i got to know now )
score: 0

http://stackoverflow.com/comment/32621007
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21592648
has text: this says that I am missing the return statement after the catch
score: 0

http://stackoverflow.com/comment/32757581
type: AnswerComment
comment on: http://stackoverflow.com/a/21660587
type: Comment
has text: Oh, sorry, I did not see it. I think (almost sure) that delete method does not support body at all. Take a look on this article: http://amundsen.com/examples/put-delete-forms/. It *suggest* to add such functionality to delete and put methods. So, you should use URL path parameters for delete only.
score: 1

http://stackoverflow.com/comment/32667115
comment on: http://stackoverflow.com/a/21618968
type: Comment
has text: `FBArrayList` is the class OP is implementing, with the `insert` method as written in the question
type: AnswerComment
score: 0

http://stackoverflow.com/comment/32510405
score: 6
has text: Are you looking for `MyEnum.valueOf(name)`?
type: QuestionComment
comment on: http://stackoverflow.com/q/21530689
type: Comment

http://stackoverflow.com/comment/32592754
type: QuestionComment
type: Comment
has text: @M D Nop, continues with the same error. Maybe I have to use other method to pass the data from the fragment to the activity? I don't know what to do, because as said, the debugger shows coordinate values in the `latitud` and `longitud` strings
score: 0
comment on: http://stackoverflow.com/q/21576942

http://stackoverflow.com/comment/32672405
comment on: http://stackoverflow.com/a/21602675
has text: You were right, I had two versions of the same enum in myprojects and the import used for my dropdownchoice was different than the one from my bean. Thanks :)
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/q/21519670
has comment: http://stackoverflow.com/comment/32491650
linked to: http://stackoverflow.com/q/4342761
has answer: http://stackoverflow.com/a/21520226
has answer: http://stackoverflow.com/a/21519848
has comment: http://stackoverflow.com/comment/32491780
has title: How To Close Android Application correctly ?
downvote count: 0
has comment: http://stackoverflow.com/comment/32491520
favorite count: 0
has comment: http://stackoverflow.com/comment/32491648
has answer: http://stackoverflow.com/a/21519722
answer count: 5
has body: I have an application which have 2 button, save and exit. save button to insert sqlite and reset all EditText and listview,Exit button to close my android application.here is my save button code : btnsaveto = (Button) findViewById(R.id.btnsaveto); btnsaveto.setOnClickListener(new OnClickListener(){ @Override public void onClick(View arg0) { //do insert into sqlite Globals.mylist.clear();//my listview Globals.outletname=null;//my Editext Globals.outletid=0;//my Editext Globals.notes=null;//my Editext Intent intent = getIntent(); finish(); startActivity(intent); } }); and here is my exit button's code: btnexit = (Button) findViewById(R.id.btnexit); btnexit.setOnClickListener(new OnClickListener(){ @Override public void onClick(View arg0) { finish(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } } ); Here is my oncreate activity : super.onCreate(savedInstanceState); setContentView(R.layout.entry_to); txtoutlet = (TextView) findViewById(R.id.txtoutlet); dataSource = new DBDataSource(this); dataSource.open(); Bundle bun = EntryTO.this.getIntent().getExtras(); try{ if (Globals.mylist == null){Globals.mylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();} id = bun.getLong("id"); Id=String.valueOf(id); description = bun.getString("description"); qty = bun.getString("qty"); if(bun.getString("outletname")!=null){ Globals.outletid = bun.getLong("outletid"); Globals.outletname = bun.getString("outletname"); } map1 = new HashMap&lt;String, String&gt;(); if(Globals.mylist.size() == 0){ if(Id!=null &amp;&amp; description!=null &amp;&amp; Globals.outletname!=null){ map1.put("one", Id); map1.put("two", description); map1.put("three", qty); Globals.mylist.add(map1); txtoutlet.setText(Globals.outletname); }else{ txtoutlet.setText(Globals.outletname); } }else{ int j=Globals.mylist.size(); if(Id!=null &amp;&amp; description!=null &amp;&amp; Globals.outletname!=nu…
tagged with: android
has comment: http://stackoverflow.com/comment/32491282
has comment: http://stackoverflow.com/comment/32491572
has answer: http://stackoverflow.com/a/21519798
has comment: http://stackoverflow.com/comment/32491291
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32492398
upvote count: 1
tagged with: android-intent
type: Question
has comment: http://stackoverflow.com/comment/32491435
has comment: http://stackoverflow.com/comment/32491378
has comment: http://stackoverflow.com/comment/32491333
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32492200
has comment: http://stackoverflow.com/comment/32492243
has answer: http://stackoverflow.com/a/21519735

http://stackoverflow.com/a/21586983
has comment: http://stackoverflow.com/comment/32611057
score: 0
has comment: http://stackoverflow.com/comment/32611012
answers question: http://stackoverflow.com/q/21586835
has comment: http://stackoverflow.com/comment/95332409
type: Answer
has body: Here some pseudo code, if you want more specific solution provide ResultSet details. for(all result set) { currentCategoriesFromDb = current category; currentCategoriesFromDb.setParentCategory() = parentCategoryId; parentCategory.addCategory(currentCategoriesFromDb ) } If all category hierarchy is initialized and you want to navigate you can do something like this: currentCategory.getChildByName(name1).getChildByName(name2); If you want exact all something recursively : printbCategories(Category category) { print(category); List&lt;Category&gt; subCategories = category.getSubCategories(); for(Category category : subCategories ) { printbCategories(category); } }

geometric-arc
tags question: http://stackoverflow.com/q/21614695
type: Tag
tag name: geometric-arc

http://stackoverflow.com/a/21656809
score: 5
has body: It is an anonymous class: public static &lt;T extends Comparable&lt;? super T&gt;&gt; Comparator&lt;T&gt; reverseOrder() { return new Comparator&lt;T&gt;() { public int compare(T o1, T o2) { return o2.compareTo(o1); } }; } You are: Declaring a method compare in the anonymous class, which is in the method reverseOrder. Returning an instance of the anonymous class. Declaring o1 and o2 as the parameters of compare.
downvote count: 0
upvote count: 5
type: Answer
answers question: http://stackoverflow.com/q/21656769

http://stackoverflow.com/comment/32731283
type: Comment
comment on: http://stackoverflow.com/a/21655853
type: AnswerComment
score: 0
has text: I don't see you assigning `loopone` anywhere, except the in `while (loopone = false);`. This will always return true, and will create an infinite loop.

http://stackoverflow.com/a/21644986
score: 4
upvote count: 4
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21644970
has body: split expects a regular expression, and "." is a regular expression for "any character". If you want to split on each . character, you need to escape it: String k[] = sen.split("\\.");

http://stackoverflow.com/a/21639222
has comment: http://stackoverflow.com/comment/32703107
has comment: http://stackoverflow.com/comment/32702654
has comment: http://stackoverflow.com/comment/32702544
score: 0
accepted answer of: http://stackoverflow.com/q/21639096
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21639096
has body: You will not be able to play that file from \assets, you must load from \raw folder. In your project create a folder \raw inside \res and paste your video file. String fileName = "android.resource://"+ getPackageName() + "/raw/video"; VideoView vv = (VideoView) this.findViewById(R.id.surface); vv.setVideoURI(Uri.parse(fileName)); vv.start();
has comment: http://stackoverflow.com/comment/32702844
type: Answer
has comment: http://stackoverflow.com/comment/32702963
has comment: http://stackoverflow.com/comment/32703511
has comment: http://stackoverflow.com/comment/32705975
has comment: http://stackoverflow.com/comment/32702577

http://stackoverflow.com/q/21570991
tagged with: set
has answer: http://stackoverflow.com/a/21571021
type: Question
tagged with: boolean
has answer: http://stackoverflow.com/a/21571031
answer count: 2
upvote count: 0
accepted answer: http://stackoverflow.com/a/21571031
favorite count: 0
has comment: http://stackoverflow.com/comment/32582302
linked to: http://stackoverflow.com/q/513832
duplicate of: http://stackoverflow.com/q/513832
score: -3
downvote count: 3
has body: I do not understand how to set multiple boolean values in a single if statement, nor am I certain if this is possible. I attempted to write out simple test code to experiment and found that I was confusing myself more. import java.util.Scanner; boolean t = false; boolean f = false; boolean a = false; System.out.println("Enter T or F"); Scanner scan = new Scanner(System.in); String t_f = scan.nextLine(); if(t_f == "t"){ t = true; a =false; } else if(t_f == "f"){ f = true; a = true; } if(t = true){ System.out.println("true"); } else if (f = true){ System.out.println("false"); } else if(a = true){ System.out.println("test"); } I am finding that if I enter 'f', "true" is printed, which shouldn't be happening as I've set it to print false if 'f' is entered. (for example) I've attempted to manipulate the if statements varying the use of 'else if' and 'if' however I have had no success. Clearly I am missing a fundamental concept here, if anyone could help it would be greatly appreciated.
has title: Need help understanding Booleans (setting and use)
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/21571021

http://stackoverflow.com/a/21663187
has body: Look at your MainActivity line 23 Caused by: java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.Button That is your error, without code we can not tell what exactly is wrong. IT may have to do with the fact that ImageButton is not a child of Button Take a look at the reference: http://developer.android.com/reference/android/widget/ImageButton.html
type: Answer
score: 0
answers question: http://stackoverflow.com/q/21663085

http://stackoverflow.com/a/21539865
has body: It completely depends on the format of the file. Any book or text document has multiple ways it can be stored and distributed. It could simply be in a .pdf file, or it could be stored in an XML, or .epub It is beyond broad, because there are so many ways to do it, it's impossible to guess without more information. This link has some information about the e-book formats: http://en.wikipedia.org/wiki/Comparison_of_e-book_formats And that's just one small subsection of ways text can be stored.
answers question: http://stackoverflow.com/q/21539625
type: Answer
score: 0

http://stackoverflow.com/a/21716639
type: Answer
score: 2
answers question: http://stackoverflow.com/q/21635031
upvote count: 2
accepted answer of: http://stackoverflow.com/q/21635031
has comment: http://stackoverflow.com/comment/33011424
has body: The solution to the problem was very simple. I just needed to add @Type annotation to the Encounter entity's dateTime field as follows: @Column(name="start_date") @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime") private DateTime dateTime; My original jpa/sql code works fine after adding this one line of code to the entity.
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/32643345
type: Comment
has text: read the api doc, you'll find a method to configure the size :-)
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/21605985

arraylist
tags question: http://stackoverflow.com/q/21618029
tags question: http://stackoverflow.com/q/21670258
tags question: http://stackoverflow.com/q/21549618
tags question: http://stackoverflow.com/q/21652506
tags question: http://stackoverflow.com/q/21652326
tags question: http://stackoverflow.com/q/21665058
tags question: http://stackoverflow.com/q/21564377
tags question: http://stackoverflow.com/q/21661390
tags question: http://stackoverflow.com/q/21566605
tags question: http://stackoverflow.com/q/21592201
tags question: http://stackoverflow.com/q/21616404
tags question: http://stackoverflow.com/q/21608038
tags question: http://stackoverflow.com/q/21528477
tags question: http://stackoverflow.com/q/21623898
tags question: http://stackoverflow.com/q/21639567
tags question: http://stackoverflow.com/q/21612974
tags question: http://stackoverflow.com/q/21617038
tags question: http://stackoverflow.com/q/21640645
tags question: http://stackoverflow.com/q/21604908
tags question: http://stackoverflow.com/q/21595605
tags question: http://stackoverflow.com/q/21582242
tags question: http://stackoverflow.com/q/21664677
tags question: http://stackoverflow.com/q/21667784
tags question: http://stackoverflow.com/q/21626234
tags question: http://stackoverflow.com/q/21568007
tags question: http://stackoverflow.com/q/21515245
tags question: http://stackoverflow.com/q/21654457
tags question: http://stackoverflow.com/q/21678077
tags question: http://stackoverflow.com/q/21614910
tags question: http://stackoverflow.com/q/21612196
tags question: http://stackoverflow.com/q/21624515
tags question: http://stackoverflow.com/q/21618495
tags question: http://stackoverflow.com/q/21563047
tags question: http://stackoverflow.com/q/21542358
tags question: http://stackoverflow.com/q/21587878
tags question: http://stackoverflow.com/q/21559842
tags question: http://stackoverflow.com/q/21570318
tags question: http://stackoverflow.com/q/21598089
tags question: http://stackoverflow.com/q/21614945
tags question: http://stackoverflow.com/q/21534091
tags question: http://stackoverflow.com/q/21665733
tags question: http://stackoverflow.com/q/21534964
tags question: http://stackoverflow.com/q/21651128
tags question: http://stackoverflow.com/q/21641910
tags question: http://stackoverflow.com/q/21612415
tags question: http://stackoverflow.com/q/21538405
tags question: http://stackoverflow.com/q/21651572
tags question: http://stackoverflow.com/q/21660293
tags question: http://stackoverflow.com/q/21672909
tags question: http://stackoverflow.com/q/21531174
tags question: http://stackoverflow.com/q/21592109
tags question: http://stackoverflow.com/q/21539586
tags question: http://stackoverflow.com/q/21554109
tags question: http://stackoverflow.com/q/21612168
tags question: http://stackoverflow.com/q/21570517
tags question: http://stackoverflow.com/q/21595253
tags question: http://stackoverflow.com/q/21621291
tags question: http://stackoverflow.com/q/21675524
tags question: http://stackoverflow.com/q/21637067
tags question: http://stackoverflow.com/q/21611881
tags question: http://stackoverflow.com/q/21533531
tags question: http://stackoverflow.com/q/21551545
tags question: http://stackoverflow.com/q/21615302
tags question: http://stackoverflow.com/q/21574696
tags question: http://stackoverflow.com/q/21673270
tags question: http://stackoverflow.com/q/21523071
tags question: http://stackoverflow.com/q/21649727
tags question: http://stackoverflow.com/q/21672382
tags question: http://stackoverflow.com/q/21575502
tags question: http://stackoverflow.com/q/21629089
tags question: http://stackoverflow.com/q/21514925
tags question: http://stackoverflow.com/q/21562958
tags question: http://stackoverflow.com/q/21638655
tags question: http://stackoverflow.com/q/21586710
tags question: http://stackoverflow.com/q/21629794
tags question: http://stackoverflow.com/q/21539056
tags question: http://stackoverflow.com/q/21605431
tags question: http://stackoverflow.com/q/21514794
tags question: http://stackoverflow.com/q/21665068
tags question: http://stackoverflow.com/q/21631862

http://stackoverflow.com/q/21620842
has comment: http://stackoverflow.com/comment/32669991
has answer: http://stackoverflow.com/a/21623494
answer count: 1
favorite count: 0
tagged with: spring
upvote count: 4
has body: My Spring app consists of two context xml config files, the first one root-context.xml only scans non-@Controller annotated beans: <context:component-scan base-package="com.myapp.test"> <context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/> </context:component-scan> While the second one servlet-context.xml contains all spring-mvc setup and scans @Controller annotated beans <beans:beans xmlns="http://www.springframework.org/schema/mvc" ...> <annotation-driven /> <context:component-scan base-package="com.myapp.test"> <context:include-filter expression="org.springframework.stereotype.Controller" type="annotation"/> </context:component-scan> ... </beans:beans> DispatcherServlet config on web.xml looks like this ... contextConfigLocation /WEB-INF/spring/root-context.xml org.springframework.web.context.ContextLoaderListener appServlet org.springframework.web.servlet.DispatcherServlet contextConfigLocation /WEB-INF/spring/appServlet/servlet-context.xml 1 ... I wanted to try annotation based caching so I added following beans definition to root-context.xml <cache:annotation-driven/> And test this with a @Service annotated class which should be scanned by root-context.xml @Service public FooService { @Cacheable("foo") public int getFoo() { System.out.println("cache miss"); return new Random().nextInt(50); } } But the getFoo() method call never gets cached, I always get random number everytime. If however I scanned all my beans on servlet-context.xml and relocated my caching beans definition there it works. What may cause this? There's definitely something I don't yet understand about caching annotations.
type: AnsweredQuestion
has title: Spring annotation based caching
downvote count: 0
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/21623494
score: 4

http://stackoverflow.com/comment/32515756
comment on: http://stackoverflow.com/a/21533461
score: 0
type: Comment
has text: `RANDOM SENTENCE` probably means it is some random text. You should use startsWith to check `.START_SEQUENCE` instead. Anyway, processing the file line by line uses less memory than regex approach.
type: AnswerComment

http://stackoverflow.com/a/21555172
upvote count: 3
accepted answer of: http://stackoverflow.com/q/21553557
type: AcceptedAnswer
type: Answer
has body: Assuming your database is failing to register even when the listener has been running for a while, it sounds like your local_listener parameter isn't explicitly set, so your database is trying to register on a default address; and since it's failing to register, whatever address it's using doesn't seem to be the same one the listener is on. Assuming watson is resolving to a useful external IP address, which is probably the case if you're able to get that TNS error from outside your box, you can tell the database to use the same address to register: alter system set local_listener = '(ADDRESS=(PROTOCOL=TCP)(HOST=watson)(PORT=1521))' scope=memory; alter system register; If that works and lsnrctl services now shows XE and you're happy with it, you can change the memory to both and re-execute so it persists across the next DB restart. Alternatively, if you've only tried connecting within the same box, watson might be resolving to something unhelpful, like 127.0.0.1 if it's set to do that in your /etc/hosts; or your /etc/hosts address might not agree with your DNS entry. You can change the listener.ora and tnsnames.ora to the 'right' FQDN or IP address instead, as long as that matches whatever your database thinks is the network name.
answers question: http://stackoverflow.com/q/21553557
downvote count: 1
score: 2

http://stackoverflow.com/comment/32573664
comment on: http://stackoverflow.com/a/21559868
has text: @Hannes Is it really bad? Why?
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32487583
comment on: http://stackoverflow.com/q/21517507
score: 1
has text: What does the shuffle method do? Should it return a MyCard object? Are you sure? Does it change the current MyDeck object? Or should it return a new MyDeck object? What do your instructions say? We'll need to see its code.
type: QuestionComment
type: Comment

http://stackoverflow.com/q/21529489
accepted answer: http://stackoverflow.com/a/21530694
score: 2
upvote count: 2
has title: Tapestry loop through nested map in tml file
tagged with: loops
type: Question
type: AnsweredQuestion
tagged with: list
tagged with: java
has body: I have following map Map<String, Map<String, Long>> This map is accessible through following method in java file. public List<Entry<String, List<Entry<String, Long>>>> getByEventTypeSorted() { List<Entry<String, List<Entry<String, Long>>>> ret = new ArrayList<Entry<String, List<Entry<String, Long>>>>(); ret.addAll((Collection<? extends Entry<String, List<Entry<String, Long>>>>) byEventType.entrySet()); return ret; } Thus I am converting Map<String, Map<String, Long>> into List<Entry<String, List<Entry<String, Long>>>> and returning it. Now, in my tml file I am trying to loop through it like this. ${entry.key} ${entry2.key} Corresponding java file has following properties. @Property private Entry<String,Long> entry; @Property private Entry<String,Long> entry2; When I run the above code. Following exception is generated. Failure writing parameter 'value' of component ConceptSummaries:loop_1: Could not find a coercion from type java.lang.String to type java.util.Map$Entry. If I change the type of property entry2 to String in java file like below..... @Property private Entry<String,Long> entry; @Property private String entry2; And loop in tml file like below. ${entry.key} ${entry2} Then I get the whole list rendered as a single string. This means that tapestry is converting the List<Entry<String, Long>> into a String. I do not want that to happen as I want to loop through the list and access individual entries. How to loop through these nested maps? And is there any way to retain the type of inner list and prevent tapestry from converting it into a string? Update: I was able to solve this problem using Lance Java's suggestions. Following are the details. code in tml file. ${entry.key} ${entry2.key} I have a getter method for "KeySetForEntryValue" and Map<String, Map<String, Long>> in corresponding java class. public Set<Entry<String, Long>> getKeySetForEntryValue(){ return entry.getValue().entrySet(); } public Map<String, Map<String, Long>> getByEventTypeSorted() { retu…
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/32510338
tagged with: tapestry
tagged with: dictionary
has answer: http://stackoverflow.com/a/21530694
favorite count: 0

http://stackoverflow.com/q/21612047
accepted answer: http://stackoverflow.com/a/21612172
possible better answer: http://stackoverflow.com/a/21612096
answer count: 2
has comment: http://stackoverflow.com/comment/32654191
score: 0
has body: I have been working on an android project, and recently imported to Eclipse at home. Once I imported my project to Eclipse I suddenly have a lot of new java errors, which I didn't have in my previous environment. I have cleaned the import and removed some of the path errors, but I'm not sure what I should do next. I believe that these errors are most likely the result of something I have done stupidly on my part, but I am not sure.
has comment: http://stackoverflow.com/comment/32654484
has answer: http://stackoverflow.com/a/21612172
tagged with: android
has comment: http://stackoverflow.com/comment/32654217
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21612096
tagged with: java
has title: New import to eclipse, suddenly a lot of Java errors
tagged with: eclipse
type: Question

http://stackoverflow.com/comment/32719938
comment on: http://stackoverflow.com/q/21649566
score: 0
has text: is this the complete json, what have you tried so far ?
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32748053
comment on: http://stackoverflow.com/a/21665228
type: AnswerComment
score: 0
type: Comment
has text: It works now, but I still don't understand why. It now looks like:

http://stackoverflow.com/q/21603172
possible better answer: http://stackoverflow.com/a/21603273
accepted answer: http://stackoverflow.com/a/21603282
has body: I am using Factory to create my objects like following, here both MyObject and YourObject classes implements MyInterface: public class MyFactory { public static MyInterface myObject(int value, int commonValue) { return new MyObject(value, commonValue); } public static MyInterface yourObject(String str, int commonValue) { return new YourObject(str, commonValue); } } I want to set commonValue at the factory level instead of passing them as parameters in individual methods, as the same value is passed to create set of objects using factory. Also once I create one set of objects using the factory I want to reset commonValue to its default so that previously set value is not used by default later on. What is the right way to do this?
tagged with: design-patterns
has answer: http://stackoverflow.com/a/21603282
tagged with: factory
type: AnsweredQuestion
tagged with: oop
tagged with: java
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/21603273
has title: Using fields/variable in Factory class to be used across objects created through factory
tagged with: factory-pattern
score: 0

http://stackoverflow.com/comment/32658123
comment on: http://stackoverflow.com/q/21613416
score: 0
type: Comment
has text: @Fede, just inspect what your browser (the xml one) is sending as accept header and content type and add those headers to your `RestTemplate` (with an interceptor).
type: QuestionComment

http://stackoverflow.com/comment/32759728
has text: You asked "what is the workaround", where the workaround is clearly listed. Why didn't you ask "how to make the workaround work for me?"
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21672219
type: Comment

http://stackoverflow.com/q/21525487
has body: how use this plugin in grails application?? I have exceptions : In Config.groovy imageUpload { temporaryFile = "webapp/images" // Path to where files will be uploaded } In Index.gsp &lt;head&gt;&lt;r:require module="fileuploader" /&gt;&lt;/head&gt; &lt;body&gt; &lt;uploader:uploader id="yourUploaderId"&gt; &lt;uploader:onComplete&gt; $('statusDiv').update('Thank you for uploading the file '); &lt;/uploader:onComplete&gt; &lt;/uploader:uploader&gt; &lt;/body&gt; ExceptionS: | Error 2014-02-03 12:22:57,386 [http-bio-8080-exec-4] ERROR ajaxuploader.AjaxUploadController - Failed to upload file. Message: java.io.FileNotFoundException: web-app\images\avatars (Accès refusé) Line | Method ->> 14 | upload in uk.co.desirableobjects.ajaxuploader.AjaxUploaderService | 22 | doCall in uk.co.desirableobjects.ajaxuploader.AjaxUploadController$_closure1 | 195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter | 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor | 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker ^ 744 | run . . . in java.lang.Thread Caused by FileNotFoundException: web-app\images\avatars (Accès refusé) ->> 221 | in java.io.FileOutputStream | 12 | upload in uk.co.desirableobjects.ajaxuploader.AjaxUploaderService | 22 | doCall . in uk.co.desirableobjects.ajaxuploader.AjaxUploadController$_closure1 | 195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter | 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor | 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker ^ 744 | run in java.lang.Thread
has comment: http://stackoverflow.com/comment/32550477
favorite count: 0
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32501378
score: 2
tagged with: java
has title: Grails <=====> compile ":ajax-uploader:1.1"
type: Question
upvote count: 2
downvote count: 0
tagged with: upload
has comment: http://stackoverflow.com/comment/32549293
tagged with: grails
tagged with: ajax
has comment: http://stackoverflow.com/comment/32504204

http://stackoverflow.com/comment/32565914
has text: There's ways to reduce this code, but compact code isn't necessarily good code. As Niks said, just move on. This is fine.
type: QuestionComment
comment on: http://stackoverflow.com/q/21561998
score: 3
type: Comment

http://stackoverflow.com/comment/32763107
comment on: http://stackoverflow.com/a/21574728
has text: Ty again! Do you think we would gain a performance boost with python compared to Java-code? Also do speed things up I am think about combining multiple Select-statements, but all I can think of is `UNION ALL` which has a limit of (500?) Selects. Is there another way to do so?
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32680529
score: 0
has text: Thanks for the reply. My problem got solved by using ChartFactory.createStackedBarChart3D() method
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21622419

http://stackoverflow.com/comment/32708106
type: Comment
score: 1
comment on: http://stackoverflow.com/q/21642617
type: QuestionComment
has text: You need to show an attempt or have a real question. This is not a tutorial site.

http://stackoverflow.com/comment/32535377
comment on: http://stackoverflow.com/a/21544892
type: Comment
type: AnswerComment
has text: Thanks for your reply if i install JVM on ios then is it Possible ?
score: 0

http://stackoverflow.com/comment/32825616
type: QuestionComment
type: Comment
has text: Sorry, too busy watching olympics of late. How are you deploying your app? If following the tutorial, then the terminal window is where the application server (Tomcat) logs, just copy the text from there into your question.
comment on: http://stackoverflow.com/q/21665694
score: 0

http://stackoverflow.com/q/21551106
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/21551166
has body: I'm writing some code to calculate a certain valuation for a hierarchy (done in points). I'm using switch statements with a scanner (declared as a static variable), and for some reason in each of the boardTypes, the "y" and "n" cases don't break; they just go into the next boardType case. What am I doing wrong here? System.out.println("Are they on board? (y/n)"); isOnBoard = s.nextLine(); switch (isOnBoard){ case "y": System.out.println("Chapter, regional, or international board? "); boardType = s.nextLine(); switch (boardType){ case "chapter": System.out.println("Are they chapter president? (y/n)"); switch(s.nextLine()){ case "y": totalPoints = chapterPres; break; case "n": totalPoints = chapterBoardMember; break; } case "regional": System.out.println("Are they regional president? (y/n)"); switch(s.nextLine()){ case "y": totalPoints = regionalPres; break; case "n": totalPoints = regionalExecutive; break; } case "international": System.out.println("Are they international president? (y/n)"); switch(s.nextLine()){ case "y": totalPoints = internationalPres; break; case "n": totalPoints = internationalExecutive; break; } case "n": break; } Thanks all!
has answer: http://stackoverflow.com/a/21551180
upvote count: 1
downvote count: 1
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/21551157
tagged with: switch-statement
type: Question
accepted answer: http://stackoverflow.com/a/21551180
possible better answer: http://stackoverflow.com/a/21551157
score: 0
has answer: http://stackoverflow.com/a/21552228
has title: Why isn't this switch block working?

http://stackoverflow.com/q/21598382
tagged with: garbage-collection
downvote count: 1
type: Question
possible better answer: http://stackoverflow.com/a/21598455
has title: How to explicitly perform garbage collection
has body: With its built-in garbage collection, Java allows developers to create new objects without worrying explicitly about memory allocation and deallocation, because the garbage collector automatically reclaims memory for reuse. AFAIK Garbage Collector usually runs when your app runs out of memory. it holds a graph that represents the links between the objects and isolated objects can be freed. Though we have System.gc(), but if you write System.gc() in your code the Java VM may or may not decide at runtime to do a garbage collection at that pointas explained by this post System.gc() in Java So I was having some doubts regarding the Garbage collection process of java. I wonder if there is such method in java like free() as such in C language, that we could invoke when we explicitly want to free the part of memory allocated by a new operator. Also does new performs the same operation as do malloc() or calloc()? Are there any alternates for delete(), free(), malloc(), calloc() and sizeof() methods in java.
score: 9
has answer: http://stackoverflow.com/a/21598533
linked to: http://stackoverflow.com/q/2414105
favorite count: 0
has answer: http://stackoverflow.com/a/21598455
upvote count: 10
tagged with: android
has comment: http://stackoverflow.com/comment/32630549
has answer: http://stackoverflow.com/a/21598484
accepted answer: http://stackoverflow.com/a/21598484
has comment: http://stackoverflow.com/comment/32634004
answer count: 4
has answer: http://stackoverflow.com/a/21598835
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/66540
tagged with: java
linked to: http://stackoverflow.com/q/1582209

http://stackoverflow.com/a/21562231
has comment: http://stackoverflow.com/comment/32568424
type: Answer
accepted answer of: http://stackoverflow.com/q/21559984
score: 1
answers question: http://stackoverflow.com/q/21559984
upvote count: 1
has body: You are storing the dates in the SQL database as text strings, but then asking SQL to return values between to limits and expecting it to interpret those limits as dates when it hasn't been told that they are dates and wouldn't know how to interpret the text format as a date if it did know they were dates. Use Date.getTime() to convert the dates to long values and store those in SQL as numbers. Similarly convert your start and end times to long values, and ask SQL to return records between those values. Any time you need to convert what is stored in SQL back into a user-friendly date, use the Date(long value) constructor and pass it the number that SQL gives you.
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/32677431
comment on: http://stackoverflow.com/q/21625445
score: 0
has text: What is the so called square though, what you said was vague.
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21602466
type: Answer
upvote count: 2
score: 2
has body: Try redirecting stderr also: /usr/IBM/WebSphere/AppServer/java/bin/java -verbose:class -cp "XXXXX" com.ibm.XXXX &gt;&gt;/home/user/log.log 2&gt;&amp;1 Your Java code might be writing on stderr that your command isn't redirecting.
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21602441
answers question: http://stackoverflow.com/q/21602441

http://stackoverflow.com/q/21669092
tagged with: java
tagged with: loops
upvote count: 1
tagged with: passwords
has body: i can't figure out how i am supposed to return the first position org and check are different. Do i have to use substrings? import acm.program.*; public class CheckPasswords extends ConsoleProgram { public void run() { while(true) { String org = readLine("Enter Password: "); String check = readLine("Confirm Password: "); if(org.equals(check)) { println("Password Confirmed"); } else { println("Passwords do not Match"); //??? } } } }
answer count: 4
has answer: http://stackoverflow.com/a/21669242
has title: Return the position first position two strings are different
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: string
possible better answer: http://stackoverflow.com/a/58127267
has answer: http://stackoverflow.com/a/21684408
favorite count: 0
has answer: http://stackoverflow.com/a/58127267
accepted answer: http://stackoverflow.com/a/21669242
type: Question
has answer: http://stackoverflow.com/a/21669307
tagged with: acm-java-libraries

http://stackoverflow.com/comment/32854161
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21677984
has text: according to the document the problem is when you have el in your parameter that gets evaluated. the case you show is perfectly normal. and, imo, disabling el completely is just missing out on a lot of useful functionality
score: 0

http://stackoverflow.com/comment/32764954
comment on: http://stackoverflow.com/q/21675326
type: Comment
type: QuestionComment
has text: If you won't limit yourself to JDK 6 you could use Apache common collections library. Its also sorted in order and you can even add at a specific location ListOrderedSet. http://commons.apache.org/proper/commons-collections/ http://commons.apache.org/proper/commons-collections/javadocs/api-release/org/apache/commons/collections4/set/ListOrderedSet.html
score: 0

http://stackoverflow.com/comment/32761611
has text: @Sybren actually i am not able to access the attached file due to firewall so i missed pblm.Plz give me some time to give u proper answer.
comment on: http://stackoverflow.com/a/21673192
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/32647088
type: AnswerComment
comment on: http://stackoverflow.com/a/21599320
type: Comment
has text: Please mark your answer as solved so this doesn't question say open - thanks!
score: 0

http://stackoverflow.com/comment/32680725
has text: Thanks Peter. Memory is no issue. On top of that , the performance implication in writing to file system would be quite huge. And yes, as I mentioned in the post, I also tried Camel-JSON, which is the unmarshaller you see above.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21622962

http://stackoverflow.com/q/21609887
tagged with: jetty
accepted answer: http://stackoverflow.com/a/21631792
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
tagged with: web-applications
has body: How can I disable .war auto-reloading in Jetty server? This question addresses the problem, but its for Jetty Maven, while I am using standalone version.
has title: Disable web app auto-reloading in standalone Jetty server
has answer: http://stackoverflow.com/a/21631792
type: Question
linked to: http://stackoverflow.com/q/9758983
upvote count: 1
answer count: 1
favorite count: 0

http://stackoverflow.com/comment/32713760
score: 0
type: Comment
has text: did you use any IDE like eclipse ?
type: AnswerComment
comment on: http://stackoverflow.com/a/21645761

http://stackoverflow.com/a/21648074
type: Answer
answers question: http://stackoverflow.com/q/21642489
score: 4
has body: For the last else statement, it seems a bit off from the rest of your statements. You're using "hold" to store the original checkAmount value, then modifying checkAmount to be the fee for the first three statements. You should model the last one like the one before it. The checkAmount should be checkAmount = (checkAmount * .01) + 40, then hold - checkAmount should return the value you're looking for. By having checkAmount = checkAmount - 40, the last line is returning hold (checkAmount) - (checkAmount - 40), which will always return 40.
upvote count: 4
downvote count: 0

http://stackoverflow.com/q/21518697
has comment: http://stackoverflow.com/comment/32497167
has comment: http://stackoverflow.com/comment/32491022
downvote count: 0
tagged with: spring
type: AnsweredQuestion
score: 1
tagged with: java
possible better answer: http://stackoverflow.com/a/21523182
has title: Spring AOP AsjectJ annotations : define pointcut for multiple methods
type: Question
tagged with: aspectj
answer count: 2
upvote count: 1
has answer: http://stackoverflow.com/a/21522019
accepted answer: http://stackoverflow.com/a/21522019
has body: I have defined by advise to be executed for the two methods : SampleBusinessLogicImpl.updateSample(Sample sample) and SampleBusinessLogicImpl.createSample(Sample sample) But my advise get executed for the first update() method only. What am I doing wrong here ? @Aspect public class SampleDynamicValidationAspect { private static final Logger logger = LoggerFactory.getLogger(SampleDynamicValidationAspect.class); /** private SampleTblDAO dao; //DAOs can be used inside dynamic validations **/ @Before("execution(public * com.rakuten.gep.sample.businesslogic.impl.SampleBusinessLogicImpl.updateSample(com.rakuten.gep.sample.entity.common.Sample,..)) &amp;&amp; args(sample,..) throws *Exception" +"|| execution(public * com.rakuten.gep.sample.businesslogic.impl.SampleBusinessLogicImpl.createSample(com.rakuten.gep.sample.entity.common.Sample,..)) &amp;&amp; args(sample,..) throws *Exception") public void validate(Sample sample) throws SampleException { //Dynamic validation here. //If some validation is failed, wrapped the appropiate exception in SampleException System.out.println("Involking Dynamic Validator"); } } My SampleBusinessLogicImpl class is as follows : @Service public class SampleBusinessLogicImpl implements SampleBusinessLogic { @Autowired @Qualifier(value="proxySampleTblDao") private SampleTblDao sampleTblDao; @Override @Transactional(rollbackFor=Exception.class) public Sample createSample(Sample sample) throws SampleException { //.. } @Override @Transactional(rollbackFor=Exception.class) public Sample updateSample(Sample sample) throws SampleException { //.. } }
tagged with: aop
favorite count: 0
tagged with: spring-aop
has answer: http://stackoverflow.com/a/21523182
has comment: http://stackoverflow.com/comment/32491871

http://stackoverflow.com/q/21637133
tagged with: android
tagged with: email
linked to: http://stackoverflow.com/q/14042742
has comment: http://stackoverflow.com/comment/32698641
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21641520
downvote count: 2
has answer: http://stackoverflow.com/a/21637186
upvote count: 1
has title: Locating SMTP servers and their ports?
has body: I'm making some researches for my final school project. And my idea is to develop an android e-mail client. I'm testing some ideas that I've got and a problem appeared. To contact a SMTP server, to send e-mails, I need to know is (SMTP server) name and port. For example, if a users has a mail.ru account, then I need to know the SMTP server name and port for contact. Is there any way to find that name and port programmatically?
tagged with: java
score: -1
has comment: http://stackoverflow.com/comment/32698588
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/32699578
tagged with: smtp

http://stackoverflow.com/comment/32643144
score: 0
comment on: http://stackoverflow.com/a/21605587
type: Comment
has text: Hi thanks! If I already have a public static int numberOfZeros(int n) { n = Math.abs(n); // 1. STOPPING CONDITION: Number has only only digit. if ( n < 10 ) { // if( n == 0 ) return 1; else return 0; Can I still add another public static int numberOfDigits(int number) { ?
type: AnswerComment

http://stackoverflow.com/comment/32630882
type: QuestionComment
score: 3
has text: With just `static` on the variables I got 4.5 as the output time, with `static volatile` I get 11.7. Also, if I make the variables neither `static` or `volatile` and just put them in the method, it's 4.6
comment on: http://stackoverflow.com/q/21598558
type: Comment

http://stackoverflow.com/q/21632931
has comment: http://stackoverflow.com/comment/32691018
has comment: http://stackoverflow.com/comment/32690464
accepted answer: http://stackoverflow.com/a/21633334
downvote count: 0
has comment: http://stackoverflow.com/comment/32690746
favorite count: 0
tagged with: static
has title: Do Java classes have an instance on machine (JVM) level if they contain only static methods and fields?
upvote count: 2
linked to: http://stackoverflow.com/q/3037637
has answer: http://stackoverflow.com/a/21632974
has comment: http://stackoverflow.com/comment/32690479
answer count: 4
has comment: http://stackoverflow.com/comment/32690486
score: 2
type: AnsweredQuestion
tagged with: instance
has answer: http://stackoverflow.com/a/21633976
has answer: http://stackoverflow.com/a/21633126
possible better answer: http://stackoverflow.com/a/21632974
tagged with: java
has answer: http://stackoverflow.com/a/21633334
type: Question
has body: Do Java classes have an instance on machine (JVM) level if they contain only static methods and fields? And if yes, what are the effects of static methods and fields when doing multithreading? Any rules of thumb?

http://stackoverflow.com/q/21558653
tagged with: java
has body: more specifically, I have a HandlerExceptionResolver registered in xml. I want to override this catch all resolver with an annotation defined one, but the xml one always runs.
type: Question
has title: Is it possible to override xml registered beans with annotation registered bean in spring?
score: 0
has comment: http://stackoverflow.com/comment/32562221
type: UnansweredQuestion
tagged with: spring
has comment: http://stackoverflow.com/comment/32559642
answer count: 0

http://stackoverflow.com/q/21590991
tagged with: cmd
has comment: http://stackoverflow.com/comment/32618362
tagged with: input
tagged with: text
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32619048
accepted answer: http://stackoverflow.com/a/21596633
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32627504
has answer: http://stackoverflow.com/a/21596633
has comment: http://stackoverflow.com/comment/32618259
tagged with: eclipse
has body: I've been using cmd to run supplied .txt through my java homework because the instructor also supplies the correct output, so we can check that our program functions properly. It looks like this when I do it... ...Documents\CSE205\Assignment5&gt;java Assignment5 &lt; input1.txt &gt; myoutput1.txt The instructor pointed us to a file compare tool that will highlight differences between myoutput and the expected output. I just learned that I can compile all classes in the folder with the command javac *.java So I'd like to know if there is any way to feed my program each of 4 inputs to get 4 separate myoutput files through the command prompt or some other way. Thanks in Advance macncheese
score: 0
has title: How to run several .txt input files as a test for Java program with output files
answer count: 1

http://stackoverflow.com/comment/33039184
score: 1
has text: Thanks a lot, although everything is messy and has too many functions, it does contains what i am looking for!
type: AnswerComment
comment on: http://stackoverflow.com/a/21822770
type: Comment

http://stackoverflow.com/comment/32671706
type: QuestionComment
score: 0
has text: Oh so you pull info from Contacts/FB/G+ into this file, then operate on it based on user input and store results in DB? It would help to have some info about the file format and DB schema, but offhand I'd say yes, your initial source should be a DB as well.
comment on: http://stackoverflow.com/q/21621955
type: Comment

http://stackoverflow.com/comment/32741738
comment on: http://stackoverflow.com/q/21662075
type: Comment
has text: Yes of course. Let me fix that.
type: QuestionComment
score: 0

http://stackoverflow.com/q/21518064
accepted answer: http://stackoverflow.com/a/21518232
has comment: http://stackoverflow.com/comment/32488629
has title: Re-instantiating objects without losing previous
possible better answer: http://stackoverflow.com/a/21518097
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21518097
tagged with: java
has comment: http://stackoverflow.com/comment/32488560
has comment: http://stackoverflow.com/comment/32488618
has comment: http://stackoverflow.com/comment/32488545
type: Question
has comment: http://stackoverflow.com/comment/32488584
has comment: http://stackoverflow.com/comment/32488698
has body: I'm not too sure about how I should go about solving this problem for an assignment I have. I'm being asked to keep track of multiple flights, they're all stored in one file, each line represents a various aspect of each flight. I'm asked to keep track of every flight by its flight number in an ordered list. Right now I'm just trying to test my code out without any of the fileIO. Here's what I have right now, OrderedList flights = new OrderedList(); Flight flight = new Flight(); flight.setFlightNumber(678); flights.add(flight); flights.printList(); This code works fine, however when I will do my fileIO I will need to re instantiate the variable to another flight like so, .... flight = new Flight(); flight.setFlightNumber(876); flights.add(flight); flights.printList(); I think that what's happening here is the pointer to the old flight isn't being found? Does anyone have any suggestions on how to work around this? EDIT: Some more information, when compiled I get a run time error of: Exception in thread "main" java.lang.ClassCastException: Flight cannot be cast to java.lang.Integer The error is thrown in my OrderedList class one the add methods line of, while(current != null &amp;&amp; (newFlight.getFlightNumber() &gt; (Integer)current.getData())) { Here's a screenshot of the debugger,
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/21518232

http://stackoverflow.com/a/21601767
has body: A browser send 2 requests. 1 is your GET request and the 2nd one is an attempt to retrieve the favicon.
type: Answer
answers question: http://stackoverflow.com/q/21601698
has comment: http://stackoverflow.com/comment/32636497
has comment: http://stackoverflow.com/comment/32636050
has comment: http://stackoverflow.com/comment/32636160
has comment: http://stackoverflow.com/comment/32635882
score: 0

http://stackoverflow.com/comment/32754254
type: AnswerComment
type: Comment
score: 1
comment on: http://stackoverflow.com/a/21668997
has text: As a side note, recommend to follow Java naming conventions: `bucWidth` instead of `BucWidth`

http://stackoverflow.com/a/21539082
score: 1
has body: You'll have to make your takephoto() return a boolean, not a void value. ---- EDIT ---- public static boolean takePhoto() { if(camera != null) { camera.takePicture(null, null, pictureTakenHandler); return true; } else return false; }
upvote count: 1
has comment: http://stackoverflow.com/comment/32526467
has comment: http://stackoverflow.com/comment/32526725
has comment: http://stackoverflow.com/comment/32526413
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21539055
answers question: http://stackoverflow.com/q/21539055
type: Answer
downvote count: 0

http://stackoverflow.com/q/21582724
has answer: http://stackoverflow.com/a/21583612
has comment: http://stackoverflow.com/comment/32603163
score: 0
tagged with: batch-file
answer count: 1
has body: I am running two batch Java classes fron windows batch file in a sequence. I want to give an option to exit after the first class is run; after the first pause statement. How do I use jump to terminate the program if the user wants to close it without using the close button on GUI? Also, can PAUSE e customised to change its default message? @ECHO off color 0E ECHO Running prog..... ECHO Step 1 commences.... java -cp D:\proj\bin;D:\proj\mysql-connector-java-5.1.12-bin.jar com.Class1 ECHO Please ensure modem is on and press any key! ECHO Step 2 commences.... PAUSE :: Give option to exit java -cp D:\proj\bin com.Class echo Completed program..... PAUSE
accepted answer: http://stackoverflow.com/a/21583612
tagged with: windows
has title: How to jump from program to exit in windows batch
type: AnsweredQuestion
tagged with: java
type: Question

http://stackoverflow.com/comment/32645303
type: QuestionComment
comment on: http://stackoverflow.com/q/21606934
score: 0
has text: Just thought there could be a better way i'm not an expert :-)
type: Comment

http://stackoverflow.com/a/21614502
type: Answer
score: 2
has body: It's not an accessor, because it doesn't return a value (it's void). One could argue that it's a mutator, because it modifies the state of the underlying I/O system (it has side effects), but it's not a clear-cut distinction, because is not modifying the state of the System class or any of its instances. The accessor/mutator distinction generally applies to methods that return a value obtained from an object's attributes (accessors) or methods that modify those attributes (mutators), but this is not the case for println(), the state being modified (an output stream) lies outside of the class.
upvote count: 2
downvote count: 0
answers question: http://stackoverflow.com/q/21614462

http://stackoverflow.com/a/21673030
score: 1
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/21661055
has body: I'm coding a program where you get the ingredients names. So i need to get the whole row of one column and String it all up together, because i need to store it in mySql and i have already set it all as String. Want to do so, try this. Here I am getting result into ArrayList and String, as I am commented ArrayList you can avoid it. public class TableValuePrint extends JFrame implements ActionListener{ private final JButton print; private final JTable table; private String str=""; public TableValuePrint() { setSize(600, 300); String[] columnNames = {"A", "B", "C"}; Object[][] data = { {"Moni", "adsad", "Pass"}, {"Jhon", "ewrewr", "Fail"}, {"Max", "zxczxc", "Pass"} }; table = new JTable(data, columnNames); JScrollPane tableSP = new JScrollPane(table); JPanel tablePanel = new JPanel(); tablePanel.add(tableSP); tablePanel.setBackground(Color.red); add(tablePanel); setTitle("Result"); setSize(1000,700); print=new JButton("Print"); JPanel jpi1 = new JPanel(); jpi1.add(print); tablePanel.add(jpi1,BorderLayout.SOUTH); print.addActionListener(this); setLocationRelativeTo(null); setDefaultCloseOperation(EXIT_ON_CLOSE); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { TableValuePrint ex = new TableValuePrint(); ex.setVisible(true); } }); } @Override public void actionPerformed(ActionEvent ae) { if(ae.getSource()==print){ // ArrayList list = new ArrayList(); for(int i = 0;i&lt;table.getModel().getRowCount();i++) { //list.add(table.getModel().getValueAt(i, 0)); //get the all row values at column index 1 str=str+table.getModel().getValueAt(i,0).toString(); } //System.out.println("List="+list); System.out.println("String="+str); } } } Output String=MoniJhonMax
downvote count: 0

nested
tags question: http://stackoverflow.com/q/21518607
tag name: nested
type: Tag
tags question: http://stackoverflow.com/q/21660121

jdbc
tags question: http://stackoverflow.com/q/21530112
tags question: http://stackoverflow.com/q/21566612
tags question: http://stackoverflow.com/q/21651671
tags question: http://stackoverflow.com/q/21579971
tags question: http://stackoverflow.com/q/21583317
tags question: http://stackoverflow.com/q/21558783
tags question: http://stackoverflow.com/q/21608714
tags question: http://stackoverflow.com/q/21541745
tags question: http://stackoverflow.com/q/21579326
tags question: http://stackoverflow.com/q/21580499
tags question: http://stackoverflow.com/q/21596325
tags question: http://stackoverflow.com/q/21568095
tags question: http://stackoverflow.com/q/21596834
tags question: http://stackoverflow.com/q/21673440
type: Tag
tags question: http://stackoverflow.com/q/21569952
tags question: http://stackoverflow.com/q/21634703
tags question: http://stackoverflow.com/q/21671681
tags question: http://stackoverflow.com/q/21583911
tags question: http://stackoverflow.com/q/21612886
tags question: http://stackoverflow.com/q/21553557
tags question: http://stackoverflow.com/q/21581253
tags question: http://stackoverflow.com/q/21604580
tags question: http://stackoverflow.com/q/21624257
tags question: http://stackoverflow.com/q/21529448
tags question: http://stackoverflow.com/q/21570748
tags question: http://stackoverflow.com/q/21572185
tags question: http://stackoverflow.com/q/21612385
tags question: http://stackoverflow.com/q/21584266
tags question: http://stackoverflow.com/q/21544851
tags question: http://stackoverflow.com/q/21641398
tags question: http://stackoverflow.com/q/21630647
tags question: http://stackoverflow.com/q/21570365
tags question: http://stackoverflow.com/q/21644195
tags question: http://stackoverflow.com/q/21590765
tags question: http://stackoverflow.com/q/21586541
tags question: http://stackoverflow.com/q/21551396
tags question: http://stackoverflow.com/q/21539053
tags question: http://stackoverflow.com/q/21646996
tags question: http://stackoverflow.com/q/21598828
tags question: http://stackoverflow.com/q/21670360
tags question: http://stackoverflow.com/q/21585650
tags question: http://stackoverflow.com/q/21645371
tags question: http://stackoverflow.com/q/21534467
tags question: http://stackoverflow.com/q/21540527
tags question: http://stackoverflow.com/q/21563011
tags question: http://stackoverflow.com/q/21661860
tags question: http://stackoverflow.com/q/21526251
tags question: http://stackoverflow.com/q/21580227
tags question: http://stackoverflow.com/q/21659485
tag name: jdbc
tags question: http://stackoverflow.com/q/21522875
tags question: http://stackoverflow.com/q/21524119
tags question: http://stackoverflow.com/q/21524191
tags question: http://stackoverflow.com/q/21540080
tags question: http://stackoverflow.com/q/21566449
tags question: http://stackoverflow.com/q/21545096
tags question: http://stackoverflow.com/q/21597949
tags question: http://stackoverflow.com/q/21542774

http://stackoverflow.com/a/22339505
has body: I am pretty sure you want to be looking at the PickResult class.. I haven't gotten that far myself yet, but I am pretty sure it is what you're looking for.. good luck! post results!
score: 0
has comment: http://stackoverflow.com/comment/33956550
type: Answer
answers question: http://stackoverflow.com/q/21520346
has comment: http://stackoverflow.com/comment/33956520

http://stackoverflow.com/q/21534986
has comment: http://stackoverflow.com/comment/32518576
favorite count: 0
has answer: http://stackoverflow.com/a/21535090
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32518460
score: 2
has body: I am going to create a model class in my project module. But I am confused what to call my package name for the below type of classes. I don't have to serialize the object to any other stream. I just have to read XML file and verify its data. my model class would be like this public class ModelClassName { //private variables //setters //getters }
upvote count: 2
tagged with: java
has comment: http://stackoverflow.com/comment/32518506
has comment: http://stackoverflow.com/comment/32518864
type: Question
has title: what is the correct name for model class in java
has comment: http://stackoverflow.com/comment/32518731
answer count: 1
downvote count: 0

http://stackoverflow.com/q/21569717
has title: Why they are Using this 'public User getUserById(int userId)'?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21569816
has comment: http://stackoverflow.com/comment/45672233
tagged with: java
tagged with: mysql
downvote count: 1
has comment: http://stackoverflow.com/comment/32580370
has comment: http://stackoverflow.com/comment/45672240
type: Question
score: -1
has comment: http://stackoverflow.com/comment/32581362
accepted answer: http://stackoverflow.com/a/21569816
upvote count: 0
answer count: 1
has comment: http://stackoverflow.com/comment/32580446
favorite count: 0
has comment: http://stackoverflow.com/comment/32580433
has body: I get this program in this site:(http://danielniko.wordpress.com/2012/04/17/simple-crud-using-jsp-servlet-and-mysql/). And my doubt is why they are using this one public User getUserById(int userId) maybe we can live this part, nothing has been change form the output then,why are they using? whats the big deal buddy? any one take me out of this problem,... package com.daniel.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import com.daniel.model.User; import com.daniel.util.DbUtil; public class UserDao { private Connection connection; public UserDao() { connection = DbUtil.getConnection(); } public void addUser(User user) { try { PreparedStatement preparedStatement = connection .prepareStatement("insert into users(firstname,lastname,dob,email) values (?, ?, ?, ? )"); // Parameters start with 1 preparedStatement.setString(1, user.getFirstName()); preparedStatement.setString(2, user.getLastName()); preparedStatement.setDate(3, new java.sql.Date(user.getDob().getTime())); preparedStatement.setString(4, user.getEmail()); preparedStatement.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } } public void deleteUser(int userId) { try { PreparedStatement preparedStatement = connection .prepareStatement("delete from users where userid=?"); // Parameters start with 1 preparedStatement.setInt(1, userId); preparedStatement.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } } public void updateUser(User user) { try { PreparedStatement preparedStatement = connection .prepareStatement("update users set firstname=?, lastname=?, dob=?, email=?" + "where userid=?"); // Parameters start with 1 preparedStatement.setString(1, user.getFirstName()); preparedStatement.setString(2, user.getLastName()); preparedStatement.setDate(3, new java.sql.Date(user.getDob().getTime())); preparedStatement.setString(4, u…

http://stackoverflow.com/comment/32542043
type: AnswerComment
type: Comment
has text: The result should be `t'est*` not `t*est*`. Your solution will replace both `'`
comment on: http://stackoverflow.com/a/21548792
score: 0

http://stackoverflow.com/comment/32546969
type: AnswerComment
has text: It’s an object. It (or one of its helper objects) did create that event instance and so it is specified as the source of the event. It’s really simple. It’s really meaningless. There could be *any* object stored as the event’s source. The reason why a source is provided is because events insist on having a source. I really don’t get what your problem is. Are you trying to add philosophical meaning to the event source?
type: Comment
comment on: http://stackoverflow.com/a/21524246
score: 0

http://stackoverflow.com/q/21564389
has title: Converting String to Date object
has answer: http://stackoverflow.com/a/21564495
answer count: 6
has answer: http://stackoverflow.com/a/21564458
has answer: http://stackoverflow.com/a/21564492
score: 0
has answer: http://stackoverflow.com/a/21564472
has comment: http://stackoverflow.com/comment/32570774
tagged with: android
has comment: http://stackoverflow.com/comment/32570457
accepted answer: http://stackoverflow.com/a/21564458
has body: Am trying to store a date object in Android.I want to get the date as a String from EditText and then "convert" or should i say store it as a Date object.This is what i have done. I have a TextField `EditText dateOfBirthTextField = (EditText) findViewById(R.id.DoBTextField);` and then a String `String dateOfBirth = dateOfBirthTextField.getText().toString();` Now i have a Student class that has a dateOfBirth field of type Date and a method `setDateOfBirth(Date dob){ this.dateOfBirth=dob; } How do i set the value of dateOfBirth with what ever is entered into dateOfBirthTextField?
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21564469
has answer: http://stackoverflow.com/a/21564577
has comment: http://stackoverflow.com/comment/32571081
tagged with: java
has answer: http://stackoverflow.com/a/21564469
linked to: http://stackoverflow.com/q/999172
type: Question
has comment: http://stackoverflow.com/comment/32570473
has comment: http://stackoverflow.com/comment/32571325

http://stackoverflow.com/q/21641264
has comment: http://stackoverflow.com/comment/32706127
score: 0
tagged with: look-and-feel
tagged with: swing
has comment: http://stackoverflow.com/comment/32706047
tagged with: java
type: UnansweredQuestion
has title: Set different look and feel for a component
linked to: http://stackoverflow.com/q/7631085
tagged with: jdatechooser
answer count: 0
has body: I'm making a java application with seaglass look and feel, but I need set the default look and feel for a specific component. The component is a JDateChooser, but with the seaglass LAF this does not display correctly, it displays horribly. How can I set the default look and feel for this component only?
type: Question

http://stackoverflow.com/comment/32719385
comment on: http://stackoverflow.com/a/21641114
score: 0
type: AnswerComment
has text: Add to it just like I said in the answer. You can open it in a terminal with `nano ~/.bash_profile`. Nano hint "writeout" means save".
type: Comment

http://stackoverflow.com/a/21599539
has comment: http://stackoverflow.com/comment/32637511
upvote count: 1
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/32632338
score: 1
answers question: http://stackoverflow.com/q/21599450
has body: The ConcurrentHashMap allows concurrent modification of the Map from several threads without the need to block them. Collections.synchronizedMap(map) creates a blocking Map which will degrade performance, albeit ensure consistency (if used properly). Use the second option if you need to ensure data consistency, and each thread needs to have an up-to-date view of the map. Use the first if performance is critical, and each thread only inserts data to the map, with reads happening less frequently.
has comment: http://stackoverflow.com/comment/32632882

http://stackoverflow.com/q/21593084
has answer: http://stackoverflow.com/a/21596317
tagged with: input
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
accepted answer: http://stackoverflow.com/a/21596317
type: Question
tagged with: libgdx
has comment: http://stackoverflow.com/comment/32628227
has title: Libgdx ( Input) Keypress seems to skip something
answer count: 1
downvote count: 0
tagged with: keyboard
favorite count: 0
has body: Hello once again oh mighty people of the internet! I have decided to go with libGDX for creating a simple memory game to become better at java. I have solved, and tested a lot of things already by myself, but i have come across a problem that i just. can't. figure. out. I have created a complete cluster of if statements to create a menu that has buttons that can be selected by the arrow keys (I couldn't figure out how to make them clickable buttons :P) and it seems to work fine except that it skips one of the buttons which is my high scores button. I will only post the levelSelection Screen class, since that's the one i'm sure the problem is in. The levelSelection Screen class: package com.me.mygdxgame; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.Screen; import com.badlogic.gdx.graphics.GL10; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.SpriteBatch; public class levelSelection implements Screen { private SpriteBatch spriteBatch; private Texture playB; private Texture exitB; private Texture hScoreB; private Texture backGround; MyGdxGame game; private boolean playButton; private boolean quitButton; private boolean highScoresButton; BitmapFont font; public levelSelection(MyGdxGame game) { this.game = game; } public void render(float delta) { Gdx.gl.glClearColor( 0f, 0f, 0f, 1f ); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); spriteBatch.begin(); spriteBatch.draw(backGround, 0, 0); spriteBatch.draw(playB, 250, 450); spriteBatch.draw(exitB, 250, 350); spriteBatch.draw(hScoreB, 250, 400); spriteBatch.end(); //Start Navigation Between menu buttons if(playButton == true &amp;&amp; quitButton == false &amp;&amp; highScoresButton == false &amp;&amp; Gdx.input.isKeyPressed(Input.Keys.DOWN)){ playButton = false; quitButton = false; highScoresButton = true; System.out.println("HighScores button is selected"); } if(highScoresButton == true &amp;&amp; playButton =…

http://stackoverflow.com/comment/32487935
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21517564
has text: and I just want to see what you tried so that i can provide it - have you written any code? It looks like your doing a 2 way conversion text > xml > text - is that correct? you'll need to tokenise your text and parse your xml. Both capabilities are in the standard JDK.

http://stackoverflow.com/comment/32503673
type: Comment
type: QuestionComment
has text: Above code will be select blank space in my browser. And i use Chrome Browser Version 32.0.1700.102. and selenium version is 2.39.0.
comment on: http://stackoverflow.com/q/21522075
score: 0

http://stackoverflow.com/comment/32533043
comment on: http://stackoverflow.com/a/21541694
has text: @user3268146: Oh, geeze. If you haven't learned how to define functions yet, that was a solid try. If you *have* learned how to define functions, you really need to review how to do that. I'm guessing you haven't learned to define functions yet. Let's try it without the function.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/21659447
tagged with: web-services
tagged with: spring
type: AnsweredQuestion
tagged with: java
type: Question
tagged with: javascript
has body: I'm trying to learn about Web services specially those used over SOAP. I love Spring!! I read the tutorial from here! http://docs.spring.io/spring-ws/sites/2.0/reference/html/tutorial.html Already tried some Ajax code but nothing really came out! This soap test message was generated by soapUI and works good! function callsoap() { var soapMessage = '&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"\ xmlns:sch="http://mycompany.com/hr/schemas"&gt;\ &lt;soapenv:Header/&gt;\ &lt;soapenv:Body&gt;\ &lt;sch:HolidayRequest&gt;\ &lt;sch:Holiday&gt;\ &lt;sch:StartDate&gt;2006-07-03&lt;/sch:StartDate&gt;\ &lt;sch:EndDate&gt;2006-07-04&lt;/sch:EndDate&gt;\ &lt;/sch:Holiday&gt;\ &lt;sch:Employee&gt;\ &lt;sch:Number&gt;32&lt;/sch:Number&gt;\ &lt;sch:FirstName&gt;ee&lt;/sch:FirstName&gt;\ &lt;sch:LastName&gt;dd&lt;/sch:LastName&gt;\ &lt;/sch:Employee&gt;\ &lt;/sch:HolidayRequest&gt;\ &lt;/soapenv:Body&gt;\ &lt;/soapenv:Envelope&gt;'; $.ajax( "http://localhost:8080/holidayService/holidayService", { contentType: "application/soap+xml; charset=utf-8", type: "POST", //important dataType: "xml", data: soapMessage }); alert("Called Soap!"); }
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/23197548
accepted answer: http://stackoverflow.com/a/23197548
tagged with: ajax
has title: How to easily test Spring.io Web Service Tutorial Example! with javascript or ajax or

http://stackoverflow.com/q/21545096
has comment: http://stackoverflow.com/comment/32535855
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/21548992
has title: Java - Execute SQL queries only once
upvote count: 1
has comment: http://stackoverflow.com/comment/32535984
has comment: http://stackoverflow.com/comment/32536592
answer count: 1
has comment: http://stackoverflow.com/comment/32536439
tagged with: jdbc
tagged with: spring
has body: I'm developing a J2EE application with Spring framework and MySQL database. I want to execute the SQL script from java (probably with a request mapping) only once. I have store the sql statements in a properties file as a key-value pair and I loop through each key and execute the statement. Connection con = ds.getConnection(); Statement stmt = con.createStatement(); Enumeration enuKeys = properties.keys(); while (enuKeys.hasMoreElements()) { String key = (String) enuKeys.nextElement(); String value = properties.getProperty(key); stmt.execute(value); } Is this the correct way of doing? or is there any other way doing the same? Thanks in advance. Update: As mentioned in the comment, I tried Spring jdbc intialize database but it is not executing all the queries in the sql file. Only the first 'create' query is executed successfully and it throws an execption "Table 'table_name' already exists". Other queries in the .sql file is not executed. This happens every time I run the server. Kindly help
has comment: http://stackoverflow.com/comment/32535695
type: AnsweredQuestion
downvote count: 0
accepted answer: http://stackoverflow.com/a/21548992
tagged with: spring-data
tagged with: mysql
favorite count: 0
has comment: http://stackoverflow.com/comment/32535987
type: Question

http://stackoverflow.com/q/21553008
has answer: http://stackoverflow.com/a/21603956
has comment: http://stackoverflow.com/comment/32591307
favorite count: 0
upvote count: 1
has body: I want to create a communication between my Java web application and SAP. I used Java Connector (JCo) and have put it in library and class path. But when I try to import the package com.sap.mw.jco.*, the program shows a compilation error. I can see that this package is not available in sapjco.jar. The issue I am facing with is, it is not allowing the import statement. This is my code snippet // basic import statements import com.sap.mw.jco.*; public void createSnippet() throws JCoException{ JCO.Client mConnection = JCO.createClient("xx", // SAP client "xx", // userid "xx", // password "xx", // language (null for the default language) "xx", // application server host name "xx"); // system number JCoFunction function = dest.getRepository().getFunction("BAPI_CR"); JCoTable eqptable=function.getTableParameterList().getTable("EQU_LIST"); eqptable.appendRow(); eqptable.setValue("TEST1", "MY_VALUE1"); eqptable.setValue("TEST2", "My_VALUE2"); connection.execute(function); }
has comment: http://stackoverflow.com/comment/32583565
tagged with: jco
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/21603956
has comment: http://stackoverflow.com/comment/32550543
has comment: http://stackoverflow.com/comment/32587132
type: Question
has title: SAP JAVA issue with package installation
downvote count: 0
has comment: http://stackoverflow.com/comment/32580431
has comment: http://stackoverflow.com/comment/32587026
has comment: http://stackoverflow.com/comment/32548941
answer count: 1
has comment: http://stackoverflow.com/comment/32549052
score: 1

http://stackoverflow.com/comment/128683986
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/21601226
type: Comment
has text: The Selector only works with network sockets and pipes, but the question is about files.

http://stackoverflow.com/comment/32686659
has text: A function that takes some arguments that it does not mutate, and returns a new object, is semantically clearer than one that takes many arguments, and mutates some of them. But sometimes you do need to modify an existing object. So it all depends on the problem you are trying to solve.
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21630652

http://stackoverflow.com/comment/32546475
type: AnswerComment
comment on: http://stackoverflow.com/a/21546668
has text: Yes, we got it. Thanks, very very much. I changed my code like this `public AscTaskLogin(Activity activity, LoginActivity mActivity) { this.mActivity = mActivity; }` and call like this `AscTaskLogin LoginTask = new AscTaskLogin(this, this);` it's worked.
score: 0
type: Comment

http://stackoverflow.com/comment/32621431
score: 0
type: AnswerComment
has text: doesn't work either....that just returns an array of size 0. it doesn't enter the try clause, so all it does is initialize an array of length 0 then return that array. I'm telling you man, I'm so confused haha
comment on: http://stackoverflow.com/a/21592856
type: Comment

http://stackoverflow.com/a/21635155
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/21635071
accepted answer of: http://stackoverflow.com/q/21635071
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32694850
has body: The Java compiler knows nothing of the JetBrains attributes like @Contract. IntelliJ may know that doThrow() always throws, but the compiler does not, so this is not well-formed code. In cases like this, I have a utility method that I use: public final class ContractUtilities { public static IllegalStateException unreachable() { return new IllegalStateException("Code is supposed to be unreachable."); } // ... } ...and I add a theoretically unreachable throw statement like so: public int doSomethingElse(final String str) { try { return Integer.parseInt(str); } catch (final NumberFormatException e) { doThrow(); throw ContractUtilities.unreachable(); } } You could also simply make doThrow() return the exception to be thrown: public int doSomethingElse(final String str) { try { return Integer.parseInt(str); } catch (final NumberFormatException e) { throw doThrow(); } }
type: Answer

http://stackoverflow.com/comment/32629204
comment on: http://stackoverflow.com/q/21597416
type: QuestionComment
has text: http://stackoverflow.com/questions/15743529/restore-postgresql-database-using-java has a nice example of what you want and can be easily adjusted to your dump command.
score: 1
type: Comment

http://stackoverflow.com/q/21645849
tagged with: jmc
tagged with: jfr
has title: JMC maxage/maxsize doesn't work
favorite count: 0
possible better answer: http://stackoverflow.com/a/23080287
accepted answer: http://stackoverflow.com/a/22518699
has body: According to JAVA cmd Reference I can set maxage and/or maxsize of JFR recording but it doesn't work. I've shared Intellij IDEA recording and compilation of scala using ant: Stats For idea I had the following settings: -XX:+FlightRecorder -XX:FlightRecorderOptions=defaultrecording=true,disk=true,dumponexit=true,dumponexitpath=/home/ichaki/development/misc/stats/idea,maxage=1h,repository=/home/ichaki/development/misc/stats/idea,settings=profile For ant: -XX:FlightRecorderOptions=defaultrecording=true,disk=true,dumponexit=true,dumponexitpath=/home/ichaki/development/misc/stats/scala-ant,maxage=120s,maxsize=200k,repository=/home/ichaki/development/misc/stats/scala-ant,settings=profile Thanks! Note: I want to make stat collection in envs with SSD's which are quite limited in size
score: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/77274198
upvote count: 2
tagged with: java
type: Question
tagged with: performance
tagged with: intellij-idea
has answer: http://stackoverflow.com/a/22518699
answer count: 3
has answer: http://stackoverflow.com/a/23080287
downvote count: 0

http://stackoverflow.com/comment/32625285
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21595078
has text: @InnocentKiller Check the class ChartDemo in that I am using Array Pass I want to use that array in next class TemperatureChart where I want to receive those values in MAXVALUES array
type: Comment

http://stackoverflow.com/a/21654447
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/32729188
has body: Here is a major problem: int xStart = 0, xEnd = 15, yStart = 0, yEnd = 15; for (int y = yEnd; y &lt;= yStart; y++) { The loop starts with y equal to 15 (yEnd), and continues until y is less-than-or-equal-to 0 (yStart). It will never execute. I don't understand why you would start your loop with yEnd and end with yStart. And why yEnd would be statically assigned to 15. Should yEnd be assigned to the y-value as input by the user?
type: Answer
has comment: http://stackoverflow.com/comment/32728713
has comment: http://stackoverflow.com/comment/32728751
has comment: http://stackoverflow.com/comment/32728990
has comment: http://stackoverflow.com/comment/32728739
upvote count: 1
has comment: http://stackoverflow.com/comment/32729110
answers question: http://stackoverflow.com/q/21654327
has comment: http://stackoverflow.com/comment/32728835

http://stackoverflow.com/a/21661841
type: Answer
has body: @Kayaman is right (+1) However if your recursion is very deep it may be not convenient to count the depth manually. You can use Expressions view instead. Write there expression new Throwable().getStackTrace().length. This will give you your recursion depth + n where n is the number of method calls from main to the beginning of your recursion.
answers question: http://stackoverflow.com/q/21661745
score: 0

http://stackoverflow.com/comment/32566058
score: 1
comment on: http://stackoverflow.com/a/21562106
type: AnswerComment
has text: @SamIam, that wasn't in the requirements as stated. Asking the right question is part of the learning process.
type: Comment

http://stackoverflow.com/q/21622148
tagged with: layout-manager
favorite count: 0
type: Question
has body: I am trying to create a Form in Java with Swing and I'm having difficulty with managing my layouts. I want to have a few text fields with labels in the center of a dialog and have "save" and "close" buttons in the lower right. Adding the buttons to the lower right of the dialog is simple, but I am not sure how to center align the text fields. I figured that, if there wasn't a center component method, then I might be able to align the field by calculating the center of the dialog window and then updating the position when the dialog is re-sized. But I am new to swing and I'm not sure how to do either (or if that is even a good idea). How can I center align my components using the Spring Layout Manager? public class Main { public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { MyFrame myFrame = new MyFrame(); myFrame.setVisible(true); } }); } } Here's how the frame looks: public class MyFrame extends JFrame { JLabel label1; JTextField field1; JLabel label2; JTextField field2; JButton saveButton; JButton closeButton; public MyFrame() { initLookAndFeel(); initFrameProperties(); initContent(); initLayout(); } private initContent() { label1= new JLabel("Label 1"); field1= new JTextField(); label1.setLabelFor(field1); label2= new JLabel("Label 2"); field2= new JTextField(); label2.setLabelFor(field2); saveButton = new JButton("Save"); closeButton = new JButton("Close"); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { System.exit(0); } }); this.add(label1); this.add(field1); this.add(lebel2); this.add(field2); this.add(saveButton); this.add(closeButton); } private void initLayout() { SpringLayout layout = new SpringLayout(); this.setLayout(layout); }
has title: How can I center align a Component with SpringLayout
has comment: http://stackoverflow.com/comment/32671847
has answer: http://stackoverflow.com/a/21623086
upvote count: 2
tagged with: java
answer count: 2
tagged with: swing
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21668829
tagged with: springlayout
has comment: http://stackoverflow.com/comment/32672134
score: 2
downvote count: 0

http://stackoverflow.com/comment/32750299
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/21666363
type: Comment
has text: Very true. Read http://www.oracle.com/technetwork/java/javase/documentation/codeconvtoc-136057.html

http://stackoverflow.com/q/21669988
has title: Hadoop sorting issue (Alternate title: 1175 is not less than 119!)
has comment: http://stackoverflow.com/comment/32755806
score: 1
tagged with: java
upvote count: 1
tagged with: mapreduce
has comment: http://stackoverflow.com/comment/32756004
type: Question
tagged with: hadoop
downvote count: 0
tagged with: sorting
has answer: http://stackoverflow.com/a/21670044
has body: I'm new to Hadoop and done with a typical "count the IP addresses in a log" exercise. Now I'm trying to sort the output by running a second MapReduce job immediately after the first. Almost everything is working, except for the fact that the output collector isn't quite processing the sort the way I'd like. Here's a snippet of my output: -101 71.59.196.132 -115 59.103.11.163 -1175 59.93.51.231 -119 127.0.0.1 -1193 115.186.128.19 -1242 59.93.64.161 -146 192.35.79.70 I can't figure out why, for example, 1175 is considered a lower value than 119. I've tried playing around with Comparators, but it hasn't had any positive effect. The Map and Reduce jobs for the data collection are both standard and non-problematic. They output a list much like the snippet above, but completely unsorted. The SortMap, SortReduce, and Runner classes are a little different. Here's my Runner class: public class Runner { public static void main(String[] args) throws Exception { JobConf conf = new JobConf(Runner.class); JobConf sortStage = new JobConf(Runner.class); conf.setJobName("ip-count"); conf.setMapperClass(IpMapper.class); conf.setMapOutputKeyClass(Text.class); conf.setMapOutputValueClass(IntWritable.class); conf.setOutputKeyClass(Text.class); conf.setOutputValueClass(IntWritable.class); conf.setReducerClass(IpReducer.class); conf.setOutputValueGroupingComparator(IntWritable.Comparator.class); //Input and output from command line... FileInputFormat.setInputPaths(conf, new Path(args[0])); FileOutputFormat.setOutputPath(conf, new Path(args[1])); sortStage.setJobName("sort-stage"); sortStage.setMapperClass(SortMapper.class); sortStage.setMapOutputKeyClass(Text.class); sortStage.setMapOutputValueClass(IntWritable.class); sortStage.setReducerClass(SortReducer.class); sortStage.setOutputKeyClass(IntWritable.class); sortStage.setOutputValueClass(IntWritable.class); //Input and output from command line... FileInputFormat.setInputPaths(sortStage, new Path(args[2])); FileOutputFormat.setOutputPat…
answer count: 1
has comment: http://stackoverflow.com/comment/32755873
favorite count: 0
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/17134341

http://stackoverflow.com/a/21598123
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/21557450
has body: i tried this way , the reason for using callback here is to finish the current activity . and the function startLogin(),in post execute is the function where you can do other work like saving in database or other taks and do not forget to do one thing in startLogin function is to dismiss progress bar like progressDialog.dismiss(); hope this helps :) . private void authenticate(String phoneNumber, String countryCode) { ServerVerify verify = new ServerVerify(this,new TaskCallback() { @Override public void done() { finish(); } }); verify.execute(""); progressDialog = new ProgressDialog(this); progressDialog.setMessage("Registering....."); progressDialog.show(); } public static class ServerVerify extends AsyncTask&lt;Object, Object, Object&gt;{ Context context; private TaskCallback mCallback; private ServerVerify(Context appContext , TaskCallback callback) { context = appContext.getApplicationContext(); mCallback = callback; } @Override protected Object doInBackground(Object... param) { DefaultHttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost(url); List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(4); nameValuePairs.add(new BasicNameValuePair(HTTPConstants.PHONE_NUMBER , phoneNo)); nameValuePairs.add(new BasicNameValuePair(HTTPConstants.OS_VERSION, version)); try { post.setEntity(new UrlEncodedFormEntity(nameValuePairs)); } catch (UnsupportedEncodingException e) { Log.e("UnsupportedEncodingException", "could not load url while registering user"); } HttpResponse response = null; try { response = client.execute(post); } catch (ClientProtocolException e) { Log.e("ClientProtocolException", "Error while registering user"); } catch (IOException e) { Log.e("IOException", "Error while registering user"); } return response; } @Override protected void onProgressUpdate(Object... values) { super.onProgressUpdate(values); } @Override protected void onPostExecute(Object result) { responseJson = Utils.readResponse((HttpResponse)resul…
downvote count: 0
score: 1

http://stackoverflow.com/q/21677212
accepted answer: http://stackoverflow.com/a/21677266
possible better answer: http://stackoverflow.com/a/21677256
has answer: http://stackoverflow.com/a/21677385
has answer: http://stackoverflow.com/a/21677256
favorite count: 0
answer count: 5
has comment: http://stackoverflow.com/comment/32767744
has answer: http://stackoverflow.com/a/78792000
type: AnsweredQuestion
tagged with: netbeans
has answer: http://stackoverflow.com/a/21677261
tagged with: list
has answer: http://stackoverflow.com/a/21677266
tagged with: java
upvote count: 1
downvote count: 1
type: Question
has title: Can't access objects stored in an ArrayList
has body: I created an arraylist. List FWD = new ArrayList&lt;Coords&gt;(); FWD.add(new Coords(42.41, 37.23)); FWD.add(new Coords(37.09, 47.8)); FWD.add(new Coords(36.83, 48.42)); and then I want to access each element of the list in this way: FWD.get(3).[some method from Coords class] but Netbeans says: cannot find symbol symbol: method getIndexX() location: class Object Coords class: public class Coords { private double weightY, indexX; Coords(double x, double y){ setIndexX(x); setWeightY(y); } public double getWeightY() { return weightY; } public void setWeightY(double weightY) { this.weightY = weightY; } public double getIndexX() { return indexX; } public void setIndexX(double indexX) { this.indexX = indexX; } }
score: 0

http://stackoverflow.com/q/21649233
type: Question
has answer: http://stackoverflow.com/a/21655988
downvote count: 1
has body: I don't really know exactly how to explain this but basically the user is asked how many times, say they say 2. It will ask the user to input a month, day and year in numerical form. Then it will do it again because they said 2. It spits out a date in (Saturday, January 8th, 2014) format for each date they put in. So what I want is: There were X dates on Sunday There were X dates on Monday There were X dates on Tuesday There were X dates on Wednesday There were X dates on Thursday There were X dates on Friday There were X dates on Saturday How can I make java recognize the day of week and then add one to it so I can replace X above. I have variables for each day, for example int saturday. I know I have to do saturday++; somewhere but I don't know where. I tried a switch and case but it doesn't know case Monday: because Monday is no where in my code, I used a simple date format. Does this make sense? Should I post my code? Warning its like 300 lines. As Pshemo said "In short, I want the user to say how many "events" occurred, pass their dates and print how many of then happened in each day of week"
has comment: http://stackoverflow.com/comment/32719350
tagged with: java
answer count: 3
accepted answer: http://stackoverflow.com/a/21649278
tagged with: date
has title: Counting days in java
upvote count: 0
has answer: http://stackoverflow.com/a/21649288
possible better answer: http://stackoverflow.com/a/21649288
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21649278
favorite count: 0
score: -1

http://stackoverflow.com/comment/32624836
comment on: http://stackoverflow.com/q/21594611
has text: sorry dude its not possible in webview in all version. It may work in KIT-KAT but not in early versions
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21547126
tagged with: build
tagged with: ant
tagged with: java
tagged with: eclipse
type: Question
has title: How do i write build-main.xml?
has answer: http://stackoverflow.com/a/21549138
answer count: 1
has body: I am new with the ant concept. I want to write the build-main.xml for the project which also include two other projects. Just check the image. how to write build for the main project ant-utilities?
favorite count: 0
upvote count: 3
accepted answer: http://stackoverflow.com/a/21549138
downvote count: 1
type: AnsweredQuestion
score: 2

http://stackoverflow.com/a/39527052
has body: You need 3 for loops: Upper-level loop for the actual number to be repeated and printed first inner level for printing the spaces second inner level for to print the number repeatedly at the end of the Upper-level loop print new line Code: public void printReversedTriangle(int num) { for(int i=0; i&lt;=num; i++) { for(int j=num-i; j&gt;0; j--) { System.out.print(" "); } for(int z=0; z&lt;i; z++) { System.out.print(i); } System.out.println(); } } Output: 1 22 333 4444 55555 666666
downvote count: 0
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/21568210

http://stackoverflow.com/a/21586123
has body: You're adding both the scrollPane (which contains the textArea) and the textArea to your mainPn1: mainPnl.add(titlePnl, BorderLayout.NORTH); mainPnl.add(scrollPane, BorderLayout.CENTER); mainPnl.add(textArea, BorderLayout.CENTER); You should only add the scrollPane: mainPnl.add(titlePnl, BorderLayout.NORTH); mainPnl.add(scrollPane, BorderLayout.CENTER);
upvote count: 4
downvote count: 0
score: 4
has comment: http://stackoverflow.com/comment/32611208
type: Answer
answers question: http://stackoverflow.com/q/21585988

http://stackoverflow.com/comment/32733228
type: Comment
type: QuestionComment
score: 2
has text: ... or just learn how to read and understand compiler errors (which tell you the exact line number that contains the error).
comment on: http://stackoverflow.com/q/21657147

http://stackoverflow.com/comment/32667790
comment on: http://stackoverflow.com/q/21598989
score: 0
type: Comment
has text: JCoFunction function = destinations.getRepository().getFunction("xxx_xxx_xxxx");
type: QuestionComment

http://stackoverflow.com/q/21519007
tagged with: java
has comment: http://stackoverflow.com/comment/32555419
tagged with: union
has body: I am working on a library for extracting outlines of SVG images. Using Batik in Java makes the process of transforming the SVG file into expanded shapes (java.awt.geom.Shape instances) a charm -- for a relatively complex shape we're on the order of milliseconds for this operation. However, as I need a combined outline, I create a java.awt.geom.Area and union each of the shapes using .add(shape). Unexpectedly, this is incredibly slow even for relatively simple shapes. By "incredibly" I mean on the order of 36 seconds to add together 8 shapes of 6-10 points per shape. Running the code with -Xrunhprof hints that a majority of time is spent in java.awt.geom.AreaOp.pruneEdges(..) with java.lang.StrictMath.acos being the biggest culprit. Combining an alternative implementation (AreaX) with FastMath has only yielded insignificant improvements while my search for Java libraries for handling arbitrary geometrical shapes has come up empty. The question then is, what is the way to go about creating a union of shapes in Java without this insane performance penalty? Is there some library or approach that can help the performance of this -- seemingly -- simple operation?
has comment: http://stackoverflow.com/comment/32554448
upvote count: 5
downvote count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32551592
favorite count: 0
tagged with: geometry
has title: Fast union of shapes in Java
type: Question
tagged with: shapes
score: 5
has comment: http://stackoverflow.com/comment/32511561
answer count: 1
has answer: http://stackoverflow.com/a/21861810
has comment: http://stackoverflow.com/comment/32546696

http://stackoverflow.com/comment/35036597
comment on: http://stackoverflow.com/q/21677142
has text: As samthebest pointed out check your memory and cores. I saw same error today and realized my worker had only 64m allocated and the default spark.executor.memory is 512m. It keeps waiting for a worker with available memory. Changing worker memory settings made it work.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32528641
score: 0
has text: Hint: What does `routeNumber = routeNumber % DIVIDE_3DIGIT;` do before you print out the route number?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21540423

http://stackoverflow.com/q/21667387
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21667401
tagged with: java
type: Question
answer count: 2
has body: I know how to call up one class from within another: new frame().setVisible(true); But I don't know how you do this but call up a subroutine on that at the same time e.g new frame().setVisible(true); Sub123();
has title: Is there any method of calling a subroutine or function within a newly opened frame? Java
tagged with: subroutine
has answer: http://stackoverflow.com/a/21667398
accepted answer: http://stackoverflow.com/a/21667398
favorite count: 0
score: 0
upvote count: 1
tagged with: swing
downvote count: 1
possible better answer: http://stackoverflow.com/a/21667401

http://stackoverflow.com/a/21615110
upvote count: 3
has comment: http://stackoverflow.com/comment/32661887
has comment: http://stackoverflow.com/comment/32661801
has comment: http://stackoverflow.com/comment/32662584
accepted answer of: http://stackoverflow.com/q/21613204
has body: OK, here's my answer, which should be O(N*N) worst case. (With smaller constant, since even worstcase I'm testing N against -- on average -- 1/2 N, but this is computer science rather than software engineering and a mere 2X speedup isn't significant. Thanks to @Alexandru for pointing that out.) 1) Split cursor (input and output advanced separately), 2) Each new value only has to be compared to what's already been kept, and compare can stop if a match is found. (The hint keyword was "incremental") 3) First element need not be tested. 4) I'm taking advantage of labelled continue where I could have instead set a flag before breaking and then tested the flag. Comes out to the same thing; this is a bit more elegant. 4.5) I could have tested whether outsize==consider and not copied if that was true. But testing for it would take about as many cycles as doing the possibly-unnecessary copy, and the majority case is that they will not be the same, so it's easier to just let a possibly redundant copy take place. 5) I'm not recopying the data in the key function; I've factored out the copy-for-printing operation to a separate function to make clear that removeDupes does run entirely in the target array plus a few automatic variables on the stack. And I'm not spending time zeroing out the leftover elements at the end of the array; that may be wasted work (as in this case). Though I don't think it would actually change the formal complexity. import java.util.Arrays; public class RemoveDupes { private static int removeDupes(final int[] array) { if(array.length &lt; 2) return array.length; int outsize=1; // first is always kept outerloop: for (int consider = 1; consider &lt; array.length; ++consider) { for(int compare=0;compare&lt;outsize;++compare) if(array[consider]==array[compare]) continue outerloop; // already present; advance to next compare // if we get here, we know it's new so append it to output array[outsize++]=array[consider]; // could test first, not worth it. } retur…
downvote count: 0
has comment: http://stackoverflow.com/comment/32661715
has comment: http://stackoverflow.com/comment/32661490
has comment: http://stackoverflow.com/comment/32662208
has comment: http://stackoverflow.com/comment/32662984
has comment: http://stackoverflow.com/comment/32662619
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32662947
has comment: http://stackoverflow.com/comment/32662755
answers question: http://stackoverflow.com/q/21613204
has comment: http://stackoverflow.com/comment/32661411
has comment: http://stackoverflow.com/comment/32661716
has comment: http://stackoverflow.com/comment/32663292
has comment: http://stackoverflow.com/comment/32661912
has comment: http://stackoverflow.com/comment/32684742
type: Answer
has comment: http://stackoverflow.com/comment/32663166
has comment: http://stackoverflow.com/comment/32662306
has comment: http://stackoverflow.com/comment/32662346
score: 3
has comment: http://stackoverflow.com/comment/32661573
has comment: http://stackoverflow.com/comment/32669245

http://stackoverflow.com/comment/32871876
comment on: http://stackoverflow.com/a/21696422
has text: @prassee: That should be enough. Is this memory listed as free or used? It may help to click individual workers and check the logs.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/32726129
type: AnswerComment
type: Comment
has text: I didn't say it was the correct thing to do, I just said it was the easiest fix possible. Having a separate thread update the object position is of course better.
comment on: http://stackoverflow.com/a/21652980
score: 0

http://stackoverflow.com/comment/32722218
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21650925
has text: To be clear, before this question disappears, _all_ Java `Object`s possess an `equals` method, and therefore `String` does as well. Whether or not it is implemented appropriately is a different story though (for `String` it is implemented correctly!).
score: 0

http://stackoverflow.com/comment/32582345
comment on: http://stackoverflow.com/q/21570972
has text: Yes I am saving the salt as well. I am getting different values from database only.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21581829
has comment: http://stackoverflow.com/comment/102764764
upvote count: 30
accepted answer of: http://stackoverflow.com/q/21577407
has body: It looks like as of version 2.3.17 you can use: ${myDate?long?c} http://sourceforge.net/p/freemarker/feature-requests/72/
has comment: http://stackoverflow.com/comment/120018814
answers question: http://stackoverflow.com/q/21577407
has comment: http://stackoverflow.com/comment/32601763
type: AcceptedAnswer
score: 30
type: Answer
has comment: http://stackoverflow.com/comment/104416637
downvote count: 0

http://stackoverflow.com/q/21530849
type: AnsweredQuestion
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32516032
has title: setOnTouchListener and setOnItemLongClickListener mutually exclusive?
type: Question
answer count: 1
downvote count: 0
has answer: http://stackoverflow.com/a/21533852
favorite count: 0
has comment: http://stackoverflow.com/comment/32511783
tagged with: android
has comment: http://stackoverflow.com/comment/32516409
accepted answer: http://stackoverflow.com/a/21533852
has body: In the code below, onItemLongClick works only when I comment out the onTouchListener. I need to be able to register swipes as well as long clicks. What am I doing wrong? public class MainPageActivity extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { ... getListView().setLongClickable(true); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { Toast.makeText(getApplicationContext(), "long click", Toast.LENGTH_SHORT).show(); return true; } }); getListView().setOnTouchListener(new OnSwipeTouchListener() { public void onSwipeBottom() { Toast.makeText(MainPageActivity.this, "bottom", Toast.LENGTH_SHORT).show(); } }); } }
has comment: http://stackoverflow.com/comment/32511245
upvote count: 1
has comment: http://stackoverflow.com/comment/32511909

http://stackoverflow.com/comment/32574756
type: QuestionComment
has text: It would be helpful if you explained how you "set your background to white." Do you clear the color buffer, do you draw a fullscreen quad with `glColor3f (...)`, do you set the color in the texture? There are a number of possible causes ranging from the benign (forgetting to reset the current color) to something more complicated like the incorrect application of pre-multiplied alpha in your blend function.
comment on: http://stackoverflow.com/q/21565778
score: 0
type: Comment

http://stackoverflow.com/comment/32681960
type: Comment
comment on: http://stackoverflow.com/q/21627546
has text: Have you checked your firewall on winodws 7 desktop ?Make sure mqtt allow for connection on public and private network.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/32630790
type: Comment
type: QuestionComment
score: 1
has text: possible duplicate of http://stackoverflow.com/questions/1090311/are-volatile-variable-reads-as-fast-as-normal-reads
comment on: http://stackoverflow.com/q/21598558

security
tags question: http://stackoverflow.com/q/21633948
tags question: http://stackoverflow.com/q/21583395
tags question: http://stackoverflow.com/q/21607087
tags question: http://stackoverflow.com/q/21604938
tags question: http://stackoverflow.com/q/21579129
tags question: http://stackoverflow.com/q/21582007
tags question: http://stackoverflow.com/q/21564354
tags question: http://stackoverflow.com/q/21564363
tags question: http://stackoverflow.com/q/21529597
tags question: http://stackoverflow.com/q/21661515
tags question: http://stackoverflow.com/q/21646688
tags question: http://stackoverflow.com/q/21630458
tags question: http://stackoverflow.com/q/21664387
tags question: http://stackoverflow.com/q/21539712
tags question: http://stackoverflow.com/q/21636566
tags question: http://stackoverflow.com/q/21633162
tags question: http://stackoverflow.com/q/21551391
tags question: http://stackoverflow.com/q/21522831
tags question: http://stackoverflow.com/q/21532166
type: Tag
tag name: security

http://stackoverflow.com/a/21644762
score: 11
has comment: http://stackoverflow.com/comment/32711538
has comment: http://stackoverflow.com/comment/32712063
upvote count: 11
has comment: http://stackoverflow.com/comment/32711522
has comment: http://stackoverflow.com/comment/32712177
has comment: http://stackoverflow.com/comment/32711520
has comment: http://stackoverflow.com/comment/32711840
has comment: http://stackoverflow.com/comment/32711943
has comment: http://stackoverflow.com/comment/32711915
has comment: http://stackoverflow.com/comment/32711875
has comment: http://stackoverflow.com/comment/32711529
answers question: http://stackoverflow.com/q/21644741
has comment: http://stackoverflow.com/comment/32711601
has comment: http://stackoverflow.com/comment/32712408
has comment: http://stackoverflow.com/comment/32711783
has comment: http://stackoverflow.com/comment/32712445
has comment: http://stackoverflow.com/comment/32712205
downvote count: 0
has comment: http://stackoverflow.com/comment/32711665
has comment: http://stackoverflow.com/comment/32712145
has comment: http://stackoverflow.com/comment/32711850
has body: The issue is with the string comparison using == instead of equals. == compares the references, which are very unlikely to be equal. Change to if(grade.equals("A")){ totalGradePoints += 4; numClasses++; }else if(grade.equals("B")){ ... and it should work. See this answer for a detailed explanation. As a good practice it is advisable to always use the static string as the object for calling equals on to prevent a NPE: if("A".equals(grade)){ totalGradePoints += 4; numClasses++; }else if("B".equals(grade)){ ... If you are using Java 7, you can also do a switch statement with strings (though this one will throw an NPE if grade is null): switch(grade) { case "A": totalGradePoints += 2; numClasses++; break; case "B": ... } And finally, since you are converting only one letter to an integer, to best solution is to convert them to char and for the values between A and D to do totalGradePoints += ('D' - grade.charAt(1)) + 1. So something along those lines would be simplest to read IMO: while (true) { final String input = in.next(); if(input == null || input.isEmpty()) break; final char grade = input.charAt(0); if(grade &gt;= 'A' &amp;&amp; grade &lt;= 'D') { totalGradePoints += ('D' - grade) + 1; } else if(grade == 'F') { // no gradepoints for 'F' } else { break; } //end if - else-if - else statement ++numClasses; } //end while loop
has comment: http://stackoverflow.com/comment/32711871
type: Answer

http://stackoverflow.com/comment/32980270
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21559984
score: 0
has text: @ntalbs i edit my question so how can i get out from ban

http://stackoverflow.com/comment/32559256
type: QuestionComment
has text: I got the Idea from @Sajal. I don't fully understand it myself but it only seems to work partially. Only the last element from my arraylist is printed out as oppose to the entire list. There is a link on the comments to his answer below if you want to have a look.
comment on: http://stackoverflow.com/q/21554109
score: 0
type: Comment

http://stackoverflow.com/a/21577489
has body: I think, the following code should work: return hundreds[i / 100] + tens[(i % 100) / 10] + ones[i % 10];
type: Answer
accepted answer of: http://stackoverflow.com/q/21577377
has comment: http://stackoverflow.com/comment/32594194
answers question: http://stackoverflow.com/q/21577377
has comment: http://stackoverflow.com/comment/32594015
has comment: http://stackoverflow.com/comment/32593978
score: 0
has comment: http://stackoverflow.com/comment/32593381
type: AcceptedAnswer

http://stackoverflow.com/comment/32684817
comment on: http://stackoverflow.com/q/21629794
score: 3
has text: Create the list once, and an Employee object every time you want a new Employee.
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21672049
downvote count: 1
type: UnansweredQuestion
tagged with: sorting
has title: How to save the sorting result to model
tagged with: jtable
has answer: http://stackoverflow.com/a/21679316
favorite count: 0
type: Question
has comment: http://stackoverflow.com/comment/32771077
score: 0
tagged with: java
tagged with: save
upvote count: 1
has body: I create a JTable in one frame. It shows the data from MyModel. Now when I click the header of column, it will do sorting. It works fine. But when I close this frame, and open it again. The data in this table is shown as the original order in MyModel. Now I want to save the sorting result when I close the frame. Should I update the MyModel with the new order data or save sorting on which column and which order (ASCENDING or DESCENDING). How to implement this? Thanks!
tagged with: swing
answer count: 1

http://stackoverflow.com/q/21597600
answer count: 2
has comment: http://stackoverflow.com/comment/32630600
has comment: http://stackoverflow.com/comment/32632344
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32632144
tagged with: android
tagged with: input
has comment: http://stackoverflow.com/comment/32629468
tagged with: android-activity
has comment: http://stackoverflow.com/comment/32634223
has comment: http://stackoverflow.com/comment/32629421
has comment: http://stackoverflow.com/comment/32629229
has answer: http://stackoverflow.com/a/21597899
has answer: http://stackoverflow.com/a/21597800
type: Question
has body: I am a completely new programmer and I am looking to make a sort of quiz app as my first app. Just Questions with the right answer that will send the user to the next activity. I figured out how to edit buttons but I am not sure what to add to the JAVA file or XML file that will allow the next activity (screen) to be opened up. This is my Layout so far. I have decided the password input but the answer to the question will be stored within the app. Not sure if this is the right approach? ` &lt;TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Question" /&gt; &lt;EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textView1" android:layout_centerHorizontal="true" android:layout_marginTop="78dp" android:ems="10" android:inputType="textPassword" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textView1" android:layout_centerHorizontal="true" android:text="Answer" /&gt; ` Thanks in advance for any help rendered! @kanwaljit Sngh I am getting multiple errors like "button cannot be resolved to a type" and "R cannot be resolved to a variable" What does these mean? `import android.os.Bundle; import android.app.Activity; import android.view.Menu; public class Startscreen extends Activity { EditText editText1 = (EditText) findViewById(R.id.editText1); Button btn = (Button) findViewById(R.id.button); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub String answer = editText1.getText().toString().trim(); if (answer.equals("desired answer")) { Intent i = new Intent(getApplicationContext(), CorrectAnswerActivity.class); startActivity(i); } else { Intent i = new Intent(getApplicationContext(), WrongAnswerActivity.class); startActivity(i); } } }); `
tagged with: passwords
tagged with: java
has title: correct text input to next activity
score: 0

http://stackoverflow.com/q/21593045
tagged with: keyboard
tagged with: linux
has body: I am trying to differentiate input between two keyboards that are connected to the computer. My java program needs to be able to distinguish between the two. The original solution was to simply have one keyboard with caps-lock enabled while the other is not. This worked perfectly when testing on Mac OSX. However when I attempted to run the same program on Ubuntu, I notice that turning caps-lock on enables it for all connected keyboards. I can no longer distinguish between the two. Any suggestions?
type: Question
score: 0
tagged with: java
answer count: 1
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21593114
has title: Distinguish between Two USB Connected Keyboards using [Caps-Lock]
tagged with: macos

http://stackoverflow.com/a/21538287
accepted answer of: http://stackoverflow.com/q/21538202
type: Answer
answers question: http://stackoverflow.com/q/21538202
has body: Captive portals generally will intercept users' HTTP requests and issue a "fake" redirect to the portal's authentication page. Or they can simply replace the actual response with the login page. If yours is a redirect-to-login, then simply do something like trying to load http://google.com, which can reasonably be expected to be truly available for at least the next few years. If the response comes in as a redirect to some totally different site, the redirect url is highly likely to be the portal's login page. If it's a replace-the-response-with-login, then you should try to contact a known page with some known content, and see what you get back. if the response you got doesn't match you should have gotten, then you've gotten the login page and can try tearing apart the response and finding the login form via DOM operations.
upvote count: 1
has comment: http://stackoverflow.com/comment/91598516
type: AcceptedAnswer
downvote count: 0
score: 1

http://stackoverflow.com/comment/32614690
type: Comment
comment on: http://stackoverflow.com/a/21580915
score: 0
type: AnswerComment
has text: I've included a short example with a generator, and also added a link to a tutorial about Cocoon generators. I hope they will help! :) Regards

minecraft
tags question: http://stackoverflow.com/q/21521907
tags question: http://stackoverflow.com/q/21514927
type: Tag
tags question: http://stackoverflow.com/q/21551998
tags question: http://stackoverflow.com/q/21520673
tag name: minecraft

http://stackoverflow.com/comment/32541703
comment on: http://stackoverflow.com/a/21548594
type: Comment
has text: it is replacing it but if i have a String a = "1+2*cos(32)+2*tan(40)+ln(3)"; it replaces String a = "1+2*cos(3*2)+2*tan(4*0)+ln(3)"; ??
score: 1
type: AnswerComment

http://stackoverflow.com/q/21650153
tagged with: java
has body: I'm having the error with class not found exception whenever I try to call getConnection from ProductDataBean. Here's the code: Product.java ProductDataBean pdb = new ProductDataBean(); Connection connect = pdb.getConnection(); // ClassNotFoundException on this line) ProductDataBean.java package cart; import java.io.*; import java.sql.*; import java.util.*; public class ProductDataBean implements Serializable{ public static Connection getConnection() throws ClassNotFoundException, SQLException{ Class.forName("com.mysql.jdbc.Driver"); String connURL ="jdbc:mysql://localhost/onlinecart?user=root&amp;password=teck1577130713"; Connection conn = DriverManager.getConnection(connURL); return conn; } } I will be thankful if u can help me solve this problem! :)
has comment: http://stackoverflow.com/comment/32721999
has comment: http://stackoverflow.com/comment/32722164
type: Question
has comment: http://stackoverflow.com/comment/32721624
has comment: http://stackoverflow.com/comment/32721988
accepted answer: http://stackoverflow.com/a/21651003
has comment: http://stackoverflow.com/comment/32722089
has comment: http://stackoverflow.com/comment/32722005
score: 0
tagged with: classnotfoundexception
answer count: 1
tagged with: connection
has comment: http://stackoverflow.com/comment/32722021
has title: MySql getConnection.Exception, Class com.mysql.jdbc.Driver Not found
has comment: http://stackoverflow.com/comment/32722199
tagged with: exception
has comment: http://stackoverflow.com/comment/32721994
has answer: http://stackoverflow.com/a/21651003
tagged with: model-view-controller
has comment: http://stackoverflow.com/comment/32721506
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32721098

http://stackoverflow.com/comment/32743341
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21662787
type: Comment
has text: You have imported the class file incorrectly otherwise there was no need to provide the complete path of a class file in your 3rd line :- ((javax.persistence.Query) query).setParameter("userName", user.getUsername());

http://stackoverflow.com/comment/38561455
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21649085
has text: does it work i mean in hotmail do you appear as website i did this and both my personal and domain email were showing up

http://stackoverflow.com/q/21644457
tagged with: selenium-webdriver
type: AnsweredQuestion
has title: Populating Excel file with poi and Loop
tagged with: java
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/21649947
answer count: 2
has answer: http://stackoverflow.com/a/21644544
downvote count: 0
score: 1
favorite count: 0
possible better answer: http://stackoverflow.com/a/21644544
tagged with: apache-poi
has body: I am new to DDT and I am trying to write my test results in an excel file. It is a simple code which takes values from a ListArray and sends them to google.translate, it then capture the results and add them to another List. When I loop through the list containing the results it only displays the last result captured, what am I doing wrong with my code? I understand I am wrongly looping through but I just cant figured it out Any help will be much appreciated. Here is the entire Code public class writeFileOutPut { WebDriver driver; WebElement element; String baseUrl = "http://translate.google.com/"; @BeforeSuite public void beforeSuite() { driver = new FirefoxDriver(); driver.get(baseUrl); } @Test public void f() throws Exception{ List&lt;String&gt; sourceWords = new ArrayList&lt;String&gt;(); sourceWords.add("house"); sourceWords.add("car"); sourceWords.add("bed"); int listLength = sourceWords.size(); System.out.println("Array length is " + sourceWords.size()); for(String temp : sourceWords){ driver.findElement(By.id("gt-tl-gms")).click(); driver.findElement(By.xpath("/html/body/div[12]/table/tbody/tr/td[4]/div/div[7]/div")).click(); driver.findElement(By.id("source")).sendKeys(temp); Thread.sleep(1000); String transRes = driver.findElement(By.id("result_box")).getText(); List&lt;String&gt; transWords = new ArrayList&lt;String&gt;(); transWords.add(transRes); System.out.println(transWords); driver.findElement(By.id("source")).clear(); HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet worksheet = workbook.createSheet("POI WorkSheet"); for(int i=0; i&lt;listLength; i++){ HSSFRow row = worksheet.createRow(i); HSSFCell cell = row.createCell(0); cell.setCellValue(transRes); } FileOutputStream fos = new FileOutputStream("My/writeDataTest3.xls"); workbook.write(fos); fos.close(); } } @AfterSuite public void afterSuite() { driver.quit(); } }
tagged with: excel
accepted answer: http://stackoverflow.com/a/21649947

http://stackoverflow.com/q/21603629
tagged with: android
accepted answer: http://stackoverflow.com/a/21615005
tagged with: socket-timeout-exception
favorite count: 0
tagged with: serversocket
score: 0
upvote count: 1
answer count: 1
has comment: http://stackoverflow.com/comment/32640759
downvote count: 1
has body: I am trying to get an instance of Socket from ServerSocket Object. But, it always prints SocketTimeoutException = null There is my code: try { // We listen for new connections Log.d("ShairPort", "Service &gt;&gt; In TRY "); try { servSock = new ServerSocket(port); } catch (IOException e) { Log.d("ShairPort", "Service &gt;&gt; In TRY # IO Exception = " +e.getMessage()); servSock = new ServerSocket(); }catch(Exception e) { Log.d("ShairPort", "Service &gt;&gt; In TRY # E xception = " +e.getMessage()); } // DNS Emitter (Bonjour) byte[] hwAddr = getHardwareAdress(); emitter = new BonjourEmitter(name, getStringHardwareAdress(hwAddr), port); //Setting Timeout servSock.setSoTimeout(10000); Log.d("ShairPort", "Service &gt;&gt; stopThread = " +stopThread); while (!stopThread) { try { //********** This is throwing Exception ***************// Socket socket = servSock.accept(); servSock.setReuseAddress(true); Log.d("ShairPort", "Service &gt;&gt; got connection from " + socket.toString()); new RTSPResponder(hwAddr, socket).start(); } catch(SocketTimeoutException e) { e.printStackTrace(); Log.d("ShairPort", "Service &gt;&gt; SocketTimeoutException = " + e.getMessage()); //********* here I am getting exception **************// }catch(Exception e) { Log.d("ShairPort", "Service &gt;&gt; Exception = " + e.getMessage()); servSock.close(); } } } catch (IOException e) { Log.d("ShairPort", "Service &gt;&gt; TRY # CATCH IOException = " + e.getMessage()); throw new RuntimeException(e); } Please let me know if I am doing anything wrong, so that I can resolve this issue. 02-06 18:14:08.300: W/System.err(2245): java.net.SocketTimeoutException 02-06 18:14:08.300: W/System.err(2245): at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:108) 02-06 18:14:08.300: W/System.err(2245): at java.net.ServerSocket.implAccept(ServerSocket.java:203) 02-06 18:14:08.310: W/System.err(2245): at java.net.ServerSocket.accept(ServerSocket.java:128) 02-06 18:14:08.310: W/System.err(2245): at vavi.apps.shairport…
tagged with: java
has comment: http://stackoverflow.com/comment/32639764
has title: ServerSocket.accept() throwing SocketTimeoutException with null message
has answer: http://stackoverflow.com/a/21615005
has comment: http://stackoverflow.com/comment/32639867
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32641022
type: Question
has comment: http://stackoverflow.com/comment/54034585
tagged with: sockets

http://stackoverflow.com/a/21667815
upvote count: 2
answers question: http://stackoverflow.com/q/21666357
has comment: http://stackoverflow.com/comment/32766977
downvote count: 0
has body: The other answers are correct. I'll add a few thoughts. Defaults Are Tricky Probably the most common source of trouble in date-time work is inadvertently relying on: Default time zone Default locale I've come to the conclusion that both should be specified in all my code, as a habit. I don't want my code changing its behavior (or breaking, as in your case) if it happens to be run with a different time zone or locale setting. The only case where date-time code should use the default is when you truly want to detect and utilize the user's (the JVM's) own settings for localization. And even in this case, I explicitly make a call to retrieve and use the default rather than rely on the implicit default, so as to make my code obvious and self-documenting. DateTimeZone.getDefault() java.util.Locale.getDefault() Joda-Time As a commenter said, minimizing your imports is indeed a queer goal. Especially with java.util.Calendar and java.util.Date – If ever there were a case for imports it would be those two classes. They are notoriously troublesome, and should be avoided. Use Joda-Time. Or, in Java 8, use the bundled new java.time.* package, inspired by Joda-Time, defined by JSR 310. Note that in Joda-Time, a DateTime object truly knows its own assigned time zone. That's a big contrast to java.util.Date which has no assigned time zone but its toString applies the JVM's default time zone which leads to much confusion. Here is some example code in Joda-Time 2.3. String input = "Sun Feb 09 22:49:36 +0000 2014"; DateTimeZone timeZone = DateTimeZone.forID( "America/Montreal" ); DateTimeFormatter formatter = DateTimeFormat.forPattern( "EEE MMM dd HH:mm:ss Z yyyy" ).withLocale( Locale.ENGLISH ).withZone( timeZone ); DateTime dateTime = formatter.parseDateTime( input ); Dump to console… System.out.println( "dateTime: " + dateTime ); System.out.println( "Same dateTime in UTC/GMT: " + dateTime.withZone( DateTimeZone.UTC ) ); When run… dateTime: 2014-02-09T17:49:36.000-05:00 Same dateTime…
type: Answer
has comment: http://stackoverflow.com/comment/32763966
score: 2

jxl
tags question: http://stackoverflow.com/q/21520184
tags question: http://stackoverflow.com/q/21537993
type: Tag
tag name: jxl

http://stackoverflow.com/comment/32606994
comment on: http://stackoverflow.com/a/21584798
type: Comment
has text: Also, there isn't a constructor... it's in `main`.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32683027
comment on: http://stackoverflow.com/q/21624035
type: Comment
has text: I just tryed to parse it as X509Certificate. I got object from binary data, and execute method certx509.getSubjectDN(), but it also return me such String: EMAILADDRESS=kokleva@klg.grinn-corp.ru, CN=Êîêëåâà Òàòüÿíà Âèêòîðîâíà, T=Áóõãàëòåð ïî çàðïëàòå
score: 0
type: QuestionComment

http://stackoverflow.com/q/21608863
downvote count: 0
tagged with: jsp
tagged with: struts2
has answer: http://stackoverflow.com/a/27874432
answer count: 1
has body: I could found an error in my code,kindly help me what mistake i have done below. Build.xml <?xml version="1.0" encoding="UTF-8"?> struts2 org.apache.struts2.dispatcher.FilterDispatcher struts2 /* /index.jsp index.jsp <s:form action="verify"> <s:textfield name="uname" label="Enter Username"/> <s:textfield name="pass" label="Enter the Password"/> <s:submit value="Click" align="center" /> </s:form> Exception org.apache.jasper.JasperException: The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location] org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
favorite count: 0
type: UnansweredQuestion
upvote count: 1
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32658438
type: Question
has comment: http://stackoverflow.com/comment/32650772
has title: The Struts dispatcher cannot be found

http://stackoverflow.com/q/21663766
tagged with: java
has body: public static void checkSolution(double[][] matrix, double[] vector) { HashSet&lt;Double&gt; arraySet = new HashSet&lt;Double&gt;(); for (int line = 0; line &lt; matrix.length; line++) { arraySet.clear(); for (int column = 0; column &lt; matrix[line].length; column++) { arraySet.add(matrix[line][column]); } if ((arraySet.size() == 1) &amp;&amp; (arraySet.contains(0.0))) { throw new RuntimeException("Oups"); } } } I want to check if the elements of each row are the same (in this example 0). I came up with the idea to put each element in an HashSet because it doesnt allow double entries. But it does not work. I clear the HashSet after each row. Is there any logical mistake? Edit: Whole code: class Main { public static void main(String [] args) { double[][] A = new double[3][3]; double[] b = new double[3]; A[0][0] = 3; A[0][1] = -1; A[0][2] = 2; b[0] = 1; A[1][0] = 7; A[1][1] = -4; A[1][2] = -1; b[1] = -2; A[2][0] = -1; A[2][1] = -3; A[2][2] = -12; b[2] = -5; solveEquation(A, b); } public static double[] solveEquation(double[][] matrix, double [] vector) { int counter = 1; double pivot; System.out.println("LGS: "); System.out.println("--------------------------------"); printMatrix(matrix); printVector(vector); for (int line = 0; line &lt; matrix.length; line++) { for (int column = 0; column &lt; matrix[line].length; column++) { if (line == column) { pivot = matrix[line][column]; //setting pivot element while (pivot == 0) //testing if pivot is equal to zero; if thats the case we have to swap lines { int secLine = line + counter; if (secLine &lt; matrix.length) { swapLines(line, secLine, matrix, vector); counter++; }else if (!(secLine &lt; matrix.length)) //necessary? { checkSolution(matrix, vector); } pivot = matrix[line][column]; //override pivot with the new element because lines have switched } //normalizing the pivot row for (int elementAdjustment = 0; elementAdjustment &lt; matrix[line].length; elementAdjustment++) { matrix[line][elementAdjustment] = matrix[line][…
has answer: http://stackoverflow.com/a/21663811
type: Question
has comment: http://stackoverflow.com/comment/32745175
has comment: http://stackoverflow.com/comment/32745187
has comment: http://stackoverflow.com/comment/32744969
tagged with: arrays
answer count: 1
downvote count: 0
tagged with: hashset
favorite count: 0
has title: Java: Array: check row elements
accepted answer: http://stackoverflow.com/a/21663811
upvote count: 3
has comment: http://stackoverflow.com/comment/32745131
type: AnsweredQuestion
score: 3

http://stackoverflow.com/comment/46314855
comment on: http://stackoverflow.com/q/21596106
score: 0
has text: Could you provide html code of this part of page, I have some ideas to improve your code, but need more details
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32723425
type: AnswerComment
comment on: http://stackoverflow.com/a/21651591
type: Comment
has text: Not where I go to school.
score: 0

http://stackoverflow.com/comment/32765070
has text: Thats probably what hes trying to do. +1. Allthough i dont see how it differs from `getAllTasks` , since he calls that on every location
type: Comment
comment on: http://stackoverflow.com/a/21675669
score: 0
type: AnswerComment

http://stackoverflow.com/a/21626559
has comment: http://stackoverflow.com/comment/32762152
has body: Change your url to : jdbc:mysql://192.168.1.5:3306/ And your database name to atrics instead of test. HTH. Check out http://itsolutionsforall.com/eclipse_sql.php
answers question: http://stackoverflow.com/q/21625994
type: Answer
has comment: http://stackoverflow.com/comment/32756110
type: AcceptedAnswer
score: 0
has comment: http://stackoverflow.com/comment/32679367
accepted answer of: http://stackoverflow.com/q/21625994

http://stackoverflow.com/a/21578389
downvote count: 9
has comment: http://stackoverflow.com/comment/32595742
type: Answer
has body: Just add @RequestBody annotation before this param
answers question: http://stackoverflow.com/q/21577782
upvote count: 3
score: -6
has comment: http://stackoverflow.com/comment/32599113

http://stackoverflow.com/a/21581495
has comment: http://stackoverflow.com/comment/32604708
accepted answer of: http://stackoverflow.com/q/21576065
downvote count: 0
upvote count: 8
type: AcceptedAnswer
has body: Here is the fixed version of your code. Also it compiles and even does something! import java.lang.reflect.{Method, InvocationHandler, Proxy} object ProxyTesting { class ProxyInvocationHandler extends InvocationHandler { def invoke(proxy: scala.AnyRef, method: Method, args: Array[AnyRef]): AnyRef = { println("Hello Stackoverflow when invoking method with name \"%s\"".format(method.getName)) proxy } } trait Iface { def doNothing() } def main(args: Array[String]) { val handler = new ProxyInvocationHandler val impl = Proxy.newProxyInstance( classOf[Iface].getClassLoader, Array(classOf[Iface]), handler ).asInstanceOf[Iface] impl.doNothing() } }
type: Answer
score: 8
answers question: http://stackoverflow.com/q/21576065

http://stackoverflow.com/a/21545822
has comment: http://stackoverflow.com/comment/32537410
downvote count: 0
has body: public static String reverse1(int number){ if (number == 1){ return "1"; } else { return number + ", " + reverse1(number - 1); } } The trick with recursion is - in my opinion - always to search the trivial case. So here the easiest input is 1 and the result would be "1" reverse1(1) = "1"; And then you need that "strange" recursion step where you reduce your input towards that trivial case. reverse1(n) = n, reverse(n-1) Here you just say: The result of a number n is always the result of "this number minus 1" with that extra number n in front. Think about it, its quite logical. It's sometimes not easy to think of a problem in that "recursive way". But often it makes things alot easier.
accepted answer of: http://stackoverflow.com/q/21545787
type: Answer
answers question: http://stackoverflow.com/q/21545787
has comment: http://stackoverflow.com/comment/32537039
score: 5
upvote count: 5
type: AcceptedAnswer

http://stackoverflow.com/comment/32779346
comment on: http://stackoverflow.com/q/21673017
has text: It looks like a IDE, or anything also, cant properly recognize UiBinder. But in another class, that use UiBinder and gin too, there is no errors.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32686071
comment on: http://stackoverflow.com/q/21630389
type: Comment
score: 0
has text: `instance` is a reserved word. Don't use it as a variable name.
type: QuestionComment

sql
tags question: http://stackoverflow.com/q/21592224
tags question: http://stackoverflow.com/q/21533072
tags question: http://stackoverflow.com/q/21607842
tags question: http://stackoverflow.com/q/21564231
tags question: http://stackoverflow.com/q/21615956
tags question: http://stackoverflow.com/q/21634896
tags question: http://stackoverflow.com/q/21603598
tags question: http://stackoverflow.com/q/21629463
tags question: http://stackoverflow.com/q/21651671
tags question: http://stackoverflow.com/q/21591328
tags question: http://stackoverflow.com/q/21662787
tags question: http://stackoverflow.com/q/21616691
tags question: http://stackoverflow.com/q/21592383
tags question: http://stackoverflow.com/q/21532058
tags question: http://stackoverflow.com/q/21541745
tags question: http://stackoverflow.com/q/21590948
tags question: http://stackoverflow.com/q/21639882
tags question: http://stackoverflow.com/q/21627704
tags question: http://stackoverflow.com/q/21544114
tags question: http://stackoverflow.com/q/21516727
tags question: http://stackoverflow.com/q/21556898
tags question: http://stackoverflow.com/q/21556425
tags question: http://stackoverflow.com/q/21596834
tags question: http://stackoverflow.com/q/21559984
tag name: sql
tags question: http://stackoverflow.com/q/21522009
tags question: http://stackoverflow.com/q/21594981
type: Tag
tags question: http://stackoverflow.com/q/21530652
tags question: http://stackoverflow.com/q/21634703
tags question: http://stackoverflow.com/q/21562442
tags question: http://stackoverflow.com/q/21583911
tags question: http://stackoverflow.com/q/21581253
tags question: http://stackoverflow.com/q/21658131
tags question: http://stackoverflow.com/q/21627520
tags question: http://stackoverflow.com/q/21604250
tags question: http://stackoverflow.com/q/21658537
tags question: http://stackoverflow.com/q/21654358
tags question: http://stackoverflow.com/q/21617648
tags question: http://stackoverflow.com/q/21542825
tags question: http://stackoverflow.com/q/21668702
tags question: http://stackoverflow.com/q/21630647
tags question: http://stackoverflow.com/q/21549194
tags question: http://stackoverflow.com/q/21644078
tags question: http://stackoverflow.com/q/21570365
tags question: http://stackoverflow.com/q/21532028
tags question: http://stackoverflow.com/q/21595297
tags question: http://stackoverflow.com/q/21645960
tags question: http://stackoverflow.com/q/21556594
tags question: http://stackoverflow.com/q/21573706
tags question: http://stackoverflow.com/q/21626861
tags question: http://stackoverflow.com/q/21663558
tags question: http://stackoverflow.com/q/21575873
tags question: http://stackoverflow.com/q/21533923
tags question: http://stackoverflow.com/q/21621283
tags question: http://stackoverflow.com/q/21605632
tags question: http://stackoverflow.com/q/21575253
tags question: http://stackoverflow.com/q/21544485
tags question: http://stackoverflow.com/q/21645371
tags question: http://stackoverflow.com/q/21658092
tags question: http://stackoverflow.com/q/21631624
tags question: http://stackoverflow.com/q/21658569
tags question: http://stackoverflow.com/q/21542774
tags question: http://stackoverflow.com/q/21608460
tags question: http://stackoverflow.com/q/21620622
tags question: http://stackoverflow.com/q/21641734
tags question: http://stackoverflow.com/q/21606034
tags question: http://stackoverflow.com/q/21517992
tags question: http://stackoverflow.com/q/21580227
tags question: http://stackoverflow.com/q/21659485
tags question: http://stackoverflow.com/q/21530529
tags question: http://stackoverflow.com/q/21676257
tags question: http://stackoverflow.com/q/21552997
tags question: http://stackoverflow.com/q/21519541
tags question: http://stackoverflow.com/q/21602667

http://stackoverflow.com/comment/32708736
type: QuestionComment
has text: Can, you ellaborate me , how to set class loader policy.
score: 0
comment on: http://stackoverflow.com/q/21642397
type: Comment

http://stackoverflow.com/a/21603686
downvote count: 0
type: Answer
upvote count: 3
answers question: http://stackoverflow.com/q/21603650
score: 3
has body: The expression this.getId(person) == null will return you true or false. Again adding a ternary operator is redundant.

http://stackoverflow.com/comment/32691550
type: Comment
comment on: http://stackoverflow.com/a/21633060
type: AnswerComment
score: 0
has text: Those resources are "semi-static" content and are `JSP` pages, so they are inside of WEB-INF

http://stackoverflow.com/q/21575640
has body: how to process the follwing query getting result list will return array list of unknown type. do i have to create dto and select to new of this object. SELECT c.currency, SUM(c.population) FROM Country c WHERE 'Europe' MEMBER OF c.continents GROUP BY c.currency
has comment: http://stackoverflow.com/comment/32590319
score: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32590216
tagged with: java
has answer: http://stackoverflow.com/a/21575947
type: Question
answer count: 2
possible better answer: http://stackoverflow.com/a/21575837
accepted answer: http://stackoverflow.com/a/21575947
tagged with: jpa
has answer: http://stackoverflow.com/a/21575837
has comment: http://stackoverflow.com/comment/32590228
has title: How to process the following query

http://stackoverflow.com/q/21545933
has comment: http://stackoverflow.com/comment/32537701
has body: I have String str, from which I want to extract the sub-string excluding a possible prefix "abc". The first solution that comes to mind is: if (str.startsWith("abc")) return str.substring("abc".length()); return str; My questions are: Is there a "cleaner" way to do it using split and a regular expression for an "abc" prefix? If yes, is it less efficient than the method above (because it searches "throughout" the string)? If yes, is there any better way of doing it (where "better way" = clean and efficient solution)? Please note that the "abc" prefix may appear elsewhere in the string, and should not be removed.
score: 71
tagged with: java
has answer: http://stackoverflow.com/a/21546141
has answer: http://stackoverflow.com/a/21546144
downvote count: 0
answer count: 7
has answer: http://stackoverflow.com/a/21546124
tagged with: string
has answer: http://stackoverflow.com/a/47059599
has answer: http://stackoverflow.com/a/21545981
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/54647148
tagged with: regex
has answer: http://stackoverflow.com/a/21546000
has title: Trim a possible prefix of a string
upvote count: 71
type: Question

http://stackoverflow.com/comment/32658183
type: Comment
has text: but that would still be O(n^3)..since O(n/2)~O(n) ?
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/21613911

http://stackoverflow.com/q/21670923
has comment: http://stackoverflow.com/comment/32757235
type: UnansweredQuestion
type: Question
score: -2
tagged with: java
has title: ArrayIndexOutOfBoundsException in Nested for loop?
tagged with: indexoutofboundsexception
downvote count: 2
has answer: http://stackoverflow.com/a/21671127
answer count: 1
has comment: http://stackoverflow.com/comment/32757330
favorite count: 0
has body: I don't know why I got an ArrayIndexOutOfBoundsException inside the nested for loop... It only prints the first inner for loops and never proceed to the outer for loop. Can anyone tell me why this is happening? public static double weight(){ //int counter = 0; System.out.println("####" + d); while(Math.abs(delta_w) &gt; 0.001){ for(int i = 0; i &lt; 33; i++ ){ for(int j = 0; j &lt; 13; j++ ){ if(Math.abs(delta_w)!=0){ value = d.exData[i][j]; //? y = d.exLabels[i]; percep = w * d.exData[i][j]; System.out.println(d.exData[i][j]); delta_w = y - percep; w+= delta_w; // counter++; System.out.println("value w " + w); } } } } return w; }
has comment: http://stackoverflow.com/comment/32757354
upvote count: 0

http://stackoverflow.com/a/21671578
score: 1
answers question: http://stackoverflow.com/q/21671530
upvote count: 1
has body: No, it doesn't matter where in the class it is defined. All you're doing is defining a method - it'll take the same amount of time whether it's at the beginning or end or somewhere in between. You can verify this with a profiler. It's executing the function that will potentially need to be optimized if anything. You don't need to worry about methods in your class trying to use it "before it's defined" either, since your entire class gets classloaded before you can run any methods in it.
type: Answer
downvote count: 0

http://stackoverflow.com/comment/32562020
comment on: http://stackoverflow.com/q/21559842
type: Comment
type: QuestionComment
has text: Why downvote? He obviously tried to understand where the error comes from...
score: 3

http://stackoverflow.com/q/21540699
downvote count: 2
tagged with: maven
tagged with: spring
type: Question
tagged with: spring-mvc
tagged with: java
tagged with: eclipse
upvote count: 0
score: -2
answer count: 1
has body: I am trying to install the spring petcare application in my eclipse/tomcat7 installation, and I am getting the following error message when I try Run As..Maven Build in eclipse: POM for joda-time:joda-time-jsptags:jar:1.0.2 is missing, no dependency information available Here is a link to the complete stack trace. And here is a link to pom.xml. The entire code for the application can be found at this link. I have not changed anything in the application's code yet because I have not even gotten it to compile. The jar in question seems to be in my local maven repository, so the problem may be that the app is simply not seeing it. Can anyone help me get this to compile?
favorite count: 0
has title: maven dependency for joda-time:joda-time-jsptags:jar:1.0.2
has answer: http://stackoverflow.com/a/21540957
type: UnansweredQuestion

http://stackoverflow.com/a/21656641
downvote count: 0
has comment: http://stackoverflow.com/comment/32747578
accepted answer of: http://stackoverflow.com/q/21650178
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21650178
type: Answer
upvote count: 1
has body: It's in the Jar but cannot be executed (same as trying to run an .exe from a zip file), you have to extract it before running it
has comment: http://stackoverflow.com/comment/32747449
score: 1
has comment: http://stackoverflow.com/comment/32741508

http://stackoverflow.com/q/21634448
tagged with: java
type: Question
tagged with: c#
has comment: http://stackoverflow.com/comment/32694401
has title: double object memory leak?
has comment: http://stackoverflow.com/comment/32693476
upvote count: 1
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/21634623
type: UnansweredQuestion
tagged with: android
tagged with: memory-leaks
has comment: http://stackoverflow.com/comment/32694854
has body: here's the setup for c# program: Inside Main class: ObjA MyObjA = new ObjA(); Inside ObjA: ObjB MyObjB = new ObjB(); So main has a reference to ObjA, and ObjA has a reference to ObjB. Now let's say in the main class, i set MyObjA = null; Will the garbage collector come along and destroy ObjA? Or will it save it since it has a reference to ObjB (which is not destroyed yet)? You can see how this would be a huge memory leak in the latter case. But as a side note, if the former case is true, then would it take 1 pass or 2 passes of the GC before ObjB is destroyed? Also, could someone tell me what would happen in Android Java too? Those are the two languages I'm working with atm.
has comment: http://stackoverflow.com/comment/32694082
downvote count: 0
has comment: http://stackoverflow.com/comment/32694599
score: 1

http://stackoverflow.com/comment/32710680
has text: I tried it with Java 7(51) and Java 8(b128) and in both cases compiler required cast, of course still in warning in both cases. But when I remove casting I get error in both cases(Java 7,8). I tried it in IDEA 13 environment.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21640002
type: Comment

exception
tags question: http://stackoverflow.com/q/21561838
tags question: http://stackoverflow.com/q/21658566
tags question: http://stackoverflow.com/q/21662075
tags question: http://stackoverflow.com/q/21677306
tags question: http://stackoverflow.com/q/21519605
tags question: http://stackoverflow.com/q/21572535
tags question: http://stackoverflow.com/q/21649299
tags question: http://stackoverflow.com/q/21562525
tags question: http://stackoverflow.com/q/21666291
tags question: http://stackoverflow.com/q/21671969
tags question: http://stackoverflow.com/q/21545803
tags question: http://stackoverflow.com/q/21596013
tags question: http://stackoverflow.com/q/21521574
type: Tag
tags question: http://stackoverflow.com/q/21618041
tags question: http://stackoverflow.com/q/21653796
tags question: http://stackoverflow.com/q/21636404
tags question: http://stackoverflow.com/q/21674152
tags question: http://stackoverflow.com/q/21654342
tags question: http://stackoverflow.com/q/21563567
tags question: http://stackoverflow.com/q/21528485
tags question: http://stackoverflow.com/q/21571423
tags question: http://stackoverflow.com/q/21599870
tags question: http://stackoverflow.com/q/21662078
tags question: http://stackoverflow.com/q/21560773
tags question: http://stackoverflow.com/q/21574971
tags question: http://stackoverflow.com/q/21656739
tags question: http://stackoverflow.com/q/21523853
tags question: http://stackoverflow.com/q/21650153
tags question: http://stackoverflow.com/q/21517967
tags question: http://stackoverflow.com/q/21671796
tags question: http://stackoverflow.com/q/21578330
tags question: http://stackoverflow.com/q/21551731
tag name: exception
tags question: http://stackoverflow.com/q/21564601
tags question: http://stackoverflow.com/q/21554323
tags question: http://stackoverflow.com/q/21645164
tags question: http://stackoverflow.com/q/21602821
tags question: http://stackoverflow.com/q/21631760
tags question: http://stackoverflow.com/q/21641910
tags question: http://stackoverflow.com/q/21568083
tags question: http://stackoverflow.com/q/21540063
tags question: http://stackoverflow.com/q/21606722

http://stackoverflow.com/q/21553108
downvote count: 0
answer count: 1
tagged with: tomcat
favorite count: 0
has body: An error occurred during the installation of Tomcat 7 Cookbook. While executing in Chef-Solo, this error appeared. The openssl is correctly installed. * execute[Create Tomcat SSL certificate] action run ================================================================================ Error executing action `run` on resource 'execute[Create Tomcat SSL certificate]' ================================================================================ Mixlib::ShellOut::ShellCommandFailed ------------------------------------ Expected process to exit with [0], but received '127' ---- Begin output of /usr/lib/jvm/default-java/bin/keytool -genkeypair -keystore "/etc/tomcat7/keystore.jks" -storepass "AWpbettrAMoVK4orJOdi" -keypass "AWpbettrAMoVK4orJOdi" -dname "cn=localhost" ---- STDOUT: STDERR: sh: 1: /usr/lib/jvm/default-java/bin/keytool: not found ---- End output of /usr/lib/jvm/default-java/bin/keytool -genkeypair -keystore "/etc/tomcat7/keystore.jks" -storepass "AWpbettrAMoVK4orJOdi" -keypass "AWpbettrAMoVK4orJOdi" -dname "cn=localhost" ---- Ran /usr/lib/jvm/default-java/bin/keytool -genkeypair -keystore "/etc/tomcat7/keystore.jks" -storepass "AWpbettrAMoVK4orJOdi" -keypass "AWpbettrAMoVK4orJOdi" -dname "cn=localhost" returned 127 Resource Declaration: --------------------- # In /root/.chef/chef-repo/cookbooks/tomcat/recipes/default.rb 181: execute "Create Tomcat SSL certificate" do 182: group node['tomcat']['group'] 183: command "#{node['tomcat']['keytool']} -genkeypair -keystore \"#{node['tomcat']['config_dir']}/#{node['tomcat']['keystore_file']}\" -storepass \"#{node['tomcat']['keystore_password']}\" -keypass \"#{node['tomcat']['keystore_password']}\" -dname \"#{node['tomcat']['certificate_dn']}\"" 184: umask 0007 185: creates "#{node['tomcat']['config_dir']}/#{node['tomcat']['keystore_file']}" 186: action :run 187: notifies :restart, "service[tomcat]" 188: end 189: end Compiled Resource: ------------------ # Declared in /root/.chef/chef-repo/cookbooks/tomcat/recipes/defa…
tagged with: openssl
accepted answer: http://stackoverflow.com/a/21561549
tagged with: chef-infra
has comment: http://stackoverflow.com/comment/32588080
upvote count: 1
has title: SSL Error during Chef-Solo Tomcat7 Cookbook Installation
type: AnsweredQuestion
score: 1
tagged with: java
tagged with: ssl
has answer: http://stackoverflow.com/a/21561549
has comment: http://stackoverflow.com/comment/32562834
type: Question

http://stackoverflow.com/comment/32532190
type: Comment
comment on: http://stackoverflow.com/a/21542000
score: 0
type: AnswerComment
has text: I used asyncTask but now the server won't even receive the message, I've eddited the question and added the modified code do you know what's wrong?

http://stackoverflow.com/a/21557841
score: 0
type: Answer
has body: put your tomcat/bin path in your class path and try to start server.
answers question: http://stackoverflow.com/q/21557529

http://stackoverflow.com/a/21666646
downvote count: 0
answers question: http://stackoverflow.com/q/21666476
type: Answer
has comment: http://stackoverflow.com/comment/32750195
has comment: http://stackoverflow.com/comment/32750173
has body: The bit pattern of a floating point number will NEVER (with ONE exception) remotely resemble the bit pattern of the corresponding integer value, if one exists. I suggest you run the following program public class Test { public static void main(String[] args) { double d = 1.3; long d1 = (long) d; long d2 = (Double.doubleToLongBits(d)); System.out.printf("cast %016X bits %016X\n", d1, d2); } } Then read What Every Computer Scientist Should Know About Floating-Point Arithmetic (The exception is, of course, the value zero) If you want to investigate further, there's a neat interactive floating point converter at CUNY that displays everything you'd ever want to know about any given number's float representations.
upvote count: 5
has comment: http://stackoverflow.com/comment/32760922
has comment: http://stackoverflow.com/comment/32750287
has comment: http://stackoverflow.com/comment/32764891
has comment: http://stackoverflow.com/comment/32750257
score: 5
has comment: http://stackoverflow.com/comment/32765121

http://stackoverflow.com/comment/32535933
comment on: http://stackoverflow.com/a/21545290
score: 1
type: AnswerComment
has text: No it doesn't, it says it should remove 4 times 365 days which is almost four years. It is just a non-working way of saying c.add(Calendar.YEAR, -4);
type: Comment

http://stackoverflow.com/q/21540488
score: 0
answer count: 2
has title: Java while loop exception
possible better answer: http://stackoverflow.com/a/21540541
has answer: http://stackoverflow.com/a/21540541
has answer: http://stackoverflow.com/a/21540502
has body: i'm receiving this error with my java application. I believe the fault is with the add function for my array list. Is there a better way of incorporating this idea without going too complex? (First week of java) Thanks a lot guys! import java.util.ArrayList; import java.util.Scanner; public class PrimeSieve { public static void main(int[] args) { System.out.println("Enter the max integer(N value): "); Scanner scan = new Scanner(System.in); int num = scan.nextInt(); System.out.println("Compute prime numbers from 2 to: " + num); if(num &lt; 2){ System.out.println("N must be greater than or equal to 2."); } else if(num == 2) { System.out.println("Prime numbers: 2"); } else { ArrayList&lt;Integer&gt; myArr = new ArrayList&lt;Integer&gt;(); int i = 2; while(i &lt;= num){ myArr.add(i); } System.out.println(myArr); } } } The error - Exception in thread "main" java.lang.NoSuchMethodError: main
has comment: http://stackoverflow.com/comment/32529306
type: AnsweredQuestion
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/21540502

http://stackoverflow.com/a/21805990
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21641431
type: Answer
answers question: http://stackoverflow.com/q/21641431
score: 3
upvote count: 3
has body: What you need is a job monitor and that depends a lot on what kind of jobs you're trying to monitor: I suggest you take a look on these options: http://www.quartzdesk.com/ - for quartz jobs http://jenkins-ci.org/ - is actually a ci server, but can be used to monitor tasks http://www.nagios.org/ - for system tasks

http://stackoverflow.com/a/21672643
has body: Your servlet name in the mapping is wrong. It should be DB.DBServlet, and you have written DB.DBervlet. What you have specified is missing an "S". Please try that again. Also, Please avoid capital letters while naming packages. From your configuration it looks like DB is the package name.
answers question: http://stackoverflow.com/q/21672499
score: 0
type: Answer

http://stackoverflow.com/q/21577407
tagged with: date
possible better answer: http://stackoverflow.com/a/44373450
type: Question
upvote count: 22
has answer: http://stackoverflow.com/a/21581829
has answer: http://stackoverflow.com/a/44373450
downvote count: 0
has answer: http://stackoverflow.com/a/64018841
score: 22
favorite count: 0
tagged with: freemarker
accepted answer: http://stackoverflow.com/a/21581829
answer count: 4
has body: Using FreeMarker, I want to display a date into milliseconds: ${mydate?long} but I get as output a comma separated millisecond: 524,354,400,000 is there any built-in function in Freemarker to remove comma ? Thanks
has answer: http://stackoverflow.com/a/67902096
type: AnsweredQuestion
tagged with: java
has title: FreeMarker - Remove comma from milliseconds

http://stackoverflow.com/a/21564784
score: 1
upvote count: 1
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21564601
has body: I would do a simple test with some removable storage (USB stick, for instance): Just write a program that opens a FileInputStream with a file from the USB stick and then prompts "Please remove the storage device", waits for an &lt;Enter&gt; and then tries in.close(). I would bet some IOException would be thrown.

http://stackoverflow.com/comment/32514724
type: QuestionComment
type: Comment
has text: It is on a separate project in the same workspace. Please look here http://i.imgur.com/WO5H57F.png
comment on: http://stackoverflow.com/q/21532709
score: 0

http://stackoverflow.com/a/21589234
has comment: http://stackoverflow.com/comment/32615239
answers question: http://stackoverflow.com/q/21585932
upvote count: 9
type: Answer
downvote count: 0
score: 9
has comment: http://stackoverflow.com/comment/32627947
has body: The issue is that you've got to one value from b to a at the same time as assigning to b the sum of a and b. Get that simultaneous swap wrong and you get the wrong answer. In the spirit of the Python code, I present: public static int fib(int n) { int a = 0, b = 1; while (n--&gt;0) b = a + (a = b); return a; } This does the swap effectively at the same time as the add (strictly not, but it's good enough). Note that this is well-defined Java, as the language defines the evaluation order of operators precisely, unlike in C and C++ (where the equivalent of the above code is permitted to make demons fly out of your nose due to being Undefined Behavior). OK, if it did make you experience problems with nasal demons, I'd suggest not using that compiler in future. But you wouldn't have any assurance of getting a correct fib() function…

http://stackoverflow.com/q/21625059
has answer: http://stackoverflow.com/a/41208695
has answer: http://stackoverflow.com/a/51318591
has title: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected
has answer: http://stackoverflow.com/a/53142565
has body: I am getting this error when I am trying to update values in my database from my spring mvc application : org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61) at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46) at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106) at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:656) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723) at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopPro…
score: 27
has answer: http://stackoverflow.com/a/62368700
has answer: http://stackoverflow.com/a/22489680
answer count: 16
tagged with: spring-mvc
has answer: http://stackoverflow.com/a/50616906
has answer: http://stackoverflow.com/a/54076927
tagged with: java
tagged with: hibernate
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/57656283
upvote count: 27
has answer: http://stackoverflow.com/a/54012496
has answer: http://stackoverflow.com/a/28535378
has answer: http://stackoverflow.com/a/30492460
tagged with: jpa
downvote count: 0
has answer: http://stackoverflow.com/a/68652917
has answer: http://stackoverflow.com/a/50698592
favorite count: 0
has answer: http://stackoverflow.com/a/25246396
type: Question
has answer: http://stackoverflow.com/a/71318875
has answer: http://stackoverflow.com/a/42025623

http://stackoverflow.com/q/21585728
has title: Java Switch Statement, discount percent off
accepted answer: http://stackoverflow.com/a/21585797
tagged with: java
has answer: http://stackoverflow.com/a/21585954
tagged with: switch-statement
type: Question
has body: I am stuck trying to create a switch statement for my program. For full disclosure this is a homework assignment that is due tomorrow. I am supposed to use a switch statement to assign a discount rate for the total charge of CD's being sold. Gold being 15% off, Silver 10%, Bronze 5% and 0% for non members. Here is my program so far. I have not gotten to the output yet, but that shouldn't be a problem as long as I cant get past this switch. public static void main(String[] args) { //Variables String firstName = null; String lastName = null; int songs; double cost; int membership; double serviceCharge; double productCharge; double baseCharge; //Keyboard input Scanner keyboard = new Scanner(System.in); //Gathering information from the user System.out.println("Enter your first name:"); firstName = keyboard.nextLine(); System.out.println("Enter your last name:"); lastName = keyboard.nextLine(); System.out.println("Enter the number of songs downloaded:"); songs = keyboard.nextInt(); System.out.println("enter the cost per song:"); cost = keyboard.nextDouble(); System.out.println("Enter the status of membership:" + "3 represents a gold member" + "2 represents a silver member" + "1 represeents a bronze member:" + "0 represents a nonmember"); membership = keyboard.nextInt(); //Here is where the math starts baseCharge = cost * songs; serviceCharge = baseCharge; if (songs &lt;= 8) serviceCharge = .07 * baseCharge; else if (songs &gt; 8 &amp;&amp; songs &lt;= 15) serviceCharge = .04 * baseCharge; else if (songs &gt; 15 &amp;&amp; songs &lt; 20) serviceCharge = .02 * baseCharge; else if (songs &lt;= 20) serviceCharge = 0; productCharge = baseCharge + serviceCharge; switch (membership) { case 3: productCharge * .15; break; case 2: break; case 1: break; case 0: break; default: break; } Obviously you cannot use double in a switch statement, but I am lost. How am I supposed to assign the percent discount rate without using a double? you need decimals to do the math correctly. Or am I…
has answer: http://stackoverflow.com/a/21585797
has answer: http://stackoverflow.com/a/21585795
score: 0
answer count: 3
possible better answer: http://stackoverflow.com/a/21585795
type: AnsweredQuestion

http://stackoverflow.com/comment/32730590
comment on: http://stackoverflow.com/q/21655358
has text: Interesting, I thought it was because of this line. Now I get the same error after I remove that line. So its a classpath issue, but does it have anything to do with the lib I've included?
type: Comment
score: 0
type: QuestionComment

http://stackoverflow.com/comment/32544734
comment on: http://stackoverflow.com/q/21550393
type: Comment
type: QuestionComment
has text: Debug your code and you'll know why.
score: 2

http://stackoverflow.com/q/21630389
type: Question
has comment: http://stackoverflow.com/comment/32686172
has comment: http://stackoverflow.com/comment/32686071
downvote count: 0
has comment: http://stackoverflow.com/comment/32686528
has body: I am getting the following error: Mapping cannot be resolved to a type When I do the import of the class I need, it appears as a valid class to import, but when cleaning the project, I obtain the error. This is the situation: I tried cleaning, restarting eclipse and all the common stuff, but nothing seems to work. Do you know how to solve this? Regards!
favorite count: 0
has comment: http://stackoverflow.com/comment/32686462
has comment: http://stackoverflow.com/comment/32686102
has comment: http://stackoverflow.com/comment/32686463
has comment: http://stackoverflow.com/comment/32686774
answer count: 0
has comment: http://stackoverflow.com/comment/32686548
type: UnansweredQuestion
upvote count: 1
has title: Eclipse cannot resolve to a type that actually exists
has comment: http://stackoverflow.com/comment/32686516
has comment: http://stackoverflow.com/comment/32686661
has comment: http://stackoverflow.com/comment/32686498
score: 1
has comment: http://stackoverflow.com/comment/32686660
tagged with: java
tagged with: eclipse
has comment: http://stackoverflow.com/comment/32686110
has comment: http://stackoverflow.com/comment/32686950
tagged with: import

http://stackoverflow.com/comment/33854085
type: Comment
has text: You should add the Lua tag to this question if you want a specific comparison to Lua's coroutines. I *believe* there is no functional difference, but only the knowledge from a Lua developer would settle it for sure. In the meantime, my answer may help them understand Python's, and give them the knowledge to provide their comparison.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21587920

http://stackoverflow.com/q/21544969
has answer: http://stackoverflow.com/a/21544999
tagged with: swing
downvote count: 0
has body: Getting an error at frame.add(game);: Multiple markers at this line - Debug Current Instruction Pointer - The method add(Component) in the type Container is not applicable for the arguments (Display) My code: import java.awt.Canvas; import java.awt.Component; import javax.swing.JFrame; public class Display { public static final int WIDTH = 800; public static final int HEIGHT = 600; public static void main(String[] args){ Display game = new Display(); JFrame frame = new JFrame(); frame.add(game); frame.setSize(WIDTH, HEIGHT); frame.setResizable(false); frame.setVisible(true); } }
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/21545060
type: Question
has title: Java Frame - Game
answer count: 2
has comment: http://stackoverflow.com/comment/32535438
upvote count: 1
favorite count: 0
tagged with: jframe
type: UnansweredQuestion

http://stackoverflow.com/a/21557097
downvote count: 1
upvote count: 4
has comment: http://stackoverflow.com/comment/32556896
has body: int is a primitive struct, yes. However, int? is syntactic sugar for Nullable&lt;int&gt; which is a completely different type. See: http://msdn.microsoft.com/en-us/library/1t3y8s4s.aspx
answers question: http://stackoverflow.com/q/21557034
has comment: http://stackoverflow.com/comment/32556772
type: Answer
score: 3

http://stackoverflow.com/q/21670104
has answer: http://stackoverflow.com/a/21672198
has title: Type Archive for required library: spring-core-4.0.1.RELEASE.jar' in project 'starter' cannot be read or is not a valid ZIP file
score: 6
tagged with: spring
has body: While importing Spring Starter zipped project generated by Spring Initializr in Eclipse (STS 3.4) I got error Type Archive for required library: 'C:/Users/user/.m2/repository/org/springframework/spring-core/4.0.1.RELEASE/spring-core-4.0.1.RELEASE.jar' in project 'starter' cannot be read or is not a valid ZIP file Is it Eclipse problem or is there something special about spring-core-4.0.1.RELEASE.jar ? Its size is 979016B. Update: trying Answer https://stackoverflow.com/a/20093533/482717 to eclipse maven error: Archive for required library in project cannot be read or is not a valid ZIP file When running mvn package -U [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project demo: Compilation failure: Compilation failure: [ERROR] 读取C:\Users\weibl\.m2\repository\org\springframework\spring-context\4.0.1.RELEASE\spring-context-4.0.1.RELEASE.jar时出错; invalid LOC header (bad signature) [ERROR] 读取C:\Users\weibl\.m2\repository\org\springframework\spring-aop\4.0.1.RELEASE\spring-aop-4.0.1.RELEASE.jar时出错; invalid LOC header (bad signature) [ERROR] 读取C:\Users\weibl\.m2\repository\org\springframework\spring-beans\4.0.1.RELEASE\spring-beans-4.0.1.RELEASE.jar时出错; invalid CEN header (bad signature) [ERROR] 读取C:\Users\weibl\.m2\repository\org\springframework\spring-expression\4.0.1.RELEASE\spring-expression-4.0.1.RELEASE.jar时出错; invalid LOC header (bad signature) [ERROR] 读取C:\Users\weibl\.m2\repository\ch\qos\logback\logback-core\1.1.0\logback-core-1.1.0.jar时出错; invalid CEN header (bad signature) [ERROR] 读取C:\Users\weibl\.m2\repository\org\springframework\spring-context\4.0.1.RELEASE\spring-context-4.0.1.RELEASE.jar时出错; cannot read zip file entry [ERROR] 读取C:\Users\weibl\.m2\repository\org\springframework\spring-aop\4.0.1.RELEASE\spring-aop-4.0.1.RELEASE.jar时出错; cannot read zip file entry [ERROR] /D:/Workspaces/workspace-sts-3.4.0.RELEASE/starter/src/main/java/demo/Application.java:[5,46] 程序包org.springframework.context.an…
type: AnsweredQuestion
tagged with: spring-boot
downvote count: 0
tagged with: java
tagged with: m2e
tagged with: eclipse
linked to: http://stackoverflow.com/q/20091177
type: Question
upvote count: 6
accepted answer: http://stackoverflow.com/a/21672198
answer count: 1
favorite count: 0

http://stackoverflow.com/comment/96006285
has text: Could there be a resource leak, if `Files.list` throws?
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21652054

http://stackoverflow.com/q/21518844
has comment: http://stackoverflow.com/comment/32622888
has answer: http://stackoverflow.com/a/21520146
linked to: http://stackoverflow.com/q/1519736
has body: Ok so i have looked about for an answer. I am using a random generator to generate numbers based on the user input. This will then select a random number from that and assign them a special position in the game. However the problem is i keep getting repeated values which isn't what i want. So could anyone help? in (blueprint class) int getRoll() { roll=rand.nextInt(totalNum); return roll; } (main class) for(numberOfWerewolves=0;numberOfWerewolves!=wolves.werewolfNum;numberOfWerewolves++) { playerNumber++; wolves.getRoll(); System.out.println(wolves.roll); } anyone can help me would be great thanks
tagged with: repeat
has comment: http://stackoverflow.com/comment/32490081
type: UnansweredQuestion
upvote count: 1
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/21520280
tagged with: java
score: 0
tagged with: random
answer count: 2
has comment: http://stackoverflow.com/comment/32489882
has comment: http://stackoverflow.com/comment/32490123
favorite count: 0
has title: how to prevent a number from repeating
has comment: http://stackoverflow.com/comment/32490130

http://stackoverflow.com/a/21568630
has body: A Java best practice is to prefer composition over inheritance. Keeps things simpler but creates more boilerplate code. You have the right idea to create delegate methods. A good Java IDE can generate all the boilerplate delegate methods code for you. Other languages on the JVM like Scala (with traits) make this easier.
upvote count: 1
has comment: http://stackoverflow.com/comment/100953795
downvote count: 0
has comment: http://stackoverflow.com/comment/100948030
score: 1
answers question: http://stackoverflow.com/q/21568253
type: Answer

http://stackoverflow.com/q/21585988
upvote count: 1
has comment: http://stackoverflow.com/comment/32609217
favorite count: 0
has answer: http://stackoverflow.com/a/21586123
answer count: 3
has answer: http://stackoverflow.com/a/21586658
downvote count: 0
type: UnansweredQuestion
has title: Adding A Scroll Pane in java GUI
has body: I'm working on a Java GUI that will tell fortunes. The code works but I have some aesthetics problems. I have looked at things on here and on other sites, but i cant seem to get my scroll pane to come up. If someone could point me in the right direction of getting these to work it would be greatly appreciated! package FortuneTellerRunner; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Random; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; /** * * @author a3cal_000 */ class FortuneTellerFrame extends JFrame { final private JPanel mainPnl, titlePnl, displayPnl, buttonPnl, imagePnl; final private JButton quitBtn, rndBtn; final private JLabel titleLbl; final private JTextArea textArea; public String[] fortune = new String [12]; int newIndex, oldIndex; private static final int HEIGHT = 250; private static final int WIDTH = 450; public FortuneTellerFrame() { setSize(WIDTH, HEIGHT); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainPnl = new JPanel(); mainPnl.setLayout(new BorderLayout()); imagePnl = new JPanel(); displayPnl = new JPanel(); buttonPnl = new JPanel(); titlePnl = new JPanel(); ImageIcon icon1 = new ImageIcon("FortuneTellerIcon.JPG"); JLabel iconLbl = new JLabel(); iconLbl.setIcon(icon1); titleLbl = new JLabel("Fortune Teller!"); textArea = new JTextArea(5, 30); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setPreferredSize(new Dimension(300, 250)); // Create the layout of the title panel titlePnl.setLayout(new GridLayout(2,1)); add(mainPnl); // Set the label to the panel. titlePnl.add(titleLbl); titlePnl.add(iconLbl); // add the panel to the main panel. mainPnl.add(titlePnl, BorderLayout.NORTH); mainPnl.add(scrollPane, BorderLayout.CENTER); mainPnl.add(textArea, B…
has comment: http://stackoverflow.com/comment/32611088
score: 1
has answer: http://stackoverflow.com/a/21586117
tagged with: java
type: Question

http://stackoverflow.com/comment/32668396
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/21612771
score: 0
has text: Glad you got a better simple explanation than my :)

http://stackoverflow.com/comment/32771843
comment on: http://stackoverflow.com/q/21676257
has text: @AshotKarakhanyan, No connection pool is not used. this is very direct.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32536102
type: AnswerComment
has text: This issue is pretty common, read the link I posted and you will understand why this happens. And maybe you won't need our help anymore.
type: Comment
comment on: http://stackoverflow.com/a/21545307
score: 0

http://stackoverflow.com/a/21521718
answers question: http://stackoverflow.com/q/21521520
type: AcceptedAnswer
downvote count: 0
has body: Use this Code for Converting Numbers to Word Source here public class YourNumberMyWord { public void pw(int n,String ch) { String one[]={" "," one"," two"," three"," four"," five"," " + "six"," seven"," eight"," Nine"," ten"," eleven"," twelve"," " + "thirteen"," fourteen","fifteen"," sixteen"," seventeen"," eighteen"," nineteen"}; String ten[]={" "," "," twenty"," thirty"," forty"," fifty"," sixty","seventy"," eighty"," ninety"}; if(n&gt;19) { System.out.print(ten[n/10]+" "+one[n%10]); } else { System.out.print(one[n]);} if(n&gt;0)System.out.print(ch); } public static void main(String[] args) { int n=0; Scanner scanf = new Scanner(System.in); System.out.println("Enter an integer number: "); n = scanf.nextInt(); if(n&lt;=0) System.out.println("Enter numbers greater than 0"); else { YourNumberMyWord a = new YourNumberMyWord(); a.pw((n/1000000000)," Hundred"); a.pw((n/10000000)%100," crore"); a.pw(((n/100000)%100)," lakh"); a.pw(((n/1000)%100)," thousand"); a.pw(((n/100)%10)," hundred"); a.pw((n%100)," "); } } }
accepted answer of: http://stackoverflow.com/q/21521520
has comment: http://stackoverflow.com/comment/32495871
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/32495423
upvote count: 2
has comment: http://stackoverflow.com/comment/32495560

http://stackoverflow.com/a/21586750
has comment: http://stackoverflow.com/comment/32611090
has comment: http://stackoverflow.com/comment/32611212
score: 5
has comment: http://stackoverflow.com/comment/32611154
upvote count: 5
accepted answer of: http://stackoverflow.com/q/21586690
has body: You can simulate multiple key-value (KV) pairs by saving a list of values for each in a map. This is a standard implementation approach for "multivalue" maps. So, if the key is a Character object and the value is Boolean, you can do Map&lt;Character, List&lt;Boolean&gt;&gt; multimap = new HashMap&lt;Character, List&lt;Boolean&gt;&gt;(); and every time you want to add a new value to an existing KV pair in the map just call multimap.get(key).add(value); where key is the Character and value its corresponding Boolean value. The Guava library by Google (free download) has a Multimap interface implemented in various ways, so essentially you can instantiate a MultiMap&lt;Character, Boolean&gt; map and use it accordingly. Similarly, you can get the Apache Commons Collections library and use its MultiValueMap class. You may also want to check the answers to a similar StackOverflow question, or another one. If you only want to store one of each value per key, then a Set should be used in the place of the List.
answers question: http://stackoverflow.com/q/21586690
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32611042
type: Answer

http://stackoverflow.com/comment/32551372
comment on: http://stackoverflow.com/q/21554341
type: Comment
has text: What don't you understand in this code?
score: 0
type: QuestionComment

http://stackoverflow.com/comment/32602911
score: 0
type: Comment
has text: The emphasis is on _assembly_, which is for a JIT usually an actual machine code, that will then include those checks.
type: AnswerComment
comment on: http://stackoverflow.com/a/21582314

http://stackoverflow.com/q/21630344
has title: Edit specific bytes in a binary file - Java
tagged with: randomaccessfile
tagged with: binaryfiles
has comment: http://stackoverflow.com/comment/32685942
downvote count: 0
answer count: 1
tagged with: outputstream
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32686009
upvote count: 1
has comment: http://stackoverflow.com/comment/32686055
has body: I want to know how can I do to edit specific bytes in a binary file in Java. Example, binaryfile before execution: byteArray1[128].. Represents a array of 128 bytes. byteArray2[128].. Other array of bytes byteArray3[128] byteArray4[128] Just now, I take a new data to the byteArray3[128] in modifiedByteArray[128]. After execution: byteArray1[128] byteArray2[128] modifiedByteArray3[128] .. The array in that position was modified. byteArray4[128] I have something like this code to append in the file: //PASSFILE -&gt; binary passfile path FileOutputStream fileOutput = new FileOutputStream(PASSFILE, true); BufferedOutputStream bufferedOutput = new BufferedOutputStream(fileOutput); long datos; // cipherText 128 bytes bufferedOutput.write(cipherText); I have this data: modifiedData[128], the new cipherText in a specific position in the binary file. offsetPosition, position where the array of the specific bytes starts. Solutions about it? Thanks :)
score: 1
tagged with: java
tagged with: inputstream
type: Question
has answer: http://stackoverflow.com/a/21631145

http://stackoverflow.com/a/21586818
score: 3
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/32610678
upvote count: 3
has body: You can use MultiMap&lt;Character,Boolean&gt; bcoz it allows duplicate key which exist in org.apache.commons.collections package. or You can use ArrayList and add the objects of the Class that contain attribute as char &amp; boolean pair.
has comment: http://stackoverflow.com/comment/32610835
has comment: http://stackoverflow.com/comment/32610771
has comment: http://stackoverflow.com/comment/32610798
answers question: http://stackoverflow.com/q/21586690

http://stackoverflow.com/comment/32754538
type: QuestionComment
score: 1
has text: @Marichyasana: The OP wanted to know, *how* `WHITESPACE_MULTIPLIER` at line 1357 has been generated, and this is AFAIK not in Guava.
comment on: http://stackoverflow.com/q/21668919
type: Comment

http://stackoverflow.com/a/71556871
answers question: http://stackoverflow.com/q/21544973
has comment: http://stackoverflow.com/comment/126487882
has body: import com.alibaba.fastjson.JSONObject; Map<String, Object> map = new HashMap<String, Object>(); JSONObject rec = JSONObject.parseObject(<JSONString>); map.put(rec.get("code").toString(), rec.get("value").toString());
score: 0
type: Answer

http://stackoverflow.com/comment/32764964
has text: See... By using the parent's reference you can call only the parent's methods (if overridden in child class, then the child's class methods will be called...).. The point is , even if you have a childClass object referenced by a parent class reference, then only "reference class's methods are visible".. this is the penalty you pay for being too generic (nicely explained by @Jorge_B below.. :)
score: 0
comment on: http://stackoverflow.com/q/21675396
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21554075
type: Question
tagged with: java
upvote count: 6
tagged with: spring-java-config
answer count: 2
has answer: http://stackoverflow.com/a/21554521
tagged with: spring-security
favorite count: 0
type: UnansweredQuestion
has title: Spring: Enable global method security in Controller layer by java config
tagged with: spring
has body: I'm trying to migrate my xml servlet config to java config. The below config is my servlet configuration, that enables custom security annotations on Controller layer. &lt;security:global-method-security pre-post-annotations="enabled"&gt; &lt;security:expression-handler ref="expressionHandler"/&gt; &lt;/security:global-method-security&gt; &lt;bean id="expressionHandler" class="yyy.MyMethodSecurityExpressionHandler" /&gt; I've also have a working spring security xml configuration, that is in order to be replaced by java config, but not now. Here some pieces of my security config: &lt;bean id="authenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider"&gt; &lt;property name="userDetailsService" ref="userDetailsService" /&gt; &lt;/bean&gt; &lt;bean id="authenticationManager" class="org.springframework.security.authentication.ProviderManager"&gt; &lt;constructor-arg&gt; &lt;ref bean="authenticationProvider"/&gt; &lt;/constructor-arg&gt; &lt;/bean&gt; &lt;security:authentication-manager&gt; &lt;security:authentication-provider user-service-ref="userDetailsService" /&gt; &lt;/security:authentication-manager&gt; &lt;security:global-method-security pre-post-annotations="enabled" /&gt; I want to start to migrate my servlet config enabling security @PreAuthorize and @PostAuthorize tag in Controller layer. I've found this annotation: @EnableGlobalMethodSecurity(prePostEnabled=true), but putting it on my servlet config: @Configuration @ComponentScan(basePackages= { "....." }) @EnableGlobalMethodSecurity(prePostEnabled=true) public class WebappServletConfig extends WebMvcConfigurationSupport { I get this exception: java.lang.IllegalArgumentException: Expecting to only find a single bean for type interface org.springframework.security.authentication.AuthenticationManager, but found [] Moreover I don't know how to set my custom expression-handler! someone with some tips? Thank you
tagged with: spring-mvc
downvote count: 0
score: 6
has answer: http://stackoverflow.com/a/21554408

http://stackoverflow.com/a/21641096
type: Answer
has body: remove the space after the "\" public static void main(String[] args) { String text = " Java " + " \u006B \u0065 \u006E \u006E \u0074 " + "\u0055 \u006E \u0069 \u0063 \u006F \u0064 \u0065 \u0021 "; System.out.print(text); } } output: Java k e n n t U n i c o d e !
score: 0
answers question: http://stackoverflow.com/q/21641073

http://stackoverflow.com/comment/32623393
type: QuestionComment
has text: I would recommend using the `elements` variable throughout and not `list.length` as the algorithm will break on `val = 0` and list contains a `0`.
comment on: http://stackoverflow.com/q/21593659
score: 0
type: Comment

http://stackoverflow.com/a/21615751
type: Answer
accepted answer of: http://stackoverflow.com/q/21613421
has comment: http://stackoverflow.com/comment/32737700
score: 8
has comment: http://stackoverflow.com/comment/32725956
downvote count: 0
has comment: http://stackoverflow.com/comment/32725156
upvote count: 8
type: AcceptedAnswer
has body: You'll probably want to implement these semantic checks in a listener, in combination with helper visitors. Here are some examples. Rule: The variables in the quantifier should be used in the condition Implementation: Create a visitor that returns the variables used by a specified parse tree node. You'll want to override defaultResult() and aggregateResult(T, T) to do most of the work for you, and then override visitNodev and visitEdgev to handle the specific variables in use. In your listener, override the enterFormula method. In this method, if ctx.quantifier() is not null, then use your visitor to get the list of variables declared in ctx.quantifier() and the list of variables used in ctx.formula(). Report an error as appropriate based on the two results. Rule: If there are 2 quantifiers then they should have different variables bound on them Implementation: Start with the visitor described in step 1 of the previous rule implementation. In your listener, override the enterFormula method. In the method, if ctx.quantifier() is not null, then you need to get a collection of all the other QuantifierContext instances underneath the tree returned by ctx.formula(). You can do this by calling XPath.findAll(ctx.formula(), "//quantifier", parser). Use the visitor described above to gather a list of variables declared in each of the linked QuantifierContext instances. If any of the sets overlap, report an error as appropriate. Rule: If there are 2 quantifiers the first should start with FOREACH Implementation: Use the listener pattern described in the previous step to locate cases where a formula contains more than one quantifier. If the first of these formulas has ctx.quantifier().FOREACH() == null emit an error as appropriate. Rule: There can't be more than two quantifiers... Implementation: Update the implementation of the 2nd rule above to report an error if XPath.findAll returns more than one QuantifierContext in the formula for a quantifier. Rule: Quantifier condition…
answers question: http://stackoverflow.com/q/21613421

http://stackoverflow.com/a/21639606
score: 2
accepted answer of: http://stackoverflow.com/q/21639577
type: AcceptedAnswer
downvote count: 0
type: Answer
has body: Use Integer.parseInt(), Double.parseDouble() etc, passing your string as an argument. e.g. int i = Integer.parseInt(drinkParse[3]); Note that these can throw a NumberFormatException if the argument can't be parsed as requested. (e.g. "soda200" can't parse straight to an int)
upvote count: 2
answers question: http://stackoverflow.com/q/21639577

http://stackoverflow.com/a/21537089
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32522530
has body: If you want an editor that will run directly on the command line, you can try Emacs or Vim. If you just want a simple editor with syntax highlighting, GEdit or Notepad++ will work well.
upvote count: 2
has comment: http://stackoverflow.com/comment/32522480
type: Answer
answers question: http://stackoverflow.com/q/21537043
score: 2
has comment: http://stackoverflow.com/comment/32522547
accepted answer of: http://stackoverflow.com/q/21537043
has comment: http://stackoverflow.com/comment/32522872
has comment: http://stackoverflow.com/comment/32522468

http://stackoverflow.com/q/21604250
score: 1
tagged with: java
has body: Please take a look at my code snippet below. What I am trying to achieve is querying the database for any results equal to the user input. It is querying SDS_NUMBER column which is an integer column. When I execute the query it returns the following exception: java.sql.SQLSyntaxErrorException: Comparisons between 'INTEGER' and 'CHAR (UCS_BASIC)' are not supported. Types must be comparable. String types must also have matching collation....etc. I understand that it is saying I am trying to compare an integer to char but I have tried to cast from examples I found on the net but no luck. Also I tried parseInt and using that value in the search but I still can't get it to work. Please advise what I am doing wrong and excuse my newbies to all of this. } else if (tmp == "sdsNumber") { try { Integer sdsNum = Integer.parseInt(val); String sql = "SELECT SDS_NUMBER, PRODUCT_NAME, PROPER_SHIPPING_NAME FROM APP.MASTER WHERE SDS_NUMBER = '"+sdsNum+"'"; pst = conn.prepareStatement(sql); pst.executeQuery(); jTable1.setModel(DbUtils.resultSetToTableModel(rs)); } catch (Exception e) { e.printStackTrace(System.out); JOptionPane.showMessageDialog(null, e); } Master table creation: CREATE TABLE MASTER ( id integer NOT NULL GENERATED ALWAYS AS (START WITH 1, INCREMENT BY 1) , SDS_NUMBER integer UNIQUE , PRODUCT_NAME varchar(100) , PRODUCT_DESCRIPTION varchar(500) , SDS_FILE_PATH varchar(50) , USE_STATUS BOOLEAN , DATA_UPDATED date , PROPER_SHIPPING_NAME varchar(100) , SIGNAL_WORD varchar(20) , CONSTRAINT MASTER_PRIMARY_KEY PRIMARY KEY (id) );
type: Question
has title: Java derby sql integer query
has answer: http://stackoverflow.com/a/21604304
downvote count: 0
answer count: 3
tagged with: sql
favorite count: 0
has comment: http://stackoverflow.com/comment/32642468
type: UnansweredQuestion
upvote count: 1
has answer: http://stackoverflow.com/a/21604287
has answer: http://stackoverflow.com/a/21642733

http://stackoverflow.com/comment/32666269
type: QuestionComment
has text: The `thread-local` in the answer you linked to is a prettier clojure-style wrapper over the construct used in `vemv`'s answer. It's not clear to me what's wrong with the linked answer that makes this one better, since it just uses the same stuff underneath.
score: 0
comment on: http://stackoverflow.com/q/21608077
type: Comment

http://stackoverflow.com/comment/33462484
has text: every request is bound from start to finish to only one thread, and in calls to the database the servlet thread blocks and then resumes until the completion of the request. at the end of the request depending on the container implementation the threads will go to a thread pool where they get reused in the next request, this is an optimization.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22054254
type: Comment

http://stackoverflow.com/comment/32584609
score: 0
type: AnswerComment
type: Comment
has text: Thanks! Adding this to the xml did make it work. Could you explain what exactly the problem must have been? And what do I need to take care of in the future?
comment on: http://stackoverflow.com/a/21571736

http://stackoverflow.com/comment/32723791
has text: @Quirliom, there are tons of HTML generator for Java out there. How is this not an occurring problem?
type: Comment
comment on: http://stackoverflow.com/q/21651519
score: 0
type: QuestionComment

http://stackoverflow.com/q/21524029
has title: Calling parent method and still hold the current variable
has answer: http://stackoverflow.com/a/21524211
type: Question
has comment: http://stackoverflow.com/comment/32498918
accepted answer: http://stackoverflow.com/a/21524212
has answer: http://stackoverflow.com/a/21524145
has body: I have a Model class. This Model has the method loadModel. It's there to load data from the database. I have many other models that extend Model. Now, I'm doing it like this Model.java public class Model { public String tablename = ""; public void loadModel ( String id ) { System.out.println ( "Tablename is: " + this.tablename ); } } User.java public class User extends Model { public String tablename = "users"; @Override public void loadModel ( String id ) { super.loadModel(id); } } How can I achieve that the parent loadModel class would say "Tablename is users"? In PHP it would work like this, why not in Java? How does it work in Java to do that? Since I will have many Models that should extend Model and it would be easier to do it like this so I don't have to rewrite methods all the time. Update What the method should do is the following. When I call the loadModel method I pass the ID of an entry. Like "5". Then I would call it like this loadModel("5"). Now the method of users get called and this calls the parent method of the super class. Now the super class should do this "SELECT * FROM " + this.tablename + " WHERE id=" + id; I hope I cleared some confusin.
score: 0
answer count: 3
possible better answer: http://stackoverflow.com/a/21524145
has comment: http://stackoverflow.com/comment/32498506
tagged with: oop
tagged with: java
has answer: http://stackoverflow.com/a/21524212
type: AnsweredQuestion

http://stackoverflow.com/q/21651660
upvote count: 1
has comment: http://stackoverflow.com/comment/32723641
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/21651688
has body: I'm trying to make an AUTO-UPDATING java application. What it's suppose to do is when initiated, it'll check for a jar file online, and if the jar file is named differently, it'll download it, and delete the current jar being ran. What would I have to do for this to work? I'm not sure what methods to use or what libraries I may need.
accepted answer: http://stackoverflow.com/a/21651688
answer count: 1
favorite count: 0
has title: Downloading files from a database onto the users computer
type: AnsweredQuestion
tagged with: auto-update
score: 0
tagged with: java

http://stackoverflow.com/q/21676470
upvote count: 3
answer count: 2
tagged with: layout
favorite count: 0
has answer: http://stackoverflow.com/a/52772433
has title: Difference between "rigid area" and "strut" in Box
has comment: http://stackoverflow.com/comment/32768346
type: AnsweredQuestion
score: 3
downvote count: 0
tagged with: java
tagged with: swing
type: Question
has body: Could someone please explain the differences between Box.createRigidArea(dimension) and Box.createHorizontalStrut(width) Box.createVerticalStrut(height) Is "Rigid area" a strut whose both dimensions can be user-specified, or is there more to it?
possible better answer: http://stackoverflow.com/a/52772433
has answer: http://stackoverflow.com/a/21676682
accepted answer: http://stackoverflow.com/a/21676682
has comment: http://stackoverflow.com/comment/32771790

http://stackoverflow.com/a/25004805
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/21620006
has comment: http://stackoverflow.com/comment/97306246
score: 0
type: Answer
has body: Since this is currently the second result in google for java superset I'm going to answer that query. Set.addAll will do this. example: // A couple of sets Set&lt;Integer&gt; set1 = new TreeSet&lt;&gt;(Arrays.asList(1, 2)); Set&lt;Integer&gt; set2 = new TreeSet&lt;&gt;(Arrays.asList(2, 3)); // Generate the superset Set&lt;Integer&gt; superset = new TreeSet&lt;&gt;(); superset.addAll(set1); // {1, 2} superset.addAll(set2); // {1, 2, 3}

http://stackoverflow.com/comment/32657676
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21613393
has text: @Javacadabra have you tried it, my friend

http://stackoverflow.com/q/21583015
has comment: http://stackoverflow.com/comment/32604247
has answer: http://stackoverflow.com/a/21586537
has answer: http://stackoverflow.com/a/51213405
has title: android getlastknownlocation always null in emulator
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/75416042
has comment: http://stackoverflow.com/comment/32609960
has comment: http://stackoverflow.com/comment/32603763
tagged with: android
has comment: http://stackoverflow.com/comment/32604021
has answer: http://stackoverflow.com/a/63263955
answer count: 4
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21586537
has comment: http://stackoverflow.com/comment/32603582
possible better answer: http://stackoverflow.com/a/63263955
score: 7
tagged with: java
has body: It seems a common issue, but i really can't understand why is it happening even though i read ton of simialr issues. I am playing with a basic location class on a emulator device, i set everything - permissions (FINE and COARSE) , i have set the coordinates in the DDMS i also tried using the telnet and then <geo fix ...> , but no matter what it always crashes witth nullpointer exception on the line with getlastknownlocation, any ideas whats wrong here ? public class MainActivity extends Activity implements LocationListener { private static LocationManager ok; private Location L; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ok=(LocationManager)this.getSystemService(ok.GPS_PROVIDER); L=ok.getLastKnownLocation(ok.GPS_PROVIDER); } @Override public void onLocationChanged(Location Loc) { try { double latop=Loc.getLatitude(); double longe=Loc.getLongitude(); Log.i("OK", "and"+longe+""+latop); } catch (NullPointerException e) { } }
upvote count: 7
type: Question
has comment: http://stackoverflow.com/comment/32603865
has comment: http://stackoverflow.com/comment/32603900

http://stackoverflow.com/comment/32670588
type: Comment
comment on: http://stackoverflow.com/a/21610532
type: AnswerComment
has text: IP is the IP address. I created a Local Queue using MQExplorer and I thought "SYSTEM.DEFAULT.LOCAL.QUEUE" is the Channel name. Do you have any idea how to find the channel name for the Local Queue
score: 0

http://stackoverflow.com/comment/32679802
comment on: http://stackoverflow.com/q/21623911
type: QuestionComment
type: Comment
has text: Just check this pkg-config --cflags --libs opencv
score: 0

http://stackoverflow.com/a/21578282
answers question: http://stackoverflow.com/q/21576482
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 2
has body: As Wiki states: SAML protocol messages are often carried directly in the URL query string of an HTTP GET request. Since the length of URLs is limited in practice, the HTTP Redirect binding is suitable for short messages, such as the message. Longer messages (e.g., those containing signed SAML assertions) should be transmitted via other bindings such as the HTTP POST Binding. SAML requests or responses transmitted via HTTP Redirect have a SAMLRequest or SAMLResponse query string parameter, respectively. Before it’s sent, the message is deflated, base64-encoded, and URL-encoded, in that order. Upon receipt, the process is reversed to recover the original message. the HTTP GET example is less than 600 characters long: <a href="https://idp.example.org/SAML2/SSO/Redirect?SAMLRequest=fZFfa8IwFMXfBb9DyXvaJtZ1BqsURRC2Mabbw95ivc5Am3TJrXPffmmLY3%2FA15Pzuyf33On8XJXBCaxTRmeEhTEJQBdmr%2FRbRp63K3pL5rPhYOpkVdYib%2FCon%2BC9AYfDQRB4WDvRvWWksVoY6ZQTWlbgBBZik9%2FfCR7GorYGTWFK8pu6DknnwKL%2FWEetlxmR8sBHbHJDWZqOKGdsRJM0kfQAjCUJ43KX8s78ctnIz%2Blp5xpYa4dSo1fjOKGM03i8jSeCMzGevHa2%2FBK5MNo1FdgN2JMqPLmHc0b6WTmiVbsGoTf5qv66Zq2t60x0wXZ2RKydiCJXh3CWVV1CWJgqanfl0%2Bin8xutxYOvZL18NKUqPlvZR5el%2BVhYkAgZQdsA6fWVsZXE63W2itrTQ2cVaKV2CjSSqL1v9P%2FAXv4C" rel="nofollow">https://idp.example.org/SAML2/SSO/Redirect?SAMLRequest=fZFfa8IwFMXfBb9DyXvaJtZ1BqsURRC2Mabbw95ivc5Am3TJrXPffmmLY3%2FA15Pzuyf33On8XJXBCaxTRmeEhTEJQBdmr%2FRbRp63K3pL5rPhYOpkVdYib%2FCon%2BC9AYfDQRB4WDvRvWWksVoY6ZQTWlbgBBZik9%2FfCR7GorYGTWFK8pu6DknnwKL%2FWEetlxmR8sBHbHJDWZqOKGdsRJM0kfQAjCUJ43KX8s78ctnIz%2Blp5xpYa4dSo1fjOKGM03i8jSeCMzGevHa2%2FBK5MNo1FdgN2JMqPLmHc0b6WTmiVbsGoTf5qv66Zq2t60x0wXZ2RKydiCJXh3CWVV1CWJgqanfl0%2Bin8xutxYOvZL18NKUqPlvZR5el%2BVhYkAgZQdsA6fWVsZXE63W2itrTQ2cVaKV2CjSSqL1v9P%2FAXv4C If you are using HTTP POST, the parameters of the Request go to the body. So no problem at all. But you should really check, if the message SAMLRequest is not too long. Security Note: Since with HTTP GET the whole Request and its parameters get l…
accepted answer of: http://stackoverflow.com/q/21576482
upvote count: 2

http://stackoverflow.com/comment/32575139
type: QuestionComment
has text: Yeah; onTouchEvent is still called as it should be.
comment on: http://stackoverflow.com/q/21566269
score: 0
type: Comment

http://stackoverflow.com/a/21624347
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/21624156
score: 3
answers question: http://stackoverflow.com/q/21624156
downvote count: 0
upvote count: 3
has body: From the JLS: If an integer addition overflows, then the result is the low-order bits of the mathematical sum as represented in some sufficiently large two's-complement format. If overflow occurs, then the sign of the result is not the same as the sign of the mathematical sum of the two operand values. Source: http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.18.2

http://stackoverflow.com/comment/32493107
score: 0
type: Comment
type: QuestionComment
has text: Whenever you get an exception, always print the full stack trace here. Also, let us knwo which line exactly is flagged.
comment on: http://stackoverflow.com/q/21520853

http://stackoverflow.com/a/21517866
type: Answer
has comment: http://stackoverflow.com/comment/32497186
upvote count: 1
has body: I think the following code like below satisfies your constraints and similar to what you want to achieve: public ArrayList&lt;ArrayList&lt;Integer&gt;&gt; deepCopy(ArrayList&lt;ArrayList&lt;Integer&gt;&gt; list) { ArrayList&lt;ArrayList&lt;Integer&gt;&gt; ret = new ArrayList&lt;ArrayList&lt;Integer&gt;&gt;(); deepCopy(list.iterator, ret); return ret; } private void deepCopy(Iterator&lt;ArrayList&lt;Integer&gt;&gt; it, ArrayList&lt;ArrayList&lt;Integer&gt;&gt; ret) { if (it.hasNext()) { ret.add(new ArrayList(it.next())); deepCopy(it, ret); } } It just visits the list and creates new lists recursively. With Integers there are no interesting uses cases though... Is this homework?
score: 1
answers question: http://stackoverflow.com/q/21517726
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21517726
has comment: http://stackoverflow.com/comment/32488502

http://stackoverflow.com/q/21639902
tagged with: selenium-webdriver
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21647483
has answer: http://stackoverflow.com/a/21639971
score: 1
tagged with: java
has body: I am writing an automation script in Java in selenium webdriver. When I try to logoff my main window screen I am getting a pop-up window that does not allow me to go to the main screen unless I click some option "Leave page" or "Stay on page" . Can I get the script to close this screen and logoff the main application.Firepath does not work for this as well. I am a beginner trying to learn automation.Thanks.
accepted answer: http://stackoverflow.com/a/21639971
type: Question
answer count: 2
tagged with: automated-tests
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/21647483
has title: How to get object of Pop-up screen that blocks the main screen using firepath in selenium webdriver?
upvote count: 1

http://stackoverflow.com/comment/32645089
has text: sho what if my jtable is just a drag-drop object, not a new one?
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21605879
type: AnswerComment

http://stackoverflow.com/q/21624257
score: 0
has comment: http://stackoverflow.com/comment/32675592
has answer: http://stackoverflow.com/a/21624555
has answer: http://stackoverflow.com/a/21624669
has body: I was wondering if it was possible to read a whole row of a MySQL table as a string, rather than having to split it up into separate types like different Strings, ints, booleans etc. The reason I'm asking is that this is for a shared package and so obviously each table has different columns and data types. It would be much easier if I could read the line as a string and then pass it off to the individual class dealing with the data from that table, rather than split it up into the different data types. Obviously this would only be feasible if looking for only a single row in the table private String row; public String getRow(){ return row; } public String getRowFromTable(){ Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection con = DriverManager.getConnection("jdbc:mysql://localhost/t", "", ""); Statement st = con.createStatement(); String sql = ("SELECT * FROM posts LIMIT 1;"); ResultSet rs = stmt.executeQuery(sql); row = rs.getRow(); // Basically, is this part possible? con.close(); }
has answer: http://stackoverflow.com/a/21624527
accepted answer: http://stackoverflow.com/a/21624527
tagged with: jdbc
answer count: 4
has title: Is it possible to read one line of a MySQL table as a string in Java?
has answer: http://stackoverflow.com/a/21624736
tagged with: java
tagged with: mysql
possible better answer: http://stackoverflow.com/a/21624555
type: Question
type: AnsweredQuestion

http://stackoverflow.com/a/21628619
has body: Look at this line: ses.setAttribute("userses", ses); You're passing your own session as an attribute. I think what you're trying to do is something like ses.setAttribute("userses", uname);
has comment: http://stackoverflow.com/comment/32683523
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21628464
answers question: http://stackoverflow.com/q/21628464
type: Answer
upvote count: 1
score: 1

http://stackoverflow.com/a/21523126
type: Answer
answers question: http://stackoverflow.com/q/21521807
has comment: http://stackoverflow.com/comment/32499502
has comment: http://stackoverflow.com/comment/32499649
has comment: http://stackoverflow.com/comment/32510556
has comment: http://stackoverflow.com/comment/32499273
score: 0
has body: Haven't you noticed that it is the power of 2 ? Why hadn't you used it? 2^N mod M is to be counted as long power=1L &lt;&lt; N; long temp=power/M; long result= power-temp*M;
has comment: http://stackoverflow.com/comment/32498636
has comment: http://stackoverflow.com/comment/32510461

http://stackoverflow.com/comment/32594865
type: Comment
has text: I cant open the link now at office , sorry , I'll check it later
score: 0
comment on: http://stackoverflow.com/a/21578201
type: AnswerComment

http://stackoverflow.com/comment/32642183
type: QuestionComment
has text: One way to get rid of a long file is to split it into many smaller ones. Oh wait... :)
score: 1
comment on: http://stackoverflow.com/q/21605309
type: Comment

http://stackoverflow.com/q/21613421
accepted answer: http://stackoverflow.com/a/21615751
has title: How to implement error handling in ANTLR4
has comment: http://stackoverflow.com/comment/32660099
type: AnsweredQuestion
tagged with: java
tagged with: error-handling
upvote count: 10
type: Question
score: 10
has answer: http://stackoverflow.com/a/21615751
has body: I have the following grammar for parsing first-order logic formulas applied over graphs: grammar Graph; /*------------------------------------------------------------------ * PARSER RULES *------------------------------------------------------------------*/ input : formula EOF ; formula : TRUE | FALSE | formula AND formula | formula OR formula | quantifier formula | ST condition ; condition : atom EQUALS QUOTE? (assignment | atom) QUOTE? ; quantifier : (FOREACH | EXISTS) variable IN domain ; domain : (GRAPH_A | GRAPH_B) ; atom : variable DOT property ; variable : (nodev | edgev) ; nodev : (NODE | NODE1) ; edgev : (EDGE | EDGE1) ; property : (COLOR | VALUE) ; assignment : (COLORTYPE | NUMBER) ; /*------------------------------------------------------------------ * LEXER RULES *------------------------------------------------------------------*/ TRUE : 'True' ; FALSE : 'False' ; AND : '&amp;' ; OR : '|' ; ST : '-&gt;' ; EXISTS : 'Exists' ; FOREACH : 'Foreach' ; NODE : 'node' ; NODE1 : 'node1' ; EDGE : 'edge' ; EDGE1 : 'edge1' ; IN : 'in' ; GRAPH_A : 'GraphA' ; GRAPH_B : 'GraphB' ; EQUALS : '=' ; DOT : '.' ; COLOR : 'color' ; VALUE : 'value' ; NUMBER : ('0'..'9')+ (DOT ('0'..'9')+)? ; QUOTE : '\'' ; COLORTYPE : ('a'..'z')+ ; WS : [ \t\r\n]+ -&gt; skip ; I believe that this is the final version of my grammar so now I want to specify some error handling for the input. The problem is that I don't know how. What I know is that after I parse the input I can iterate over the generated AST and this is the place to add the error handling. If the parse fails, return the parse exception; otherwise, I have specified the following cases for returning error message. There can't be 1 quantifier followed by -&gt; condition (this is a formula element) where condition is equal to atom=atom. In other words, if there is only quantifier then condition should be equal to atom EQUALS assignment. If there are 2 quantifiers the first should start with FOREACH The variable(s) in the quantifier…
answer count: 1
downvote count: 0
favorite count: 0
tagged with: antlr4

http://stackoverflow.com/a/21563375
downvote count: 0
answers question: http://stackoverflow.com/q/21562968
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/32569057
score: 2
has comment: http://stackoverflow.com/comment/32568862
has comment: http://stackoverflow.com/comment/32568805
has body: You need a reference to a Context which you can't have within a static initializer block because it does not accept parameters. Your best bet is to load the library within your own Application subclass in onCreate. package com.example; // imports public class CustomApplication extends Application { @Override public void onCreate() { super.onCreate(); String path = new File(getApplicationInfo().dataDir, "midi").getPath(); System.loadLibrary(path); } } Then add the name of your application to the manifest. e.g. ... &lt;application android:name="com.example.CustomApplication" ... If that doesn't work, you'll need some construct that allows passing in a reference while ensuring that the library is only loaded once. E.g. public class Init { private static final AtomicBoolean STATE = new AtomicBoolean(false); public static void init(Context context) { if (STATE.compareAndSet(false, true)) { String path = new File(context.getApplicationInfo().dataDir, "midi").getPath(); System.loadLibrary(path); } } } would run only the first time you call Init.init(somecontext), but I doubt that you can use it from within your Runnable.

http://stackoverflow.com/a/21561746
score: 4
upvote count: 4
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21561214
has comment: http://stackoverflow.com/comment/32572233
type: Answer
has comment: http://stackoverflow.com/comment/32593047
has comment: http://stackoverflow.com/comment/32566773
has body: Inheritance of interfaces really isn't "flaky" or complicated. They behave exactly the way abstract classes do, with the exceptions that you reference them differently (implements rather than extends) and that you're allowed to inherit as many interfaces as you like but can only have one superclass (abstract or not). As with other inheritance: If all you know about an object is that it implements an interface, then you can only access it through that interface. If you know that it implements another interface, or a specific superclass, or is an instance of a particular class, then you can cast it to those and access it through the exposed members of those. So, yes: If all your program knows is that the object is an instance of Animals, then all you can do is call what's declared on Animals. That means bark() plus whatever methods it inherits from Object (since everything is an Object directly or indirectly even if that isn't explicitly stated). If your program knows that the object is an implementation of dogIF or catIF -- because the variable type says it is, or because you've successfully typecast it to one of those interfaces -- you can also call the method(s) declared by those interfaces. By the way, the usual convention for interfaces is to name them like classes, with UppercasedFirstLetter... since in many cases the difference between an interface and a class really isn't significant to the folks using it. If your program happens to know that the object is a Dog, you can call anything it inherits from either Animals or dogIF, or that is provided directly by Dog. Of course it could actually be a Chihuahua (subclass of dog), but that's OK, the subclass will respond to anything the superclass would have responded to, in "the right way to maintain the semantics". (That is, a Chihuahua may respond to bark() by saying "yip yip yip grr yip!", but that method really shouldn't cause it to try to bite your ankle.) Hope that helps. It really isn't that complicated.
has comment: http://stackoverflow.com/comment/32566690
has comment: http://stackoverflow.com/comment/32571647
has comment: http://stackoverflow.com/comment/32565661
has comment: http://stackoverflow.com/comment/32566561
accepted answer of: http://stackoverflow.com/q/21561214
has comment: http://stackoverflow.com/comment/32566191
has comment: http://stackoverflow.com/comment/32565906

http://stackoverflow.com/comment/32706549
has text: yes both are random, but user can determine the attack percentage
comment on: http://stackoverflow.com/q/21640920
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21577463
answer count: 1
tagged with: esper
type: UnansweredQuestion
score: 0
tagged with: java
has body: Working with ESPER CEM and maritime ais tracks. I want to detect when a ship change draught to over 11 meters from under 11 mesters. select new from pattern [every new=VoyageReport(draught &lt; 11) -&gt; (VoyageReport(mmsi=new.mmsi and draught &gt; 11))] *Server messege:*Statement already destroyed Source: http://esper.codehaus.org/esper-4.4.0/doc/reference/en/html/index.html hoping somone can help me im pretty new to this. Best regards Peter
type: Question
has title: detect when a ship change draught to over 11 meters from under 11 mesters
has answer: http://stackoverflow.com/a/21604656

http://stackoverflow.com/q/21561542
has answer: http://stackoverflow.com/a/21563524
has comment: http://stackoverflow.com/comment/32569356
tagged with: computer-vision
has answer: http://stackoverflow.com/a/21561664
has comment: http://stackoverflow.com/comment/32578797
score: 8
has comment: http://stackoverflow.com/comment/32579040
has title: Java library or strategy to tell if an image contains a signature
downvote count: 0
type: UnansweredQuestion
tagged with: image-processing
tagged with: opencv
tagged with: java
upvote count: 8
type: Question
answer count: 2
has body: I have an image file, and I need to determine if a specified area of this image contains a signature. Or to put it in end-user terms, "Has this document been signed?" What I have done so far is to examine all the pixels contained in the area, to calculate an average "darkness", and compare that to a reference value. If the difference in darkness exceeds some threshold, then I consider it signed. The problem with this (admittedly simplistic) approach is that because the pixels of the signature itself are such a small fraction of area, I have to use a very low darkness threshold, which results in a large number of false positives. I can't distinguish a real signature from stray markings, smudges, fax artifacts, etc. To be clear...I'm not trying to match any specific signature or set of signatures. That is, I don't care who signed it, only whether it is signed. Is anyone aware of a Java library that can do this, or of a better approach to this problem than what I am currently doing? EDIT: This is an example of the kinds of images I am working with. This document would be faxed to the recipient, signed and faxed back. It won't be this clean-looking by the time I need to look for a signature.
has comment: http://stackoverflow.com/comment/32565134
has comment: http://stackoverflow.com/comment/32568457
favorite count: 0

http://stackoverflow.com/comment/32720187
score: 1
has text: "The thing is, I dont want to add duplicated id to the arraylist. " I think you should redesign your structures.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21649727

http://stackoverflow.com/q/21650851
favorite count: 0
upvote count: 28
has comment: http://stackoverflow.com/comment/32725184
has title: .jar error - could not find or load main class
answer count: 4
has body: I tried to put HelloWorld in a .jar file and running it, but it doesn't work. I created the java file and typed in the program, and then wrote in cmd: javac HelloWorld.java java HelloWorld and it worked. Then I entered echo Main-Class: HelloWorld &gt;manifest.txt jar cvfm HelloWorld.jar manifest.txt HelloWorld.class and got the output added manifest adding: HelloWorld.class(in = 426) (out= 288)(deflated 32%) I then entered java -jar HelloWorld.jar HelloWorld.jar and the first line worked, while the second line gave me an error: Error: Could not find or load main class path\HelloWorld.jar which is the same output I got (in a rapidly closing window) when I tried to open it with the java.exe file in 64 bit jre7\bin, jdk1.7.0_51\bin, jdk1.7.0_51\jre\bin, as well as 32 bit jre7\bin. I've uninstalled and reinstalled both my jre and jdk and recreated my .class and .jar files, but the problem persists. I'm on win8. Edit: I tried to do as aetheria suggested, but no luck. I put HelloWorld.java in path\com\stackoverflow\user\blrp, compiled it, and it worked by entering java com.stackoverflow.user.blrp.HelloWorld in path. I then created the manifest and jar by: (echo Manifest-Version: 1.0 echo Class-Path: . echo Main-Class: com.stackoverflow.user.blrp.HelloWorld) &gt;manifest.txt jar cvfm HelloWorld.jar manifest.txt com\stackoverflow\user\blrp\HelloWorld.class and got the output added manifest adding: com/stackoverflow/user/blrp/HelloWorld.class(in = 454) (out= 312)(deflat ed 31%) but still, java -jar HelloWorld.jar worked and HelloWorld.jar didn't (same error). I also tried not doing the package thing, just the Class-Path in manifest, same result. (Also, I solved the problem prior to asking the question by use of a .bat file, but it'd still be sweet to get that jar working.)
has answer: http://stackoverflow.com/a/21760426
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/32489582
has comment: http://stackoverflow.com/comment/32734654
has answer: http://stackoverflow.com/a/32489582
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/32725028
has comment: http://stackoverflow.com/comment/32725385
has answer: http://stackoverflow.com/a/36658429
tagged with: java
has answer: http://stackoverflow.com/a/21650867
score: 27
accepted answer: http://stackoverflow.com/a/21760426
tagged with: jar

http://stackoverflow.com/comment/32656858
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21613181
type: AnswerComment
has text: oh wait a minute, it just dawned on me. I had to read over your explanation a few times for it to sink in. thanks again! wonderful explanation.

http://stackoverflow.com/a/21636198
downvote count: 0
has comment: http://stackoverflow.com/comment/32697446
has comment: http://stackoverflow.com/comment/32696749
score: 3
has comment: http://stackoverflow.com/comment/32697116
has comment: http://stackoverflow.com/comment/32697838
upvote count: 3
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32697188
answers question: http://stackoverflow.com/q/21636036
has body: Instead of- setContentView(R.layout.main); write this- setContentView(R.layout.loginsignup);
has comment: http://stackoverflow.com/comment/32697624
accepted answer of: http://stackoverflow.com/q/21636036
has comment: http://stackoverflow.com/comment/32697250
type: Answer
has comment: http://stackoverflow.com/comment/32697146
has comment: http://stackoverflow.com/comment/32696825
has comment: http://stackoverflow.com/comment/32697953
has comment: http://stackoverflow.com/comment/32696898

http://stackoverflow.com/comment/32620297
score: 2
comment on: http://stackoverflow.com/q/21592234
has text: why php? please check your tags
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32527784
has text: How are you switching screens?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21538858
score: 0

http://stackoverflow.com/q/21531858
has body: Although i am using the fixedRate method instead of simple schedule does this ensure concretely that no background activity or garbage collection can knock my timing off? Can delays be long enough to make subsequent runs miss the entire window i've given it ? (8:00am to 8:05 am).I've tested executions by changing the OS time and it works but this is first time using scheduling and timing logic. //1 day static final long timeDelay = 864000000; public static void main(String[] args) { Timer timer = new Timer(); TimerTask startBegin = new TimerTask() { @Override public void run() { Calendar cal = Calendar.getInstance(); int month = cal.get(Calendar.MONTH); // 0 to 11 int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH); int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); int hour = cal.get(Calendar.HOUR_OF_DAY); int minute = cal.get(Calendar.MINUTE); // March, June, Sept, Dec, First Tues at 8 a.m if(((month == 2)||(month == 5)||(month == 8)||(month == 11)) &amp;&amp; (dayOfMonth &lt;7) &amp;&amp; (hour == 8) &amp;&amp; (minute &gt;= 0 &amp;&amp; minute &lt;5)) { begin(); } } }; timer.scheduleAtFixedRate(startBegin, 0, timeDelay); }
tagged with: timer
type: UnansweredQuestion
has title: Can delays interfere with my timing logic?
tagged with: calendar
tagged with: java
has answer: http://stackoverflow.com/a/21532060
type: Question
has answer: http://stackoverflow.com/a/21531995
score: 0
has answer: http://stackoverflow.com/a/21532867
tagged with: scheduled-tasks
has answer: http://stackoverflow.com/a/21532016
answer count: 4

http://stackoverflow.com/comment/32519248
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21535466
has text: can you ex I get "CÃ©leste" but it has to be Céleste mean ?
score: 0

bit-manipulation
tags question: http://stackoverflow.com/q/21517361
type: Tag
tags question: http://stackoverflow.com/q/21591637
tags question: http://stackoverflow.com/q/21619397
tags question: http://stackoverflow.com/q/21588470
tag name: bit-manipulation
tags question: http://stackoverflow.com/q/21652237

http://stackoverflow.com/q/21527082
favorite count: 0
has comment: http://stackoverflow.com/comment/32504102
has answer: http://stackoverflow.com/a/21542293
tagged with: build
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32503765
has answer: http://stackoverflow.com/a/21527900
accepted answer: http://stackoverflow.com/a/21527900
has comment: http://stackoverflow.com/comment/32504123
score: 1
tagged with: java
has body: I have this ant script: &lt;sequential&gt; &lt;echo message="Deleting needed folder" /&gt; &lt;property name="bigPathToFolder" value="${basePath}/pathToFolder" /&gt; &lt;delete dir="bigPathToFolder" quiet="false"/&gt; &lt;echo message="Delete success" /&gt; &lt;/sequential&gt; In console I see Deleting needed folder and after Delete success, but the content of the folder and folder don't change. What did I do wrong?
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/32503975
tagged with: ant
possible better answer: http://stackoverflow.com/a/21542293
downvote count: 0
has comment: http://stackoverflow.com/comment/32503849
has comment: http://stackoverflow.com/comment/32503907
upvote count: 1
has title: Why does not ant delete task work?

http://stackoverflow.com/comment/32759828
type: QuestionComment
has text: have you looked at magnifierui class?
comment on: http://stackoverflow.com/q/21672466
score: 0
type: Comment

http://stackoverflow.com/a/21630000
type: AcceptedAnswer
has body: JUnit creates a new ClassToTestTest object for each of your test methods. Therefore no field can sneak to another test. For details: http://martinfowler.com/bliki/JunitNewInstance.html
answers question: http://stackoverflow.com/q/21627799
accepted answer of: http://stackoverflow.com/q/21627799
type: Answer
upvote count: 5
downvote count: 0
has comment: http://stackoverflow.com/comment/32686247
score: 5

http://stackoverflow.com/a/21533747
type: Answer
answers question: http://stackoverflow.com/q/21533356
upvote count: 5
score: 5
has body: How about your extend the JButton class. class MyButton extends JButton{ public int index; MyButton(){super();} MyButton(int index){super();this.index=index;} } When you need to get the index, cast it back to MyButton and get the index; MyButton mybtn = (MyButton)this;
downvote count: 0

http://stackoverflow.com/comment/32714025
comment on: http://stackoverflow.com/a/21644416
type: AnswerComment
type: Comment
has text: The significand of an IEEE-754 32-bit binary floating-point object has 24 bits, not 23. 23 are encoded in the significand field, one is encoded via the exponent field.
score: 1

http://stackoverflow.com/comment/32712994
type: Comment
has text: Hi Rath, please try with these code. http://stackoverflow.com/questions/21245196/how-to-delete-all-data-from-sd-card/21249622#21249622
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/21645572

http://stackoverflow.com/comment/32671822
score: 0
has text: I edited my post, adding the code i use to read a blob field. can u take a look? Thank you
type: Comment
comment on: http://stackoverflow.com/a/21572999
type: AnswerComment

http://stackoverflow.com/q/21574696
possible better answer: http://stackoverflow.com/a/21574918
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21574918
downvote count: 0
tagged with: java
accepted answer: http://stackoverflow.com/a/21574835
has answer: http://stackoverflow.com/a/21575045
linked to: http://stackoverflow.com/q/4343202
type: Question
has answer: http://stackoverflow.com/a/21574835
score: 4
tagged with: wildcard
has answer: http://stackoverflow.com/a/21574956
tagged with: arraylist
linked to: http://stackoverflow.com/q/897935
upvote count: 4
tagged with: generics
has body: Consider the following codes: class Super {} class Sub extends Super {} class Test { public static void main(String[] args) { List&lt;? extends Super&gt; list = new ArrayList&lt;Sub&gt;(); //1 list.add(new Sub()); //2 } } Line 1 compiles successfully, but line 2 fails compilation: The method add(capture#2-of ? extends Super) in the type List&lt;capture#2-of ? extends Super&gt; is not applicable for the arguments (Sub) My questions are: 1) Why does line 1 successfully compile? 2) Is line 1 a good practice in declaring a List (or other collections)? 3) Why does line 2 fail compilation, after list was declared to be type Sub in line 1? 4) Eclipse's autocompletion says only "null" elements are allowed in list now. Why? Thanks a lot!
has title: Can I use generics wildcard in List declaration?
favorite count: 0
has answer: http://stackoverflow.com/a/21574919
linked to: http://stackoverflow.com/q/2723397
answer count: 5

file
tags question: http://stackoverflow.com/q/21589575
type: Tag
tags question: http://stackoverflow.com/q/21619304
tags question: http://stackoverflow.com/q/21651658
tags question: http://stackoverflow.com/q/21624965
tags question: http://stackoverflow.com/q/21532776
tags question: http://stackoverflow.com/q/21578557
tags question: http://stackoverflow.com/q/21577137
tags question: http://stackoverflow.com/q/21576584
tags question: http://stackoverflow.com/q/21663556
tags question: http://stackoverflow.com/q/21556839
tags question: http://stackoverflow.com/q/21542881
tags question: http://stackoverflow.com/q/21530325
tags question: http://stackoverflow.com/q/21646683
tag name: file
tags question: http://stackoverflow.com/q/21655369
tags question: http://stackoverflow.com/q/21641455
tags question: http://stackoverflow.com/q/21642617
tags question: http://stackoverflow.com/q/21609932
tags question: http://stackoverflow.com/q/21622382
tags question: http://stackoverflow.com/q/21533748
tags question: http://stackoverflow.com/q/21597348
tags question: http://stackoverflow.com/q/21601993
tags question: http://stackoverflow.com/q/21673265
tags question: http://stackoverflow.com/q/21633196
tags question: http://stackoverflow.com/q/21645572
tags question: http://stackoverflow.com/q/21630384
tags question: http://stackoverflow.com/q/21646912
tags question: http://stackoverflow.com/q/21515126
tags question: http://stackoverflow.com/q/21563512
tags question: http://stackoverflow.com/q/21590117
tags question: http://stackoverflow.com/q/21639667
tags question: http://stackoverflow.com/q/21527197
tags question: http://stackoverflow.com/q/21606027
tags question: http://stackoverflow.com/q/21642101
tags question: http://stackoverflow.com/q/21564757
tags question: http://stackoverflow.com/q/21671003
tags question: http://stackoverflow.com/q/21668382
tags question: http://stackoverflow.com/q/21650634
tags question: http://stackoverflow.com/q/21586612
tags question: http://stackoverflow.com/q/21647095
tags question: http://stackoverflow.com/q/21628722
tags question: http://stackoverflow.com/q/21662439
tags question: http://stackoverflow.com/q/21558092
tags question: http://stackoverflow.com/q/21621955
tags question: http://stackoverflow.com/q/21518998

http://stackoverflow.com/comment/32664374
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21614897
has text: Actually I solved the cycle of layouts being opened just now, but now even if the image is changed, the buttons don't seem to work

teradata
type: Tag
tags question: http://stackoverflow.com/q/21592383
tags question: http://stackoverflow.com/q/21608095
tag name: teradata
tags question: http://stackoverflow.com/q/21605803

http://stackoverflow.com/q/21531351
tagged with: tomcat7
has comment: http://stackoverflow.com/comment/32514822
has title: how to do URL-Rewriting when browser cookies are disabled?
tagged with: java
type: Question
has body: I am trying to achieve URL-Rewriting for my Application. I am using java,servlet, JSP, tomcat 7 as part of the technologies. BackGround: The reason for URL-Rewriting is that when my browser cookies are disabled the connection between the client and the server is not established and session on being lost and for each request that comes from the browser the server thinks as a new request. By reading through the internet found that URL-Rewriting is one solution. My application has just one JSP page called root.jsp This is how i am loading the jsp page from my servlet. I have only one servlet that handles all the request. getServletContext().getRequestDispatcher("/view/root.jsp").forward( request, response); In root.jsp includes another jsp pages as a part of root.jsp it shown below. Based on the programming logic the respective JSP page that needs to be included get added. &lt;div class="grey_container"&gt; &lt;jsp:include page="${requestScope.jspPage.pageFileUrl}" flush="false" /&gt; &lt;/div&gt; I read that the URL-rewriting is possible using HttpServletResponse encodeURL() and encodeRedirectURL(). For the JSP pages this encodeURL is achievied using &lt;c:url&gt; WHat i have tried In my servlet show below, I did not see any Jsession ID being appended to the URL. getServletContext().getRequestDispatcher(response.encodeURL("/view/root.jsp")).forward( request, response); getServletContext().getRequestDispatcher(response.encodeRedirectURL("/view/root.jsp")).forward( request, response); Next thought that i might need to configure something similar in JSP using &lt;c:url&gt; tag. So tried to configure in the &lt;jsp: include&gt; but it is throwing some compilation exception. so at this point of time i tried different approaches to make that JSP compilation error go away but was not successful. So thought that is it possible configure to &lt;jsp: include&gt; to have &lt;c:url&gt; was not sure. configuring in JSP with &lt;c:url&gt; is needed? Below is the exception when i tr…
tagged with: jsp
has comment: http://stackoverflow.com/comment/32515820
tagged with: servlets
has comment: http://stackoverflow.com/comment/32515302
score: 0
has comment: http://stackoverflow.com/comment/32515667
linked to: http://stackoverflow.com/q/962729
answer count: 0
type: UnansweredQuestion

http://stackoverflow.com/comment/32695195
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21584859
score: 0
has text: thanks David, i see the formatting tags.

http://stackoverflow.com/comment/32567317
type: AnswerComment
score: 0
type: Comment
has text: What do you mean with '&& takes care'?
comment on: http://stackoverflow.com/a/21562505

http://stackoverflow.com/a/21518207
type: Answer
has comment: http://stackoverflow.com/comment/32489343
has comment: http://stackoverflow.com/comment/32488835
answers question: http://stackoverflow.com/q/21518177
has comment: http://stackoverflow.com/comment/32488979
has comment: http://stackoverflow.com/comment/32489012
has body: You're setting the text of outputTextArea to output and then immediately replacing that with other text (the "There are ..." string). You probably want to be appending strings instead of setting the text twice. Maybe something like this: private void simulateBtnActionPerformed (ActionEvent event) { outputTextArea.setText(output + "\nThere are "+ Integer.valueOf(numLockerTextField.getText()) +" lockers, and "+ runLockers(0) +" are left open."); }
has comment: http://stackoverflow.com/comment/32488886
has comment: http://stackoverflow.com/comment/32489279
score: 0
accepted answer of: http://stackoverflow.com/q/21518177
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32488859
has comment: http://stackoverflow.com/comment/32489217
has comment: http://stackoverflow.com/comment/32488925
has comment: http://stackoverflow.com/comment/32488799
has comment: http://stackoverflow.com/comment/32488941

http://stackoverflow.com/comment/32557006
has text: @Sebastian where I should add that? Because It seems that at the other question the answerers are responding by the same thing, but I cannot find where to put that? Should I do it to define the return type next to getPossibleActions()? or should I cast the movement I return. I tried both, but it does not work for me...
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21556774
score: 0

jax-ws
tags question: http://stackoverflow.com/q/21590210
type: Tag
tags question: http://stackoverflow.com/q/21528651
tags question: http://stackoverflow.com/q/21551798
tags question: http://stackoverflow.com/q/21531757
tags question: http://stackoverflow.com/q/21576233
tags question: http://stackoverflow.com/q/21625400
tags question: http://stackoverflow.com/q/21596080
tag name: jax-ws
tags question: http://stackoverflow.com/q/21519046
tags question: http://stackoverflow.com/q/21583396

http://stackoverflow.com/q/21673034
has comment: http://stackoverflow.com/comment/32760904
upvote count: 0
score: -1
has title: Internal Server Error In Web Application Project
tagged with: servlets
linked to: http://stackoverflow.com/q/664331
has comment: http://stackoverflow.com/comment/32763263
has comment: http://stackoverflow.com/comment/32764427
answer count: 1
has comment: http://stackoverflow.com/comment/32761073
tagged with: jsp
has answer: http://stackoverflow.com/a/21956989
has comment: http://stackoverflow.com/comment/32763096
tagged with: tomcat
has comment: http://stackoverflow.com/comment/32760745
favorite count: 0
type: UnansweredQuestion
has body: I have a Dynamic application in which I have a JSP file which is sending a string to a Servlet which is in another project which is a Web application Project. I am using Tomcat server in JSP project and the server is starting just fine but when I am trying to run the web application on local host I am getting HTTP ERROR 500 Problem accessing /jsptoservlettocloud. Reason: INTERNAL_SERVER_ERROR This is my JSP FILE <% String str= "Shanx"; URL u = new URL("http://localhost:8080/ServletToCloud/JSPToServletToCloudServlet"); HttpURLConnection huc = (HttpURLConnection)u.openConnection(); huc.setRequestMethod("GET"); huc.setDoOutput(true); ObjectOutputStream objOut = new ObjectOutputStream(huc.getOutputStream()); objOut.writeObject(str); objOut.flush(); objOut.close(); %> This is my Servlet Class public class JSPToServletToCloudServlet extends HttpServlet { String str; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ObjectInputStream ois = new ObjectInputStream(request.getInputStream()); try { str= (String) ois.readObject(); } catch (ClassNotFoundException e) { e.printStackTrace(); } finally { ois.close(); } System.out.println("Servlet received : " + str); } } This is my Web.xml file JSPToServletToCloud pack.exp.JSPToServletToCloudServlet JSPToServletToCloud /jsptoservlettocloud index.html </web-app> In the url ServletToCloud is the name of the web application project and JSPToServletToCloudServlet is the name of the servlet. Is this url correct.
tagged with: java
has comment: http://stackoverflow.com/comment/32760920
downvote count: 1
type: Question

http://stackoverflow.com/q/21654300
has answer: http://stackoverflow.com/a/21654367
tagged with: user-interface
score: 0
answer count: 3
has comment: http://stackoverflow.com/comment/32728507
has answer: http://stackoverflow.com/a/21654351
type: UnansweredQuestion
tagged with: swing
tagged with: java
has body: So I've made 3 different classes, one to construct a text field, one for a label, and one for a slider. The problem I'm having is that in the slider listener, if set on 1(out of 3) set the label to " randomInt + randomInt" which I know how to randomize the numbers, it's just altering the text of the label which is made in a different class. here is my main fnctn followed by the two classes: import javax.swing.*; import javax.swing.event.*; import java.awt.*; public class driver { public static void main(String[] args) { colorfulLabel blueLabel = new colorfulLabel("", Color.yellow); colorfulTextField redTextField = new colorfulTextField(Color.red,15); RatingSlider mathSlide = new RatingSlider(JSlider.HORIZONTAL , 0, 3, 0); JFrame frame = new JFrame("Math"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(); panel.add(blueLabel); panel.add(redTextField); panel.add(mathSlide); frame.getContentPane().add(panel); frame.pack(); frame.setVisible(true); } } import javax.swing.*; import java.awt.*; public class colorfulLabel extends JLabel { //constructor uses one color parameter to respresent bg color //creates label using bg color //calls parent constructor using super() //private Color color; public colorfulLabel(String text,Color bg){ super(text); setBackground(bg); setOpaque(true); } } //RatingSlider import javax.swing.*; import java.awt.*; import java.util.Random; import javax.swing.event.*; public class RatingSlider extends JSlider { Random generator = new Random(); private JSlider difficultySlider; //accepts horizontal paramater, a min, a max, and starting point for slider public RatingSlider(int horiz, int start, int max, int min){ super(horiz, start, max, min); difficultySlider = new JSlider(horiz, start, max, min); difficultySlider.setMajorTickSpacing(1); difficultySlider.setMinorTickSpacing(0); setPaintTicks(true); setPaintLabels(true); difficultySlider.setAlignmentX(Component.LEFT_ALIGNMENT); JPanel Slide = new JPanel(); BoxLayout…
has answer: http://stackoverflow.com/a/21654415
has title: Java GUI components
type: Question

http://stackoverflow.com/comment/32685565
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/21630152
type: Comment
has text: This validates any of the 3 conditions but only one at a time, I mean, if at least one of those conditions is true it will return true. Does it have to comply with the 3 validations at the same time? (like have at least one of each?)

http://stackoverflow.com/a/21656903
has comment: http://stackoverflow.com/comment/32732854
score: 6
has body: You could use the split() method. It takes one argument in the form of a regex string and outputs an array of strings, split around the regex. String[] stringArray = URL.split("/"); Will probably output an array like: String[] stringArray = {"http:","","abcd.com","region","country","state","123xyzCONSTANTTEXT.html"}; And then use split again on an array index: String[] stringArray2 = stringArray[7].split("CONSTANTTEXT.html"); To retrieve 123xyz, which will be stored in stringArray2[0]
has comment: http://stackoverflow.com/comment/70996848
answers question: http://stackoverflow.com/q/21656835
upvote count: 7
has comment: http://stackoverflow.com/comment/70996798
downvote count: 1
type: Answer

http://stackoverflow.com/comment/32709095
comment on: http://stackoverflow.com/a/21643108
score: 0
type: AnswerComment
has text: It tells me I have duplicate variables when I do this. Is there any way I can just reset the value for my variable "input" and for "output"?
type: Comment

http://stackoverflow.com/q/21553252
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21555375
downvote count: 0
tagged with: quartz-scheduler
tagged with: cluster-computing
has body: Using Apache 2.11.0 here. I am writing a little Camel-based app (using Spring XML) that consumes messages off a queue (inputQueue), aggregates them, processes the aggregated batch, and then sends out a generated report. I'd like to deploy this app (widget-reporter.war) to multiple Tomcat instances and cluster them so that if one node goes down, it is still running on other nodes and the report will still get generated. So far the route's pseudo-code is as follows: <from uri="activemq:queue:inputQueue" /> /fizz/buzz <to uri="bean:reportGenerator?method=runReport"/> So, as you can see, we dequeue messages off of inputQueue, send them to an aggregator (which correlates them on an xpath expression), and after we reach 500 messages we send the aggregated exchange off to a reportGenerator. I have this working locally (1 node) perfectly. Now I'm trying to deploy this app to multiple Tomcat instances, but I only want it running on 1 node at a time. In other words, if I have this app deployed to 5 Tomcat instances, I don't want 5 Tomcats all consuming from inputQueue at the same time: only 1 should be operating at any given time, and the other 4 should be idling, waiting for the primary to failover to them. It looks like Camel Quartz allows for such clustering, but the problem is that it requires me to start my route with a quartz:// endpoint, and not activemq. So I'd have to have something like this (which doesn't work): <from uri="quartz://runWidgetReporterExclusively?cron=0+15,45+0-16+?+*+SAT" /> <from uri="activemq:queue:inputQueue" /> /fizz/buzz <to uri="bean:reportGenerator?method=runReport"/> Does anybody know how I can either: Implement Camel-Quartz clustering into my existing route, and if so, can you give me a specific code example?; or Implement 1-node-at-a-time clustering using any Java/Camel technology, not just Camel-Quartz?
type: Question
score: 3
tagged with: java
tagged with: apache-camel
has title: How to use Camel Quartz clustering in tandem with queue consumption?
upvote count: 3
answer count: 2
tagged with: high-availability
favorite count: 0
has answer: http://stackoverflow.com/a/21568969

http://stackoverflow.com/comment/33211845
has text: can you please tell me, can i use these jars in the production also?
comment on: http://stackoverflow.com/a/21648385
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32733323
type: Comment
has text: The missing ']' was actually a typo in the question. What version of Maven are you using? Can you confirm that all .css files are removed except for .min.css files and that all normal non-css files remain?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21656547

http://stackoverflow.com/q/21572202
has body: string input = "12+5-1"; Expected output would be: 16 The algorithm should identify the operators(+,-,*,/) and then do the operations one by one between the given numbers as inputs. I initially created a string array string[] strArrInput = input; Somebody advised me however that I'm being inefficient that way because a string is already a character array. I need help with this logic. EDIT: By the way, I'm trying to make a scientific calculator that could do PEMDAS.
has comment: http://stackoverflow.com/comment/32584439
score: 0
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32584371
has answer: http://stackoverflow.com/a/21572847
has answer: http://stackoverflow.com/a/21572352
has comment: http://stackoverflow.com/comment/32584385
linked to: http://stackoverflow.com/q/3422673
has title: I want to perform multiple mathematical operations within my string
answer count: 3
has comment: http://stackoverflow.com/comment/32584859
tagged with: string
duplicate of: http://stackoverflow.com/q/3422673
linked to: http://stackoverflow.com/q/7487908
type: UnansweredQuestion
tagged with: android
has answer: http://stackoverflow.com/a/21572796

http://stackoverflow.com/q/21584930
tagged with: ssl
has title: startTLS in apache mina without clientside authentication
type: Question
score: 0
answer count: 1
has body: I am trying to implement startTLS in apache Mina taking following reference. http://mina.apache.org/mina-project/apidocs/org/apache/mina/filter/ssl/SslFilter.html My code is as follows: @Override public void messageReceived(IoSession session, Object message) throws Exception { jsonparser(msg); if (condition) { startTLS(); } } SslFilter sslFilter; public void startTLS() { try { SSLContext sslContext = SSLContext.getInstance("TLSv1"); sslContext.init(null, null, new SecureRandom()); sslFilter = new SslFilter(sslContext); sslFilter.setUseClientMode(true); sslFilter.setNeedClientAuth(false); session.getFilterChain().addFirst("mySSL", sslFilter); session.setAttribute(SslFilter.DISABLE_ENCRYPTION_ONCE, Boolean.TRUE); assert session.getAttribute(SslFilter.DISABLE_ENCRYPTION_ONCE) == null; } catch (Exception e) { e.printStactTrace(); } } I am trying to put things using JSON. So every message I received I am parsing with JSON library. Negotiation message is : SESSION_UNSECURED Track trace is as follows: 02-05 12:50:20.365: W/System.err(994): Unexpected character (S) at position 0. 02-05 12:50:20.374: W/System.err(994): at org.json.simple.parser.Yylex.yylex(Yylex.java:610) 02-05 12:50:20.394: W/System.err(994): at org.json.simple.parser.JSONParser.nextToken(JSONParser.java:269) 02-05 12:50:20.394: W/System.err(994): at org.json.simple.parser.JSONParser.parse(JSONParser.java:118) 02-05 12:50:20.404: W/System.err(994): at org.json.simple.parser.JSONParser.parse(JSONParser.java:81) 02-05 12:50:20.444: W/System.err(994): at org.json.simple.parser.JSONParser.parse(JSONParser.java:75) 02-05 12:50:20.444: W/System.err(994): at network.com.parse(com.java:146) 02-05 12:50:20.444: W/System.err(994): at network.com.messageReceived(com.java:106) 02-05 12:50:20.474: W/System.err(994): at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:690) 02-05 12:50:20.474: W/System.err(994): at org.apache.mina.core.filterchain.DefaultIoFilterCh…
tagged with: starttls
type: UnansweredQuestion
tagged with: handshake
has answer: http://stackoverflow.com/a/23967696
tagged with: apache-mina
tagged with: java

http://stackoverflow.com/comment/32703824
score: 0
type: AnswerComment
has text: you really need to learn about dependencies in java... if the compiler says cannot be resolved, you need to import the missing class, which in this case is import org.codehaus.jackson.JsonNode;
type: Comment
comment on: http://stackoverflow.com/a/21639637

http://stackoverflow.com/comment/32752438
has text: I think so, I installed 1.6 but I think 1.7 was on it by default.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21568166
score: 0

http://stackoverflow.com/q/21674661
tagged with: oracle-database
has answer: http://stackoverflow.com/a/21677159
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21677159
has answer: http://stackoverflow.com/a/21674950
tagged with: java
has title: How to get array of object type parse in java from oracle procedure
type: Question
accepted answer: http://stackoverflow.com/a/21674950
tagged with: oracle-type
has body: I have a oracle procedure which return two parameter, 1st is array object type and 2nd is number. My procedure is : CREATE OR REPLACE PROCEDURE APPS.xx_push_notification ( p_user_name IN VARCHAR2, p_hr_type IN VARCHAR2, p_ret_array OUT NOCOPY XX_WF_SVC_NTF_ARRAY, p_ret_array_size OUT NOCOPY NUMBER ) AS --l_item_type IN VARCHAR2,l_message_names IN VARCHAR2, l_orig_system VARCHAR2 (4000); l_orig_system_id NUMBER; l_ret_array xx_wf_svc_ntf_array; l_ret_array_size NUMBER; l_item_type VARCHAR2 (1000); l_message_names VARCHAR2 (4000); l_latest_ntf_id NUMBER; CURSOR cur_hrms ( cur_orig_system VARCHAR2, cur_orig_system_id NUMBER ) IS ...................... ...................... ...................... BEGIN ...................... ...................... ...................... p_ret_array := xx_wf_svc_ntf_array (); IF p_hr_type = 'HR_ABSENCES' THEN FOR c1_rec IN cur_hrms (l_orig_system, l_orig_system_id) LOOP p_ret_array.EXTEND; p_ret_array (p_ret_array.COUNT) := xx_wf_svc_ntf_record (c1_rec.NOTIFICATION_ID, c1_rec.CONTEXT, c1_rec.FROM_USER, c1_rec.TO_USER, c1_rec.SUBTYPE); END LOOP; p_ret_array_size := p_ret_array.COUNT; END IF; END; / oracle type object : create or replace type xx_wf_svc_ntf_record is object (NOTIFICATION_ID NUMBER, CONTEXT VARCHAR2(2000), FROM_USER VARCHAR2(320), TO_USER VARCHAR2(320), SUBJECT VARCHAR2(2000), SUBTYPE VARCHAR2(32)); / oracle type array : create or replace type xx_wf_svc_ntf_array is table of xx_wf_svc_ntf_record ; / My java code is : ....... ....... db = new DBConnectionManager(); conn=db.getConnection(); if(conn!=null) { cstmt = conn.prepareCall("{call xx_push_notification(?, ?, ?, ?)}"); cstmt.setString(1, UserName); cstmt.setString(2, NotificationType); cstmt.registerOutParameter(3, OracleTypes.ARRAY,typeTableName); cstmt.registerOutParameter(4, Types.INTEGER); cstmt.execute(); int newRecord=cstmt.getInt(4); System.out.println("Total New Record : "+newRecord); } ......... ......... I get 2nd out parameter which is return array size. I ha…
score: 0
answer count: 2
tagged with: procedure

http://stackoverflow.com/comment/32783640
type: Comment
comment on: http://stackoverflow.com/a/21673812
has text: What do you mean with "demanding"? You were showing a repository method, which clearly makes the impression you want to manage cache invalidation at exactly that level. If you're looking for a solution closer to what you have already, you should update the question accordingly. We can just judge from what you show :).
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32518893
type: QuestionComment
has text: The default value of all the elements of int array is 0 so check whether you have set the any value successfully.
score: 1
comment on: http://stackoverflow.com/q/21534809
type: Comment

http://stackoverflow.com/comment/32623570
score: 0
type: Comment
has text: while compiling ur source code from cmd/terminal u have to be outside the package. try running this compile command: javac textfiles\*.java
type: QuestionComment
comment on: http://stackoverflow.com/q/21594025

http://stackoverflow.com/comment/32723667
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21651285
has text: Yeah, this wasn't for any homework assignment. I am just trying to make fake ideas to help me to study for my exam. Thanks for the coding explanations and additional help!
score: 0

http://stackoverflow.com/a/21643327
upvote count: 0
answers question: http://stackoverflow.com/q/21643225
score: -4
has comment: http://stackoverflow.com/comment/32709298
has comment: http://stackoverflow.com/comment/32709472
type: Answer
has comment: http://stackoverflow.com/comment/32726293
has comment: http://stackoverflow.com/comment/32709180
has comment: http://stackoverflow.com/comment/32709178
has comment: http://stackoverflow.com/comment/32709241
has comment: http://stackoverflow.com/comment/32709134
has body: First of all,out of memory is Error in java not an Exception.We can handle only exceptions in java by using try-catch construct or throws clause. Both Error and Exception classes extends Throwable class.But Error is irrecoverable condition and Exception is hand able. For your situation ,go through Garbage Collection in java .
has comment: http://stackoverflow.com/comment/32709211
has comment: http://stackoverflow.com/comment/32709285
has comment: http://stackoverflow.com/comment/32709677
downvote count: 4

http://stackoverflow.com/a/21648385
has comment: http://stackoverflow.com/comment/32815762
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/32814951
has comment: http://stackoverflow.com/comment/32759655
has comment: http://stackoverflow.com/comment/33211845
has comment: http://stackoverflow.com/comment/33256103
has comment: http://stackoverflow.com/comment/32815163
downvote count: 0
has comment: http://stackoverflow.com/comment/33306858
has comment: http://stackoverflow.com/comment/32814278
answers question: http://stackoverflow.com/q/21643230
has comment: http://stackoverflow.com/comment/32815374
has comment: http://stackoverflow.com/comment/32816001
has comment: http://stackoverflow.com/comment/32755304
has comment: http://stackoverflow.com/comment/32814154
has comment: http://stackoverflow.com/comment/33255917
type: AcceptedAnswer
has body: Its simple:) jodd-lagarto module depends on jodd-core module that has the missing class (as well as other utils Lagarto is using). Check the download page to see all modules and dependencies. For your version there might be also a dependency on slf4j logger (this has been removed recently). You may also consider using some dependency management tool, like gradle or maven. Than all dependencies will be automatically downloaded. If possible, try using the latest version of Jodd :) At this moment it's 3.4.10; 3.5 is almost out. The new versions contain some important Lagarto-related improvements, fixes and performance boosting :) Enjoy!
has comment: http://stackoverflow.com/comment/32814816
accepted answer of: http://stackoverflow.com/q/21643230
type: Answer
has comment: http://stackoverflow.com/comment/32815902
has comment: http://stackoverflow.com/comment/33225442

http://stackoverflow.com/comment/32620984
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21585262
has text: Variable g is available in void paint(Graphics g) method. As a function argument.
score: 0

http://stackoverflow.com/a/21676267
answers question: http://stackoverflow.com/q/21675390
upvote count: 1
type: Answer
downvote count: 0
score: 1
has body: Your event listeners should be in the controller. The controller holds an instance of the view and your view has public methods to set the event listeners of the GUI controls(JTextField etc). Example: You have a view that has a JButton control called buttonSubmit and you want to listen for when someone interacts with that button. View public void addSubmitButtonListener(ActionListener listener) { buttonSubmit.addActionListener(listener); } Controller public void run() { view.addSubmitButtonListener( new SubmitButtonListener() ); } class SubmitButtonListener implements ActionListener { @Override public void actionPerformed(ActionEvent evt) { // What happens after someone interacts with the button goes in here. } } That SubmitButtonListener class goes directly into the controller as an inner class.
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21675390

http://stackoverflow.com/q/21623335
tagged with: audio
score: 1
tagged with: java
linked to: http://stackoverflow.com/q/3287518
has comment: http://stackoverflow.com/comment/32676122
type: Question
has body: I should want to detect frequencies in music with java. I use TarsosDSP, which work ok, but I'm afraid there no active community (I think). Is there other ? On stackoverflow I've seen Sound processing: mixing two audio files, phase shifting and peak controller, Capturing audio and processing rythm in realtime, audio search library... but there's no accepted answer, so I try me too.
has title: Search java library for audio processing
linked to: http://stackoverflow.com/q/13661809
upvote count: 1
linked to: http://stackoverflow.com/q/4346968
favorite count: 0
answer count: 0
downvote count: 0
type: UnansweredQuestion

http://stackoverflow.com/comment/32712980
type: AnswerComment
has text: or..These might help you: http://manishkpr.webheavens.com/android-navigation-drawer-example-using-fragments/ http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/ https://github.com/thecodepath/android_guides/wiki/Fragment-Navigation-Drawer
type: Comment
comment on: http://stackoverflow.com/a/21645437
score: 0

http://stackoverflow.com/comment/32542409
comment on: http://stackoverflow.com/q/21548859
type: Comment
type: QuestionComment
has text: Try 31, please. I'd like to see result.
score: 0

http://stackoverflow.com/q/21571940
type: Question
answer count: 2
possible better answer: http://stackoverflow.com/a/21572106
has answer: http://stackoverflow.com/a/21572106
has answer: http://stackoverflow.com/a/21572000
tagged with: java
has comment: http://stackoverflow.com/comment/36996148
downvote count: 1
upvote count: 4
has body: This is my Fraction class code with several methods, the requirement I have is to keep numerator an denominator as an int: /** * @author GKsiazek * Reference: https://github.com/kiprobinson/BigFraction/blob/master/com/github/kiprobinson/util/BigFraction.java * Reference: https://github.com/kiprobinson/BigFraction/blob/master/com/github/kiprobinson/junit/BigFractionTest.java */ package Fraction; import java.math.*; public class Fraction { private int numerator; private int denominator; /** * Constructor with two int parameters * @param num is numerator * @param den is denominator */ public Fraction() {} public Fraction(int num, int den) { if (den==0){//denominator cannot be zero System.out.println("Denominator cannot be zero"); return; } this.numerator = num; this.denominator = den; this.normalize(); } /** * Constructor with one int parameter * @param num is numerator * @param den is assumed one */ public Fraction(int num){ this.numerator = 1; this.denominator = num ; } /** * Constructor with String parameter * @param str * Only String in a following format "numerator/denominator" allowed * If the String consists of one int it is considered denominator * Numerator will be considered 1 * Denominator cannot be zero */ public Fraction(String str) { if(str.isEmpty()) { System.out.println("The str (String) parameter cannot be empty!"); return; } String[] data = str.split("/"); if(data.length==0) System.out.println("The str (String) parameter cannot be empty"); try { this.numerator = Integer.parseInt(data[0]); } catch (Exception ex) { System.out.println(ex.toString()); } try { this.denominator = Integer.parseInt(data[1]); if(this.denominator==0) throw new Exception("Denominator can't be 0"); } catch (Exception ex) { System.out.println(ex.toString()); } this.normalize(); } /** * the method is applied within the constructors * normalize method takes care of fraction normalization * 1.Converts the numerator and denominator into BigInteger * 2.Finds the GCD of both * 3.if the …
has title: How can I negate Java Fraction,a class which I've created
accepted answer: http://stackoverflow.com/a/21572000
linked to: http://stackoverflow.com/q/385506
type: AnsweredQuestion
score: 3
favorite count: 0

sfml
tag name: sfml
tags question: http://stackoverflow.com/q/21528903
type: Tag

http://stackoverflow.com/comment/32664627
comment on: http://stackoverflow.com/q/21615510
type: QuestionComment
type: Comment
score: 0
has text: If you don't get an answer here you can try at https://groups.google.com/d/forum/google-admob-ads-sdk

http://stackoverflow.com/q/21557972
has answer: http://stackoverflow.com/a/21559347
type: Question
has body: I am wondering if there is a way to get around uniqueness of objects w.r.t. compareTo() / Comparator.compare() method. For example, suppose I have the class class MyClass extends Comparable&lt;MyClass&gt; { int value; // ... plenty of other fields public int compareTo(MyClass other) { ... // compares using the value field } } and would like to put different instances of MyClass into a TreeSet. By different, I mean if the default equals() would have returned false for two inserted objects, both should remain in the TreeSet. Of course, a way to implement this with "high" probability of correctness would by having compareTo() method first check the value field and in case of a tie resolve it by comparing the hashCode() value. I doubt there exist a way to achieve the desired behavior, since Java doesn't offer a safe way to cast references to a comparable type (unlike C/C++). However, if anybody has an idea please let me know. Otherwise, is there an easier alternative than rewriting a TreeSet from scratch, or a less clumsy one than using TreeMap&lt;K, HashSet&lt;K&gt;&gt;?
tagged with: comparison
score: 0
answer count: 3
has title: Java: TreeSet with multiple objects that compare as equal using compareTo()?
type: UnansweredQuestion
tagged with: collections
tagged with: tree
has answer: http://stackoverflow.com/a/21558296
has comment: http://stackoverflow.com/comment/32558578
has answer: http://stackoverflow.com/a/21559340
tagged with: java
tagged with: duplicates

http://stackoverflow.com/comment/32553422
comment on: http://stackoverflow.com/a/21541710
score: 0
type: AnswerComment
type: Comment
has text: I will try what you suggested. Thank you!

http://stackoverflow.com/comment/32690764
score: 0
type: Comment
has text: @humdinger, sorry, but what is queued blocking vs locked blocking? Maybe I'll ask another question. How do you want the multiple threads to behave when writing to the same file? In queuing, I thought you might want the thread write "data" but not have to block for I/O and get back to work straightaway to fetch more data to write. Is this the intention?
comment on: http://stackoverflow.com/a/21632701
type: AnswerComment

http://stackoverflow.com/comment/32717650
type: Comment
type: QuestionComment
has text: BTW if you are executing jar them command to execute it is: java -jar CrazyRunner.jar
comment on: http://stackoverflow.com/q/21647650
score: 0

http://stackoverflow.com/a/21654560
has comment: http://stackoverflow.com/comment/32756539
type: Answer
has comment: http://stackoverflow.com/comment/32730626
has body: And the code above has some problems... maybe this works. public static void main(String[] args) { String operatorInput=null; double numberInput; String userRedo = "Y"; double result = 0.0; Scanner input = new Scanner(System.in); System.out.println("Type in an arithmetic operator of your choice and press enter."); System.out.println("Then, please type in a number that will undergo the operation."); while ((userRedo.toUpperCase()).compareTo("Y") == 0) { try { operatorInput = input.nextLine().trim(); if (operatorInput.compareTo("+") != 0 &amp;&amp; operatorInput.compareTo("-") != 0 &amp;&amp; operatorInput.compareTo("*") != 0 &amp;&amp; operatorInput.compareTo("/") != 0) { throw new UnknownOperatorException("Unknown operator!"); } } catch (UnknownOperatorException e) { System.out.println(e.getMessage()); continue; } numberInput = Double.parseDouble(input.nextLine()); if (operatorInput.compareTo("+") == 0) { result += numberInput; } else if (operatorInput.compareTo("-") == 0) { result -= numberInput; } else if (operatorInput.compareTo("*") == 0) { result = result * numberInput; } else { result = result / numberInput; } System.out.println("\nresult " + operatorInput + " " + numberInput + "= "); System.out.println("Updated result: " + result); System.out.print("Again? (y/n) : "); userRedo = input.nextLine(); } input.close(); }
score: 0
answers question: http://stackoverflow.com/q/21654342

http://stackoverflow.com/comment/32644092
type: Comment
score: 0
type: AnswerComment
has text: What about java.net.URLConnection, public long getLastModified()? "Gets the last modified date of the object. Returns 0 if not known." Which object's date is returned, that of the file or of the URLConnection?
comment on: http://stackoverflow.com/a/21606199

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

http://stackoverflow.com/q/21596016
tagged with: android
has comment: http://stackoverflow.com/comment/32626937
upvote count: 2
has comment: http://stackoverflow.com/comment/32626731
answer count: 1
has body: I have tried to find a information/way about this case and I found 3 ways to do this, there is : using adb usb host usb accessory but, I'm still not found the solution. anybody can help me about this case?
tagged with: java
tagged with: usb
has title: Is it possible to send file from android smart phone to computer / PC programmatically?
tagged with: file-transfer
score: 2
downvote count: 0
type: UnansweredQuestion
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/21596975

http://stackoverflow.com/a/21582169
answers question: http://stackoverflow.com/q/21582128
type: Answer
has body: You need to initialize the buffers before you append something templates[0][0] = new StringBuffer();
score: 1
upvote count: 1
downvote count: 0

http://stackoverflow.com/comment/32718221
score: 1
comment on: http://stackoverflow.com/q/21648636
has text: Your data format will not be known to any library provider. Also this is a known problem which has been solved several times. Look at :http://stackoverflow.com/questions/16193970/servlet-export-reponse-to-excel-file
type: QuestionComment
type: Comment

parallel-processing
tags question: http://stackoverflow.com/q/21541261
type: Tag
tag name: parallel-processing
tags question: http://stackoverflow.com/q/21638552
tags question: http://stackoverflow.com/q/21631236

http://stackoverflow.com/comment/32586221
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21573193
score: 0
has text: only send me 43 numbder lines of AffiliateDAO class

http://stackoverflow.com/a/21587198
has comment: http://stackoverflow.com/comment/32616431
downvote count: 0
has body: The other answers are correct - however this implementation of the Singleton pattern is horribly flawed and will break in unexpected ways in a multi-threading environment. The easiest way is not to have lazy initialization of the singleton, if you really must have lazy initialization then do it using a static holder: public class CowSingleton { private static class SingletonHolder { private static CowSingleton unique; } private CowSingleton(){} public static CowSingleton getInstance(){ return SingletonHolder.unique; } public String cowMoo(String str) { return str; } } This uses the class loader to handle all the lazy initialization, thread safety, etc for you. It's completely thread safe and fast due to the fact that it doesn't need synchronization or null checks.
has comment: http://stackoverflow.com/comment/32613572
type: Answer
score: 2
answers question: http://stackoverflow.com/q/21587066
upvote count: 2

http://stackoverflow.com/q/21526982
downvote count: 2
tagged with: android
tagged with: custom-datetimepicker
linked to: http://stackoverflow.com/q/9406920
type: AnsweredQuestion
score: 3
tagged with: java
has answer: http://stackoverflow.com/a/31139170
has comment: http://stackoverflow.com/comment/32503657
type: Question
has body: How can I create a date Spinner, which shows current date in EditText as default and future dates in Spinner (like, for next 30 days) I used date picker in many apps, so I am familiar with date picker dialog but don't have any idea about date spinner. Note Please don't tell me How to style EditText as Spinner EDITED: 1 AS RECOMMENDED BY @erakitin @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_date); Spinner spinnerDateIn = (Spinner) findViewById(R.id.spinnerDateIn); Spinner spinnerDateOut = (Spinner) findViewById(R.id.spinnerDateOut); spinnerDateIn.setAdapter(new CalendarSpinnerAdapter(SpinnerDateActivity.this, 30)); } EDITED: 2 AS RECOMMENDED BY @erakitin in new update CalendarSpinnerAdapter mSpinnerDateInAdapter = new CalendarSpinnerAdapter(SpinnerDateActivity.this, 30); spinnerDate.setAdapter(mSpinnerDateInAdapter); spinnerDate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) { spinnerDate.setSelection(position); } @Override public void onNothingSelected(AdapterView&lt;?&gt; parent) { } }); Now, trying to get value of selected Item in String but getting: java.util.GregorianCalendar, where i am doing mistake ? strDate = spinnerDate.getSelectedItem().toString();
has title: How to create Spinner to show current and next 30 dates
accepted answer: http://stackoverflow.com/a/31139170
upvote count: 5
linked to: http://stackoverflow.com/q/28871921
tagged with: android-spinner
tagged with: date
answer count: 2
possible better answer: http://stackoverflow.com/a/31139142
favorite count: 0
has answer: http://stackoverflow.com/a/31139142

loops
tags question: http://stackoverflow.com/q/21561295
tags question: http://stackoverflow.com/q/21667356
tags question: http://stackoverflow.com/q/21642613
tags question: http://stackoverflow.com/q/21606532
tags question: http://stackoverflow.com/q/21525019
tags question: http://stackoverflow.com/q/21565633
tags question: http://stackoverflow.com/q/21586835
tags question: http://stackoverflow.com/q/21633246
tags question: http://stackoverflow.com/q/21650526
tags question: http://stackoverflow.com/q/21653939
tags question: http://stackoverflow.com/q/21636647
tags question: http://stackoverflow.com/q/21545499
tags question: http://stackoverflow.com/q/21670212
tags question: http://stackoverflow.com/q/21576148
tags question: http://stackoverflow.com/q/21568434
tags question: http://stackoverflow.com/q/21655834
type: Tag
tags question: http://stackoverflow.com/q/21521378
tags question: http://stackoverflow.com/q/21623137
tags question: http://stackoverflow.com/q/21584988
tags question: http://stackoverflow.com/q/21654581
tags question: http://stackoverflow.com/q/21634410
tags question: http://stackoverflow.com/q/21637986
tags question: http://stackoverflow.com/q/21642944
tags question: http://stackoverflow.com/q/21562192
tags question: http://stackoverflow.com/q/21619300
tags question: http://stackoverflow.com/q/21540603
tags question: http://stackoverflow.com/q/21643592
tag name: loops
tags question: http://stackoverflow.com/q/21661611
tags question: http://stackoverflow.com/q/21643257
tags question: http://stackoverflow.com/q/21581061
tags question: http://stackoverflow.com/q/21538697
tags question: http://stackoverflow.com/q/21591005
tags question: http://stackoverflow.com/q/21602836
tags question: http://stackoverflow.com/q/21637879
tags question: http://stackoverflow.com/q/21620592
tags question: http://stackoverflow.com/q/21529489
tags question: http://stackoverflow.com/q/21619997
tags question: http://stackoverflow.com/q/21517210
tags question: http://stackoverflow.com/q/21515659
tags question: http://stackoverflow.com/q/21669092
tags question: http://stackoverflow.com/q/21539586

http://stackoverflow.com/q/21615307
favorite count: 0
has body: I am using a thread to capture audio input which works the first time. However, I'm getting a java.lang.IllegalThreadStateException which I found out is because the interrupt flag isn't being set. Any help I could get would be awesome :) Below is a fully compilable example. import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JPanel; public class MainFrame extends JFrame { public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { MainFrame frame = new MainFrame(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } public MainFrame() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setResizable(false); setBounds(100, 100, 618, 373); Sessioninprogress sip = new Sessioninprogress(this); sip.setVisible(true); setContentPane(sip); setLayout(null); } } import javax.swing.JFrame; import javax.swing.JPanel; import javax.sound.sampled.*; import java.io.*; import java.awt.Color; import javax.swing.JButton; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.Font; import javax.swing.JLabel; import java.io.IOException; import java.util.ArrayList; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import javax.swing.UIManager; import javax.swing.border.LineBorder; public class Sessioninprogress extends JPanel { // path of the wav file File wavFile = new File("C:/userconvo.wav"); // format of audio file AudioFileFormat.Type fileType = AudioFileFormat.Type.WAVE; // the line from which audio data is captured TargetDataLine line; ExecutorService executorService = Executors.newFixedThreadPool(1); public Sessioninprogress(final MainFrame parent) { setBounds(100, 100, 618, 373); setBackground(new Color(255, 250, 250)); setBorder(new LineBorder(Color.DARK_GRAY, 1, true)); setLayout(null); JLabel txtpnEmployeeLogin = new JLabel(); txtpnEmployeeLogin.setForeground(Color.DARK_GRAY); txtpnEmployeeLogin.setBackground(Color.WH…
has comment: http://stackoverflow.com/comment/32661076
has title: Interrupt flag is not being set
has comment: http://stackoverflow.com/comment/32660481
has answer: http://stackoverflow.com/a/21618327
has comment: http://stackoverflow.com/comment/32703881
has comment: http://stackoverflow.com/comment/32685397
upvote count: 2
type: UnansweredQuestion
tagged with: java
downvote count: 2
tagged with: multithreading
has comment: http://stackoverflow.com/comment/32661023
tagged with: swing
has comment: http://stackoverflow.com/comment/32660772
type: Question
has comment: http://stackoverflow.com/comment/32670088
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/21616095

http://stackoverflow.com/comment/32737800
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21658908
has text: I don't know the difference but I will try. I don't understand why the list is deleted, do I need to define an external variable, a database or a static?
score: 0

http://stackoverflow.com/a/21516230
has comment: http://stackoverflow.com/comment/32485739
type: Answer
has body: The usual cause of this is that you had previously written to a connection that had already been closed by the other end. In other words, an application protocol error. You can see by the stack trace that it is happening inside ImageHandler.importData(), not inside the code you posted.
answers question: http://stackoverflow.com/q/21515125
has comment: http://stackoverflow.com/comment/32485574
has comment: http://stackoverflow.com/comment/32485788
has comment: http://stackoverflow.com/comment/32485831
score: 0

csrf
tags question: http://stackoverflow.com/q/21626335
tags question: http://stackoverflow.com/q/21534723
tag name: csrf
tags question: http://stackoverflow.com/q/21530338
type: Tag

http://stackoverflow.com/a/21657669
downvote count: 0
has body: You have to add working directory denoted as . to the class path as fcrypt.class is located there. Syntax for Unix: java -cp ".:libs/bcprov-jdk15on-150.jar" fcrypt note elements are separated with :. Syntax for Windows: java -cp ".;libs/bcprov-jdk15on-150.jar" fcrypt note elements are separated with ;. Java code style suggests class names to start with a capital letter. So it should be class FCrypt defined in FCrypt.java.
accepted answer of: http://stackoverflow.com/q/21655358
upvote count: 2
answers question: http://stackoverflow.com/q/21655358
type: AcceptedAnswer
type: Answer
score: 2

http://stackoverflow.com/q/21552095
answer count: 1
has title: sending input from text box to controller
has body: i want to send the input from the textbox to the controller on the click of submit button. following is the controller code... CONTROLLER: package com.sms.app.controller; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.multiaction.MultiActionController; import com.sms.app.util.FAQUtility; public class FAQController extends MultiActionController{ private FAQUtility faqUtility; public void setFaqUtility(FAQUtility faqUtility) { this.faqUtility = faqUtility; } public ModelAndView getHomePage(HttpServletRequest request, HttpServletResponse response) throws ServletException { System.out.println("In method getHomePage of FAQController"); return new ModelAndView("home"); } } this is the jsp page... JSP: &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt; &lt;%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1" contentType="text/html"%&gt; &lt;%@ taglib uri="/tld/c.tld" prefix="c" %&gt; &lt;%@ taglib uri="/tld/fmt.tld" prefix="fmt" %&gt; &lt;% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; String contextPath = request.getContextPath(); %&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt; &lt;title&gt;SMS FAQ&lt;/title&gt; &lt;link href="css/stylesheet.css" rel="stylesheet" type="text/css" /&gt; &lt;script type="text/javascript" src="js/home/home.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body oncontextmenu="return false;" width="100%" height="100%"&gt; &lt;form name="Home" action="" method="POST"&gt; &lt;input type="hidden" id="contextPath" name="contextPath" value="&lt;%=contextPath%&gt;" /&gt; &lt;table width="100%" align="center"&gt; &lt;tr&gt; &lt;td width="100%" &gt; &lt;table width="100%"&gt; &lt;tr&gt; …
favorite count: 0
tagged with: spring
tagged with: spring-mvc
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
type: Question
accepted answer: http://stackoverflow.com/a/21552469
has answer: http://stackoverflow.com/a/21552469
downvote count: 0

http://stackoverflow.com/a/21647679
type: AcceptedAnswer
downvote count: 0
score: 4
accepted answer of: http://stackoverflow.com/q/21647628
answers question: http://stackoverflow.com/q/21647628
has body: I want to be able to print the departments' full names with their descriptions on the screen. You need to associate the full name with each enum value. The simplest way of doing it is to add a description member to the enum: enum DepartmentName { FINANCE ("FIN", "Finance") , SALES ("SAL", "Sales") , PAYROLL ("PYR", "Payroll") , LOGISTIC ("LGT", "Logistic") ; private final String department; private final String description; DepartmentName(String abbr, String full) { department = abbr; description = full; } public String getDepartmentCode() {return department;} public String getDescription() {return description;} @Override public String toString() { return "The department name is " + getDepartmentCode(); } } I want to accomplish that by using a switch statement That would be a wrong way of doing that, because the association with the name would be external to the enum (i.e. no longer be encapsulated). The consequence of this is that each time you add a new enum member, all your switches that depend on that enum would need to change. Moreover, the compiler would not be able to help you catch places where you missed the new enum value.
type: Answer
upvote count: 4

http://stackoverflow.com/q/21668759
accepted answer: http://stackoverflow.com/a/21668807
answer count: 4
favorite count: 0
has comment: http://stackoverflow.com/comment/32753801
possible better answer: http://stackoverflow.com/a/21668784
linked to: http://stackoverflow.com/q/40480
has answer: http://stackoverflow.com/a/21668784
has comment: http://stackoverflow.com/comment/32753815
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/21668800
type: Question
upvote count: 4
has answer: http://stackoverflow.com/a/21668807
has body: How do I change a variable from a different class in Java? I'm trying to change a variable from another class, and use it back in the first class. I make a variable in class First, and give it a value of 1. Then I try to change the value of the same variable to 2 in class Second, but it changes back to 1 when I use it in class First. I'm new to Java and don't know very much yet, so if you could try and keep the answers simple, that would be great :) Class First: public class First { public static void main(String args[]){ int var = 1; //Variable i'm trying to change from class "Second" Second Second = new Second(); System.out.println(var); //Prints out 1 Second.test(var); System.out.println(var); // Prints out 1 again, even though I changed it } } Class Second: public class Second { void test(int var){ /* * * I try to change var to 2, and it works in this class * but when it doesn't change in the class "First" * */ var = 2; System.out.println(var); //Prints out 2 } } What the output looks like: 1 2 1 What i'm trying to get: 1 2 2 Ive tried to find answers to this, but all of the answers that I could find didnt make any sense to me, as im very new to Java and programming.
downvote count: 0
tagged with: variables
score: 4
has title: How do I change a variable from a different class in Java?
tagged with: class
has answer: http://stackoverflow.com/a/21668836

http://stackoverflow.com/q/21606204
has body: I am using following code to remove multiple elements from XMl file. NodeList removeNodeList = doc.getElementsByTagName("server1"); Element rootElement = doc.getDocumentElement(); for (int i = 0; i &lt; removeNodeList.getLength(); i++) { rootElement.removeChild(removeNodeList.item(i)); } But after removing one element it is coming out of loop. What is the issue. Following is my XML file content. &lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt; &lt;start&gt; &lt;category name="server1"/&gt; &lt;category name="server2"/&gt; &lt;server1 name="serverName1" value="serverValue"/&gt; &lt;server1 name="serverName1" value="serverValue"/&gt; &lt;server2 name="serverName2" value="serverValue"/&gt; &lt;/start&gt;
type: AnsweredQuestion
score: 3
has comment: http://stackoverflow.com/comment/32645378
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/21607716
has answer: http://stackoverflow.com/a/56615235
type: Question
tagged with: jakarta-ee
has answer: http://stackoverflow.com/a/53971198
favorite count: 0
upvote count: 3
tagged with: jaxp
possible better answer: http://stackoverflow.com/a/21606880
has comment: http://stackoverflow.com/comment/32644073
has answer: http://stackoverflow.com/a/21606880
has comment: http://stackoverflow.com/comment/32644054
has title: removeChild() method is breaking for loop
answer count: 4
tagged with: http://stackoverflow.com/tag/xml
linked to: http://stackoverflow.com/q/1374088
accepted answer: http://stackoverflow.com/a/21607716

http://stackoverflow.com/q/21544446
has answer: http://stackoverflow.com/a/21544850
type: AnsweredQuestion
tagged with: dynamic
has comment: http://stackoverflow.com/comment/32726453
possible better answer: http://stackoverflow.com/a/35352015
type: Question
has answer: http://stackoverflow.com/a/35352015
has title: How do you dynamically compile and load external java classes?
tagged with: java
has body: (This question is similar to many questions I have seen but most are not specific enough for what I am doing) Background: The purpose of my program is to make it easy for people who use my program to make custom "plugins" so to speak, then compile and load them into the program for use (vs having an incomplete, slow parser implemented in my program). My program allows users to input code into a predefined class extending a compiled class packaged with my program. They input the code into text panes then my program copies the code into the methods being overridden. It then saves this as a .java file (nearly) ready for the compiler. The program runs javac (java compiler) with the saved .java file as its input. My question is, how do I get it so that the client can (using my compiled program) save this java file (which extends my InterfaceExample) anywhere on their computer, have my program compile it (without saying "cannot find symbol: InterfaceExample") then load it and call the doSomething() method? I keep seeing Q&amp;A's using reflection or ClassLoader and one that almost described how to compile it, but none are detailed enough for me/I do not understand them completely.
linked to: http://stackoverflow.com/q/3447359
tagged with: compilation
accepted answer: http://stackoverflow.com/a/21544850
linked to: http://stackoverflow.com/q/35620908
answer count: 2
duplicate of: http://stackoverflow.com/q/3447359
downvote count: 0
upvote count: 50
favorite count: 0
score: 50
has comment: http://stackoverflow.com/comment/32534786
has comment: http://stackoverflow.com/comment/32732577
tagged with: load
tagged with: external
has comment: http://stackoverflow.com/comment/109156927

http://stackoverflow.com/comment/32686133
comment on: http://stackoverflow.com/q/21630345
type: QuestionComment
score: 1
has text: `uname != ""` is wonky. The `if` statement should have precisely been `if (uname != null && !uname.equals("")){...}`.
type: Comment

http://stackoverflow.com/q/21609146
tagged with: regex
has comment: http://stackoverflow.com/comment/32648851
type: AnsweredQuestion
has title: Matching numbers with regex
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/21609183
score: 0
has body: I need to match numbers where the first character is either a - (minus) or NOT a 0 (unless it's the only character in the string) and I'm kinda stuck. ^[-|1-9]?[0-9]+ I've currently got this but it'll match any amount of zeroes. Examples: Should match: -16 25 2005 Should not match: -05 05 00001 0-017
has answer: http://stackoverflow.com/a/21609183
answer count: 1

jasper-reports
tags question: http://stackoverflow.com/q/21631521
tags question: http://stackoverflow.com/q/21642810
tags question: http://stackoverflow.com/q/21608196
tags question: http://stackoverflow.com/q/21622419
tags question: http://stackoverflow.com/q/21631233
tag name: jasper-reports
tags question: http://stackoverflow.com/q/21624875
tags question: http://stackoverflow.com/q/21627587
type: Tag
tags question: http://stackoverflow.com/q/21519123
tags question: http://stackoverflow.com/q/21553540
tags question: http://stackoverflow.com/q/21521479
tags question: http://stackoverflow.com/q/21576326

http://stackoverflow.com/q/21636566
tagged with: annotations
tagged with: methods
type: Question
score: 3
tagged with: java
has answer: http://stackoverflow.com/a/21638070
has body: I'm trying to use Spring Security Annotations for security instead of defining the rules in XML. It seems to work, but when I run into an access denied error I get a HTTP status code of 500 returned. I do not see any exceptions in my tomcat log files. And when the execution hits my AuthenticationEntryPoint, the response is committed. If I revert to having the rules in XML and get an access denied error, I get a HTTP status code of 401 returned. The method is annotated with @PreAuthorize @GET @Produces(MediaType.APPLICATION_JSON) @PreAuthorize("hasRole('user')") public String list() throws IOException Here is my XML (the previous XML rule is commented out) &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:security="http://www.springframework.org/schema/security" xmlns="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd"&gt; &lt;security:debug/&gt; &lt;security:global-method-security pre-post-annotations="enabled"/&gt; &lt;security:authentication-manager id="authenticationManager"&gt; &lt;security:authentication-provider user-service-ref="userDao"&gt; &lt;security:password-encoder ref="passwordEncoder"/&gt; &lt;/security:authentication-provider&gt; &lt;/security:authentication-manager&gt; &lt;security:http realm="Protected API" use-expressions="true" auto-config="false" create-session="stateless" entry-point-ref="unauthorizedEntryPoint" authentication-manager-ref="authenticationManager"&gt; &lt;security:access-denied-handler ref="accessDeniedHandler"/&gt; &lt;security:custom-filter ref="tokenAuthenticationProcessingFilter" position="FORM_LOGIN_FILTER"/&gt; &lt;security:custom-filter ref="tokenFilter" position="REMEMBER_ME_FILTER"/&gt; &lt;!--&lt;security:intercept-url…
downvote count: 0
answer count: 1
accepted answer: http://stackoverflow.com/a/21638070
favorite count: 0
tagged with: security
tagged with: spring
has title: Using global-method-security, Access Denied errors are returned as HTTP 500 errors
type: AnsweredQuestion
upvote count: 3

http://stackoverflow.com/q/21623143
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/32675218
type: Question
has title: Tomcat catalina.out growing rapidly
tagged with: tomcat
has body: I see below messages in my catalina.out file. Every second I have over 50 of these statements getting printed, which is eating up all my disk space, and causing catalina to grow like crazy. INFO [Fri Feb 7 04:48:21 GMT 2014:] [http-bio-10080-exec-141] [] queueLog : Fri Feb 07 04:48:21 GMT 2014 TestReq:http://my-chattertest.com/stlp/RequestWeb--USER-&gt;demo INFO [Fri Feb 7 04:48:21 GMT 2014:] [http-bio-10080-exec-141] [] queueLog : Fri Feb 07 04:48:21 GMT 2014 TestReq:http://my-chattertest.com/stlp/RequestWeb--USER-&gt;demo INFO [Fri Feb 7 04:48:21 GMT 2014:] [http-bio-10080-exec-140] [] queueLog : Fri Feb 07 04:48:21 GMT 2014 TestReq:http://my-chattertest.com/stlp/RequestWeb--USER-&gt;demo INFO [Fri Feb 7 04:48:21 GMT 2014:] [http-bio-10080-exec-140] [] queueLog : Fri Feb 07 04:48:21 GMT 2014 TestReq:http://my-chattertest.com/stlp/RequestWeb--USER-&gt;demo INFO [Fri Feb 7 04:48:21 GMT 2014:] [http-bio-10080-exec-101] [] queueLog : Fri Feb 07 04:48:21 GMT 2014 TestReq:http://my-chattertest.com/stlp/RequestWeb--USER-&gt;demo What could be causing this? I don't have any of the words in the log in my code. I have no clue where these statements are coming from. Please help me with your thoughts. If any of you have faced something similar to this? What could be causing it, and how do I prevent it?
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32680057

http://stackoverflow.com/a/21664103
has comment: http://stackoverflow.com/comment/32745673
accepted answer of: http://stackoverflow.com/q/21664031
answers question: http://stackoverflow.com/q/21664031
has comment: http://stackoverflow.com/comment/32745751
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32745635
type: Answer
has comment: http://stackoverflow.com/comment/32745512
has comment: http://stackoverflow.com/comment/32745585
has comment: http://stackoverflow.com/comment/32745701
has comment: http://stackoverflow.com/comment/32745551
score: 3
upvote count: 3
has body: The stack overflow isn't in your constructor. It's when your main method calls add on your BigNumber. This is the first problem: public BigNumber add(BigNumber other) throws CloneNotSupportedException { return ((BigNumber) BigNumber.this.CloneNumber()).add(other); } You're calling add within the add method... how would you expect that to work? It's not clear why you've got both sum and sum2, but I expect your add method only needs to be: public BigNumber add(BigNumber other) throws CloneNotSupportedException { return new BigNumber(sum.add(other.sum).toString()); } ... although you'd be better off with an overload of the constructor to accept a BigInteger, at which point you can just have: public BigNumber add(BigNumber other) throws CloneNotSupportedException { return new BigNumber(sum.add(other.sum)); } The constructors (and field declaration) would then look like this: // Personally I'd make the class final, but that's a different matter public class BigNumber { private final BigInteger value; // Renamed from sum - see below public BigNumber(BigInteger value) { this.value = value; } public BigNumber(String value) { this(new BigInteger(value)); } ... methods ... } Additionally: You should override the existing toString method rather than introducing your own ToString method You should override clone() instead of introducing your own CloneNumber method Follow Java naming conventions, where methods are camelCased, not PascalCased. You should remove the sum2 field which isn't used anywhere within your class You don't need to add anything in your constructor - you can just have: this.sum = new BigInteger(g); Your field is called sum but it's not obviously the sum of anything - it's just the value. I would rename it to value or something similar. It's not clear why you're doing this at all - you're just reproducing a small part of the BigInteger class... why?

http://stackoverflow.com/a/21572847
score: 0
type: Answer
has body: you can parse the String with the givn String functions. (indexOf,lastOf,split) But it is not that easy to write a algho who knows the mathematik. I have done it once (without "()") but havnt the code to give it to you. 8[ I tell you what i have done: I searched first for '*,/' eg input=120-20*2+30; split the string at the givn index left=120-20; right=2+30; at the left split i searcht the last +,- and on the right the first split it again to the givn index (leftRest=120;rightRest=+30) now i take the left found Value -20 parse it to BigDecimal (because that will give u better results for comma values) and parse the right found Value to BigDecimal 2 now u can calculate calcValue=-40=-20 * 2; write the value back to the string, if the calcValue is not minus u have to write a + before; somting like this will do: if(calcValue&gt;0){ setPlus="+"; }else{ setPlus=""; } input=leftRest+setPlus+Value+rightRest; that give u: 120-40+30 now u repead until there are no *,/ then u start searching +,- If u Divide somthing with bigDecimal u have to say how many comma values u like to have ... otherwise it will throw an exeption for thinks like 1/3 if u want to do it with '()' u have to split the string at '(',')' first and do the math within, then write it back without '()' hope i could help you a little, i think there are other ways to do so, but i only need 6h, fully drunk do write this code ^^ Stefan
answers question: http://stackoverflow.com/q/21572202

http://stackoverflow.com/q/21588684
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/21589080
tagged with: aop
score: 12
tagged with: aspectj
has answer: http://stackoverflow.com/a/36101789
favorite count: 0
has body: I am (of course) trying to maintain a project using many constructs I don't know that well. In the course of attempting to figure out the AOP use within Spring, I came across methods with the following annotation: @Around(value = "@annotation(annotation)") So @Around means we're doing the 'around' version of the method pointcut in AOP, I understand that. I don't know what the other part means. The Spring documentation gives the following: @annotation - limits matching to join points where the subject of the join point (method being executed in Spring AOP) has the given annotation I don't know what that means - "method being executed in Spring AOP" sounds like the advised method, but I don't know how I (or Spring) figure out which methods are being advised. It sounds like it is the methods that have "the given annotation", but if so, what annotation has been given? What methods are advised by this annotation? And what else does it mean?
has title: Spring AOP: @annotation(annotation)
answer count: 5
has answer: http://stackoverflow.com/a/59703489
has answer: http://stackoverflow.com/a/47949832
tagged with: spring
upvote count: 12
type: AnsweredQuestion
downvote count: 0
possible better answer: http://stackoverflow.com/a/23998085
tagged with: annotations
accepted answer: http://stackoverflow.com/a/21589080
has answer: http://stackoverflow.com/a/23998085

http://stackoverflow.com/comment/32648335
score: 0
type: Comment
type: QuestionComment
has text: They can span for multiple lines. They do not have to be at the end of the line. User can insert any legit `SQL` statement like this : `select * from mytable; select smth as "xxx" from table2 where somefield in ('x;xx', 'ccc;');` all in one line
comment on: http://stackoverflow.com/q/21607152

http://stackoverflow.com/q/21668148
accepted answer: http://stackoverflow.com/a/21668212
upvote count: 1
tagged with: http
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21668212
score: 1
tagged with: java
tagged with: servlets
has title: HttpServlet hierarchy explanation
answer count: 1
downvote count: 0
has body: I'm a little concern about some facts of java hierarchy model. As stated in java tutorials: an abstract class may not implement methods ( but they can) and if you extend from an abstract class you must implement all methods of superclass otherwise the new class must be abstract as well But right now, I'm learning servlets classes and found that my servlet runs even if I don´t implement all of the methods declared in HttpServlet, what is happening? I see that in the source they are protected methods (dopost, doget ,etc) and even it says compiled code) but even if they are protected how we can extend the methods to create new servlets, is it because the public abstract HTTPservlet signature? . I also found this very unusual, what's the meaning? private static final String METHOD_DELETE = "DELETE"; private static final String METHOD_HEAD = "HEAD"; private static final String METHOD_GET = "GET"; All other pieces of theory are ok when you look at Public abstract class GenericServlet which implements servlet, servletconfig, serializable. wich the idea is to have a class in the future that don't necessarily need to implements all interface methods like httpservlet does. Than you very much, I also would appreciate clearer or deeper resources of java class modeling. When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class. However, if it does not, then the subclass must also be declared abstract. yeah i misunderstood and misread the httservlet the rule only applies to abstract methods with no body just the signature but httpsevlet methods are not abstract they have implementation but is compiled =) thank you very much i see why now we don't need to implement those methods and the interfaces used by httpservlet.
favorite count: 0
has comment: http://stackoverflow.com/comment/32753341

http://stackoverflow.com/comment/32529373
comment on: http://stackoverflow.com/a/21539025
score: 3
has text: Plus if you don't define a scope, it'll implicitly be `Dependent`, and inherit the scope of the bean being injected to.
type: AnswerComment
type: Comment

http://stackoverflow.com/q/21669459
possible better answer: http://stackoverflow.com/a/21669470
has body: Why does the following print 197, but not 'bc'? System.out.println('b' + 'c'); Can someone explain how to do proper concatenation on Java? P.S. I learnt some Python, and now transforming to learn Java.
has answer: http://stackoverflow.com/a/21669526
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/21669472
has answer: http://stackoverflow.com/a/21669491
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/21669570
linked to: http://stackoverflow.com/q/10361579
has title: How does Java concatenate 2 strings?
answer count: 6
has comment: http://stackoverflow.com/comment/32754944
has answer: http://stackoverflow.com/a/21669518
upvote count: 4
tagged with: concatenation
score: 3
has answer: http://stackoverflow.com/a/21669470
tagged with: string
favorite count: 0
has answer: http://stackoverflow.com/a/21669472
has comment: http://stackoverflow.com/comment/32754966

http://stackoverflow.com/a/37132834
has comment: http://stackoverflow.com/comment/61805252
answers question: http://stackoverflow.com/q/21602338
downvote count: 1
type: Answer
has body: Please check Database connection pool maxtotal. It might be less and you may need to increase it.
upvote count: 0
score: -1

http://stackoverflow.com/q/21660699
answer count: 1
downvote count: 1
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21661032
favorite count: 0
tagged with: jtoolbar
type: Question
tagged with: jframe
has title: Why JMenuBar is not place in the JFrame content pane, but JToolbar place in the content pane
tagged with: jmenubar
accepted answer: http://stackoverflow.com/a/21661032
upvote count: 1
tagged with: swing
score: 0
tagged with: java
has body: Why JMenuBar is not place in the content pane?is there any reason or effects when make a java gui program especially when using jframe? Thanks

http://stackoverflow.com/q/21524082
has title: Installation procedure for cassandra, Datastax Enterprise and community and Opscenter in Ubuntu
upvote count: 1
type: AnsweredQuestion
tagged with: cassandra-2.0
score: 1
tagged with: java
has body: Hi I'm a Java programmer and new to Cassandra, as per my project requirement I need to install in Ubuntu machine and start playing with it. By reviewing lot of websites I got a conclusion that, to setup Cassandra need to install cassandra, Datastax Enterprise and community and Opscenter. But I don't know which s/w need to install first and what is the configuration I need to do with that. So please some one can guide me directly or please suggest me good websites for simple procedure into setup Cassandra in Ubuntu machine.
type: Question
downvote count: 0
accepted answer: http://stackoverflow.com/a/21524917
tagged with: cassandra
answer count: 1
has answer: http://stackoverflow.com/a/21524917
favorite count: 0

http://stackoverflow.com/q/21572423
has comment: http://stackoverflow.com/comment/32585841
favorite count: 0
has answer: http://stackoverflow.com/a/21573209
tagged with: windows
tagged with: swt
upvote count: 1
accepted answer: http://stackoverflow.com/a/21573209
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32585755
has title: Workaround for Ampersand in SWT Table Header
score: 1
tagged with: java
type: Question
has body: An ampersand in an SWT Table header will not be displayed, is there a known workaround? I have to display an ampersand in my application and i'm looking for a workaround... https://bugs.eclipse.org/bugs/show_bug.cgi?id=154904 if you don't want to read the full atricle just follow this example public class TableWidget { Display d; Shell s; TableWidget() { d = new Display(); s = new Shell(d); s.setSize(250, 200); s.setText("A Table Shell Example"); s.setLayout(new FillLayout()); Table t = new Table(s, SWT.BORDER); TableColumn tc1 = new TableColumn(t, SWT.CENTER); TableColumn tc2 = new TableColumn(t, SWT.CENTER); TableColumn tc3 = new TableColumn(t, SWT.CENTER); tc1.setText("First&amp;&amp;Name"); //THESE ampersands won't be shown tc2.setText("Last &amp; Name"); //and HERE tc3.setText("Address"); tc1.setWidth(70); tc2.setWidth(70); tc3.setWidth(80); t.setHeaderVisible(true); TableItem item1 = new TableItem(t, SWT.NONE); item1.setText(new String[] { "Tim", "Hatton", "Kentucky" }); TableItem item2 = new TableItem(t, SWT.NONE); item2.setText(new String[] { "Caitlyn", "Warner", "Ohio" }); TableItem item3 = new TableItem(t, SWT.NONE); item3.setText(new String[] { "Reese", "Miller", "Ohio" }); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); } public static void main(String[] argv) { new TableWidget(); } } and yes, of course '\u0026' won't work as well - i'm not really expecting a solution but maybe someone is smarter than i am...
answer count: 1
downvote count: 0

http://stackoverflow.com/q/21671106
score: 0
has answer: http://stackoverflow.com/a/22039045
accepted answer: http://stackoverflow.com/a/22039045
has comment: http://stackoverflow.com/comment/32785635
has comment: http://stackoverflow.com/comment/32900114
answer count: 1
has comment: http://stackoverflow.com/comment/32762173
has comment: http://stackoverflow.com/comment/32880735
has title: How to join 2 tables based on passing a parameter for search operation?
tagged with: criteria-api
has comment: http://stackoverflow.com/comment/32757542
has comment: http://stackoverflow.com/comment/32896433
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33402349
tagged with: join
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32900823
has comment: http://stackoverflow.com/comment/32762851
has body: I have 2 entities Addemp and Job.I want to join these 2 tables based on empid .empid is foreign key in job table and primary key in addemp table here i am doing a search operation based on employee id .i am using criteria builder for search operation the relationship here is manytoone public List&lt;Object[]&gt; findEmployeeList(Integer id) { EntityManager em=null; try { em=getEntityManager(); CriteriaBuilder cb=em.getCriteriaBuilder(); CriteriaQuery cq=cb.createQuery(Addemp.class); Root&lt;Addemp&gt;rt= cq.from(Addemp.class); Join&lt;Addemp,Job&gt; job=rt.join(Addemp_.jobCollection); Predicate predicate=cb.equal(rt.get("empId"),id); cq.where(predicate); /* cq.select(rt.get("firstName")); cq.where (cb.equal(rt.&lt;String&gt;get("empId"),id));*/ Query qry= em.createQuery(cq); return qry.getResultList();
tagged with: jpa
has comment: http://stackoverflow.com/comment/32762254
has comment: http://stackoverflow.com/comment/32762079
has comment: http://stackoverflow.com/comment/32890029
has comment: http://stackoverflow.com/comment/32762585
has comment: http://stackoverflow.com/comment/32797601

http://stackoverflow.com/q/21596500
tagged with: mysql
type: Question
has comment: http://stackoverflow.com/comment/32637737
score: 0
has body: I am using this site This site for learning spring and hibernate in primefaces. I however getting an error javax.el.PropertyNotFoundException: /login.xhtml @31,125 action="#{login.spring}": Target Unreachable, identifier 'login' resolved to null My login.xhtml (primefaces) &lt;h:inputText id="username" value="#{spring_login.username}" label="UserName"/&gt; &lt;h:inputSecret id="password" value="#{spring_login.password}" label="PassWord"/&gt; &lt;h:commandButton value="LOGIN" action="#{login.spring}" /&gt; LoginController.java @RequestMapping("/Login_spring") public class LoginController { @RequestMapping(method=RequestMethod.POST) public ModelAndView processCredentials (@RequestParam("username")String username,@RequestParam("password")String password){ String message="invalid credentials"; if(!username.equals("") &amp;&amp; !password.equals("")){ if(username.equals(username)){ try { message="welcome "+ username + " !"; FacesContext context = FacesContext.getCurrentInstance(); HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getResponse(); response.sendRedirect("index.xhtml"); } catch (IOException ex) { Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex); } } } return new ModelAndView("results", "message", message); } } I have been all over the internet for a working example on A working login with primefaces, spring, hibernate, glassfish, mysql on netbeans 7.4
has title: A working login with primefaces, spring, hibernate, glassfish, mysql on netbeans
has comment: http://stackoverflow.com/comment/32715271
type: UnansweredQuestion
tagged with: spring
answer count: 0
tagged with: primefaces
tagged with: java
tagged with: hibernate

http://stackoverflow.com/comment/32587511
score: 0
type: Comment
type: QuestionComment
has text: ok guys, I changed Stateful to Stateless. Now I get interesting exception NPE. It seems that for some iteration collections which I initialize in b.init() are not instantiated. I iterate over hundreds of objects in the for loop and I suppose that ejb container use more than one ejb to process every single call to b.doSthInB(c). But only for the first one ejb the b.init() is called and that is why I get NPE. Am I right?
comment on: http://stackoverflow.com/q/21549778

http://stackoverflow.com/comment/32723418
has text: `putExtra()` also takes `ints`. Just try it ;)
score: 0
comment on: http://stackoverflow.com/q/21651536
type: QuestionComment
type: Comment

http://stackoverflow.com/q/21621494
tagged with: thread-sleep
has comment: http://stackoverflow.com/comment/32670836
has answer: http://stackoverflow.com/a/21621619
has body: I tried to implement an automatic rolling progress-bar. The problem is that I can't stop it onece it starts. But It works fine when during the step by step debugging, and only during the debugging. Here's a fragment of my codes. Any help will be highly appreciated. package test; import javax.swing.*; public final class MyTest{ private boolean isvisible = false; private JProgressBar progressbar = new JProgressBar(); /** * thread of automatic rolling progress-bar */ private Thread proT = new Thread(new Runnable(){ @Override public void run(){ isvisible = true; progressbar.setVisible(true); while(true){ progressBar.setValue((progressBar.getValue() + 20)%100); System.out.println(progressBar.getValue()); try{ Thread.sleep(500); }catch(InterruptedException e){ e.printStackTrace(); } if(!isvisible){ progressbar.setVisible(false); break; } } } }); /** * constructor */ public MyTest(){ //initiate GUI } /** * show an automatic rolling progress-bar */ public void showProgressBar(){ proT.start(); } /** * stop/veil the progress-bar */ public void veilProgressBar(){ isvisible = false; } }
has title: Can't stop a thread during running but debugging
has comment: http://stackoverflow.com/comment/32672258
score: 0
accepted answer: http://stackoverflow.com/a/21621619
has comment: http://stackoverflow.com/comment/32673850
tagged with: event-dispatch-thread
possible better answer: http://stackoverflow.com/a/21621558
has answer: http://stackoverflow.com/a/21621558
tagged with: multithreading
has comment: http://stackoverflow.com/comment/32670850
tagged with: swing
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/32670769
type: Question
answer count: 2

http://stackoverflow.com/q/21568109
tagged with: java
has body: I'm working on a project that involves using Twitter. I began to use Tweepy and put in the following code... import tweepy """public_tweets = tweepy.api.public_timeline() print "hi" for tweet in public_tweets: print tweet.text""" auth = tweepy.BasicAuthHandler('username', 'password') api = tweepy.API(auth) api.update_status('hello from tweepy!') ...But I got this error that says Tweety does not have an error module. I looked in the Tweety folder and a PY file called "error" was there... what am I doing wrong? Traceback (most recent call last): File "C:/Users/Karan/Desktop/untitled.py", line 1, in &lt;module&gt; import tweepy File "C:\Users\Karan\AppData\Local\Temp\Temp1_tweepy-master.zip\tweepy-master\tweepy\__init__.py", line 12, in &lt;module&gt; from tweepy.models import Status, User, DirectMessage, Friendship, SavedSearch, SearchResults, ModelFactory, Category File "C:\Users\Karan\AppData\Local\Temp\Temp1_tweepy-master.zip\tweepy-master\tweepy\models.py", line 5, in &lt;module&gt; from tweepy.error import TweepError ImportError: No module named error
tagged with: twitter
has title: How do I get started on working with the Twitter API?
downvote count: 1
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/21568203
upvote count: 0
score: -1
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21568152
tagged with: python

http://stackoverflow.com/comment/32612463
type: QuestionComment
comment on: http://stackoverflow.com/q/21587777
type: Comment
has text: You'll need a regular expression if you're checking for any string within quotes.
score: 0

http://stackoverflow.com/a/21664931
has comment: http://stackoverflow.com/comment/32747362
has comment: http://stackoverflow.com/comment/32747644
type: Answer
upvote count: 0
has comment: http://stackoverflow.com/comment/32747119
score: -3
has body: Arrays can not be generic in Java. On the other hand you already have Stack, Queue, Set, Map and other collection types &mdash; just examine java.util.* or do some research about Java Collections Framework.
answers question: http://stackoverflow.com/q/21664875
downvote count: 3

http://stackoverflow.com/comment/32670245
comment on: http://stackoverflow.com/q/21620964
has text: That means I am bending my test case to accept `NestedServletException`. What I want is to somehow change the controller behaviour to throw the `MethodArgumentNotValidException` directly instead of nesting it inside `NestedServletException`
type: Comment
score: 1
type: QuestionComment

http://stackoverflow.com/comment/32591099
type: Comment
comment on: http://stackoverflow.com/a/21572992
type: AnswerComment
has text: There's a problem, when I changed 2 to 11, there's a conflict.
score: 0

http://stackoverflow.com/a/21644044
has comment: http://stackoverflow.com/comment/32714758
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21643618
has comment: http://stackoverflow.com/comment/32714848
type: Answer
has body: You can obviously return from the for loop. public String getFileInformation() throws IOException { try{ String file; file = "tra.srt"; Charset charset = Charset.defaultCharset(); Path path = Paths.get(file); BufferedReader reader = Files.newBufferedReader(path, charset); System.out.printf("Lines from %s:%n",file); String line; while((line = reader.readLine()) != null) { if (line.indexOf(':') != -1 &amp;&amp; line.indexOf(',') != -1 &amp;&amp; line.indexOf('0') != -1) { return line.substring(0, 12); } } }catch(FileNotFoundException ex){ System.err.println(ex); } return ""; }
has comment: http://stackoverflow.com/comment/32710880
has comment: http://stackoverflow.com/comment/32710633
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/21643618

http://stackoverflow.com/comment/32493063
type: Comment
has text: Is there a bean defined in your xml with `id="response"`
score: 0
comment on: http://stackoverflow.com/q/21520827
type: QuestionComment

http://stackoverflow.com/comment/32690278
type: Comment
comment on: http://stackoverflow.com/q/21632585
type: QuestionComment
has text: @MaciejDobrowolski I think blockingQueue's are going to be my answer. Thanks for the suggestion.
score: 0

http://stackoverflow.com/comment/32581199
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21518127
type: Comment
has text: You could always make your "Screen" class implement InputProcessor then add it like this: multiplexer.addProcessor(this);. Or use an inner class like how I have done in my pinch-to-zoom example. But I don't think you can listen for a keydown without ImputProcessor.

http://stackoverflow.com/comment/32553139
has text: Yes, this is what I currently have. This is called by (1) and (2).
type: AnswerComment
comment on: http://stackoverflow.com/a/21555282
score: 0
type: Comment

http://stackoverflow.com/a/21583873
score: 0
type: Answer
has body: If you do not provide a constructor in your child class,the compiler inserts a no-arg constructor and adds the first line as call to super no-arg constructor So your code becomes :- public class ChildClass extends ParentClass { public ChildClass() { super(); } } Obviously, u have thrown a null pointer exception which may be causing the problem.I suggest you to add a constructor and make a call to super constrcutor which takes String argument:- public class ChildClass extends ParentClass { public ChildClass(String id) { super(id); } @Override public void doInstanceStuff() { // .... } } This should solve all your problems... Note:- If you add a argument constructor,the compiler doesn't not add a default constructor for you. Now your beans will initialize properly as it will call the string argument constructor. Currently the compiler is providing a default no-arg constrcutor for you which in turn is calling your no arg parent class constructor and is throwing a null pointer exception..
answers question: http://stackoverflow.com/q/21583399

http://stackoverflow.com/comment/32637668
score: 0
has text: @AssafG. Yes, that is what last picture about. In my opinion, it seems to be ok.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21595745

http://stackoverflow.com/q/21651336
has comment: http://stackoverflow.com/comment/32722960
possible better answer: http://stackoverflow.com/a/21652035
tagged with: while-loop
has body: I want the user to enter integers into an array. I have this loop I wrote which has a try and catch in it, in case a user inserts a non integer. There's a boolean variable which keeps the loop going if is true. This way the user will be prompted and prompted again. Except, when I run it, it gets stuck in a loop where it repeats "Please enter # " and "An Integer is required" without letting the user input a new number. I reset that number if an exception is caught. I don't understand. import java.util.*; public class herp { //The main accesses the methods and uses them. public static void main (String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Hello and welcome!\n"); System.out.print("This program stores values into an array"+" and prints them.\n"); System.out.println("Please enter how many numbers would like to store:\n"); int arraysize = scan.nextInt(); int[] mainarray = new int[arraysize+1]; int checkint = 0; boolean notint = true; int prompt = 1; while (prompt &lt; mainarray.length) { // Not into will turn true and keep the loop going if the user puts in a // non integer. But why is it not asking the user to put it a new checkint? while(notint) { try { notint = false; System.out.println("Please enter #"+ prompt); checkint = scan.nextInt(); } catch(Exception ex) { System.out.println("An integer is required." + "\n Input an integer please"); notint = true; checkint = 1; //See, here it returns true and checkint is reset. } } mainarray[prompt] = checkint; System.out.println("Number has been added\n"); prompt++; notint = true; } } }
has answer: http://stackoverflow.com/a/21652035
has comment: http://stackoverflow.com/comment/32723101
has answer: http://stackoverflow.com/a/21651447
has comment: http://stackoverflow.com/comment/32723128
favorite count: 0
has title: Why is my try and catch stuck in a loop?
has comment: http://stackoverflow.com/comment/32722970
has comment: http://stackoverflow.com/comment/32722997
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32722947
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/21651447
upvote count: 1
type: Question
tagged with: try-catch
has comment: http://stackoverflow.com/comment/32722919
answer count: 2
downvote count: 0

http://stackoverflow.com/comment/32565715
comment on: http://stackoverflow.com/q/21559984
type: Comment
has text: use longs to store your date, I thought that had been said already.
type: QuestionComment
score: 0

http://stackoverflow.com/q/21612621
tagged with: collections
type: AnsweredQuestion
score: 3
tagged with: java
tagged with: comparable
has comment: http://stackoverflow.com/comment/32655594
type: Question
has answer: http://stackoverflow.com/a/21612660
linked to: http://stackoverflow.com/q/4432774
downvote count: 0
accepted answer: http://stackoverflow.com/a/21612660
tagged with: sorting
favorite count: 0
answer count: 3
possible better answer: http://stackoverflow.com/a/21612652
has answer: http://stackoverflow.com/a/21612652
has body: Quick example is a collection of users' first and last name. One method requires that I compare using the first name, another using the last name. Is it possible to have two different compareTo()? Or am I just better off creating two different value classes?
has title: Is it possible to have TWO compareTo methods for a value class?
has answer: http://stackoverflow.com/a/21612650
upvote count: 3

http://stackoverflow.com/comment/32859447
has text: I believe you wanted to do `Runtime.getRuntime().exec(arg1);` & not `Runtime.getRuntime().exec(filePath);`
comment on: http://stackoverflow.com/q/21650626
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/32642388
type: Comment
comment on: http://stackoverflow.com/a/21605286
has text: Sorry, but that's a really bad practice. I would never write the IP of the machine in the config file. Even the script that instantiates the JVM does detect the public IP address and puts it in the command line used to stat it.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/32705412
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21640952
score: 0
has text: Look at the exceptions's stack trace. It will tell you what line the problem is on.

http://stackoverflow.com/comment/33021624
score: 0
type: AnswerComment
has text: THis is not correct . THe answer work only from the folder . THis is not a real JAR
type: Comment
comment on: http://stackoverflow.com/a/21789045

http://stackoverflow.com/comment/32730803
type: Comment
score: 0
comment on: http://stackoverflow.com/a/21654125
type: AnswerComment
has text: @peeskillet I fixed those errors, could you post a link or a sample of what you mean by "Loop through the list of Pipe and use the drawPipe(g) method"?

http://stackoverflow.com/q/21654091
has title: MySQL Query Error SQLException
answer count: 1
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21654145
tagged with: java
tagged with: mysql
type: Question
has comment: http://stackoverflow.com/comment/32727980
tagged with: sqlexception
tagged with: jquery
has body: I encountered this issue when trying to implement query requests into a program. Connecting to the database without this method works fine, however, this throws a SQLException. String query = "SELECT EXISTS ( SELECT * FROM usr WHERE username = admin AND password = pass )"; boolean result; Connection con = null; try { con = DriverManager.getConnection(url, username, password); Statement stmt = (Statement) con.createStatement(); ResultSet rs = stmt.executeQuery(query); result = rs.next(); } catch (SQLException e) { throw new RuntimeException("Cannot connect to the database!", e); } finally { System.out.println("Closing the connection."); if (con != null) try { con.close(); } catch (SQLException ignore) { System.out.println("Unknown Error Connecting to MySQL Server!"); } } I brought the query into the method to isolate it. Any help would be appreciated.
score: 0

http://stackoverflow.com/q/21642367
has title: Java: How to compare if statement with object?
type: Question
tagged with: if-statement
has body: Hey Im trying to fill in different slots of this table with the variable f, however I need to do some checks on the row and column it is in before it is put in. I do not know how to change the if statement to make it work, it keeps giving me the null pointer exception. Please help :) This is the part of the code that needs fixing. for (int row1 = 0; row1 &lt; data.length; row1++) { for (int col1 = 0; col1&lt;data[0].length; col1++) { if(col1%2 != 0) { data[row1][col1]= "day" + d; d++; } else { Integer f = new Integer(1); int col2 = 0; int row3 = 0; boolean rows; for (int row2 = 0; row2 &lt; data.length; row2++) { if(data[row2][col2].equals(f))//this one { rows = false; } else { rows = true; } col2++; if(col2 &gt;= col) { col2 = 0; } for (int col3 = 0; col3&lt;data[0].length; col3++) { if(f &gt; a) { f = 1; } else if(rows == true &amp;&amp; data[row3][col3].equals(f))//this one { data[row3][col3]= f; } f++; row3++; if(row3 &gt;= row) { row3 = 0; } } } } } }
has comment: http://stackoverflow.com/comment/32707657
answer count: 1
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21642443
has comment: http://stackoverflow.com/comment/32707718
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/32707716

http://stackoverflow.com/q/21519828
has comment: http://stackoverflow.com/comment/32492475
score: 1
tagged with: java
has title: Why Bind a socket
type: Question
possible better answer: http://stackoverflow.com/a/21519860
has comment: http://stackoverflow.com/comment/32491540
linked to: http://stackoverflow.com/q/152457
downvote count: 0
linked to: http://stackoverflow.com/q/3003878
favorite count: 0
has answer: http://stackoverflow.com/a/21519929
answer count: 3
tagged with: sockets
has comment: http://stackoverflow.com/comment/32560559
has body: I've searched here and found a similar article but I didn't really get the answer I'm looking for. I'm learning Networking with Java through some examples and some pseudo-reverse engineering. Oracle's documentation is helping quite a bit too but I've got a few questions. Why exactly do you bind an IP address to a Socket? Is it necessary? When would you use said binding? Here is part of the code that raised the question to me: ServerSocket myServerSocket = new ServerSocket(1337); System.out.println("Server is waiting for an incoming connection from client..."); Socket recievingSocket = myServerSocket.accept(); Now from what I understand that if I was to bind a Socket it would be right after the running accept() correct?
has answer: http://stackoverflow.com/a/21519860
upvote count: 1
has answer: http://stackoverflow.com/a/21520486
accepted answer: http://stackoverflow.com/a/21520486
has comment: http://stackoverflow.com/comment/32491627
type: AnsweredQuestion

http://stackoverflow.com/q/21523764
tagged with: libgdx
has body: I am working on a rummikub game, I have a board which have tiles on it, and all positions on board are defined as TileActor. Some tile actors have actual tiles on them, some are empty. Problem is: when I drag a tile and drop it on an empty TileActor, it works fine but when I drop it on empty space, the actor is getting lost. How can I prevent the actors from getting lost? This is my drag&amp;drop code: dragAndDrop.addSource(new Source(actor) { @Override public Payload dragStart(InputEvent event, float x, float y, int pointer) { Payload payload = new Payload(); payload.setObject("Some payload!"); payload.setDragActor(getActor()); Label validLabel = new Label("Valid move!", skin); validLabel.setColor(0, 1, 0, 1); payload.setValidDragActor(validLabel); Label invalidLabel = new Label("Invalid!", skin); invalidLabel.setColor(1, 0, 0, 1); payload.setInvalidDragActor(invalidLabel); return payload; } dragAndDrop.addTarget(new Target(actor) { public boolean drag (Source source, Payload payload, float x, float y, int pointer) { getActor().setColor(Color.GREEN); return true; } public void reset (Source source, Payload payload) { getActor().setColor(Color.WHITE); } public void drop (Source source, Payload payload, float x, float y, int pointer) { int movingTile =((TileActor)source.getActor()).getPosition(); if(movingTile!=-1){ int newPosition=player.moveTileOnBoard(movingTile, ((TileActor)getActor()).getPosition()); } } });
downvote count: 0
answer count: 1
favorite count: 0
tagged with: drag-and-drop
upvote count: 2
score: 2
type: AnsweredQuestion
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21532855
has title: Actors are getting lost when drop failed -libgdx
accepted answer: http://stackoverflow.com/a/21532855

http://stackoverflow.com/q/21597735
has body: import java.util.Scanner; public class youalwaystwo { public static void main(String[] args) { String sentence; Scanner keyboard = new Scanner(System.in); System.out.println("Please enter a sentence."); sentence = keyboard.nextLine(); { if (sentence.charAt(sentence.length()-1) == '?' ) if (sentence.length( ) %2 == 0) System.out.println("Yes."); else if (sentence.charAt(sentence.length()-1) == '?' ) if (sentence.length( ) %1 == 0) System.out.println("No."); else if (sentence.charAt(sentence.length()-1) == '!' ) System.out.println("Wow."); else System.out.println("You always say \"" + sentence + "\"."); } } } The problem is when I enter a sentence without a ? or ! nothing gets printed.
has comment: http://stackoverflow.com/comment/32629344
upvote count: 0
has comment: http://stackoverflow.com/comment/32629373
has title: My else statement in an else if tree isn't printing
favorite count: 0
answer count: 5
has comment: http://stackoverflow.com/comment/32629446
score: -3
has answer: http://stackoverflow.com/a/21597830
has answer: http://stackoverflow.com/a/21598306
type: UnansweredQuestion
tagged with: java
downvote count: 3
has answer: http://stackoverflow.com/a/21597793
has answer: http://stackoverflow.com/a/21597867
type: Question
has answer: http://stackoverflow.com/a/21597879

http://stackoverflow.com/a/21567548
has comment: http://stackoverflow.com/comment/32577353
has comment: http://stackoverflow.com/comment/32576599
answers question: http://stackoverflow.com/q/21567400
has body: One reason I can think of is that you are placing network communication on the main thread. You are not allowed to do so. You can use AsyncTask http://developer.android.com/reference/android/os/AsyncTask.html For testing you can add the following in your Main Activity but it is consider bad practice. StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy);
score: 0
has comment: http://stackoverflow.com/comment/32576651
type: Answer

http://stackoverflow.com/comment/32723333
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21650462
has text: You sir, deserve more than ONE beer. I am truly thankful, as I sat hours not getting this. It works now. You made my entire day!

http://stackoverflow.com/a/21599216
score: 2
upvote count: 2
downvote count: 0
answers question: http://stackoverflow.com/q/21599096
type: Answer
has body: You can use // and /* ... */ comments where you like. There are also /** ... */ which are JavaDoc comments, and can be processed by external tools for generating JavaDoc documentation. See also: JavaDoc Eclipse or not it does not matter, this is not IDE dependent.
has comment: http://stackoverflow.com/comment/45880899

http://stackoverflow.com/q/21536116
accepted answer: http://stackoverflow.com/a/21536243
tagged with: java
type: Question
answer count: 2
has body: I'm working on a tracking system and it involves tracking a users path. I'm having trouble calculating the distance. I've been using the start location along with the most recent location update but that does not calculate the actual distance. In the onLocationChanged method I pass the location to my updateDistance function. I understand that the route needs to be broken into segments and then each segments value added to the total but I can't solve the problem. I've searched the site and am aware there is some similar topics but I haven't found a solution to my problem so I would be appreciative of any help. Here is my function to calculate distance so far. private void updateDistance(Location location) { Log.i("updateDistance", "In distance function"); locationA = new Location("point A"); locationB = new Location("point B"); locationA.setLatitude(firstlat); locationA.setLongitude(firstlon); lat = location.getLatitude(); lon = location.getLongitude(); locationB.setLatitude(lat); locationB.setLongitude(lon); // Calculate the distance between them distance = locationA.distanceTo(locationB); // if less than 10 metres, do not record if (distance &lt; 10.00) { Log.i("DISTANCE", "Values too close, so not used."); } else tv1.setText("Distance Travelled: " + distanceTravelled + " metres"); }
score: 0
has title: Calculating distance traveled in Android/Google Maps
has answer: http://stackoverflow.com/a/21536243
possible better answer: http://stackoverflow.com/a/28856176
has answer: http://stackoverflow.com/a/28856176
type: AnsweredQuestion

http://stackoverflow.com/q/21639505
type: Question
tagged with: android-layout
has body: I am setting a View's Height at an OnTouch event, later in that event I need to get the Height of that view. The problem is that the event needs to end so the View's Height is updated. Because of that the getHeight() method I call during the event, gives an outdated value. Is there any way to redraw the view before the event ends or to update the View's params?
score: 0
has answer: http://stackoverflow.com/a/21656576
answer count: 1
has title: View Width and Height get updated only after it is drawn
type: UnansweredQuestion
tagged with: android
tagged with: java

http://stackoverflow.com/comment/32744845
comment on: http://stackoverflow.com/q/21663275
score: 0
type: Comment
type: QuestionComment
has text: Please vote to close, i'll come up with some code.

http://stackoverflow.com/a/21621087
answers question: http://stackoverflow.com/q/21619997
score: 0
type: Answer
has body: Random random = new Random(); Set&lt;Integer&gt; twoSet = new HashSet&lt;&gt;(); while (twoSet.size() &lt; 2) { twoSet.add(random.nextInt(someNumber); } Take notice that if your range is too small this will loop endlessly. Also, you might want to take a look at this: http://en.wikipedia.org/wiki/Reservoir_sampling

http://stackoverflow.com/comment/100953795
type: Comment
comment on: http://stackoverflow.com/a/21568630
type: AnswerComment
score: 0
has text: Now that Java supports default method implementations in interfaces, this is much easier to do via multiple interfaces without needing to create delegate methods.

http://stackoverflow.com/q/21568886
tagged with: java
has comment: http://stackoverflow.com/comment/32617994
type: Question
linked to: http://stackoverflow.com/q/7229226
answer count: 2
has comment: http://stackoverflow.com/comment/32578997
has title: jcombobox is listing but unable to select the items in linux java1.6
has comment: http://stackoverflow.com/comment/32578999
downvote count: 0
has comment: http://stackoverflow.com/comment/32586164
accepted answer: http://stackoverflow.com/a/21925605
tagged with: linux
tagged with: java-6
has comment: http://stackoverflow.com/comment/32581121
has comment: http://stackoverflow.com/comment/32586021
has body: I am having a problem with jcombobox in linux java 1.6. The exact problem is the combo is listing the items when i click the combobox (down arrow) but it minimizes if the selection goes off. i.e I am unable to select the items in the list. The same code is working in windows(java1.5, 1.6) and linux(java 1.5). The prob is only in linux java 1.6. Please help me to get out of this. Thanks in advance. Below is the code, import java.awt.*; import java.awt.event.*; import javax.swing.*; public class JComboBoxDemo extends JPanel { public JComboBoxDemo() { String[] comboTypes = { "Numbers", "Alphabets", "Symbols" }; // Create the combo box, and set 2nd item as Default JComboBox comboTypesList = new JComboBox(comboTypes); comboTypesList.setSelectedIndex(2); comboTypesList.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JComboBox jcmbType = (JComboBox) e.getSource(); String cmbType = (String) jcmbType.getSelectedItem(); System.out.println(cmbType); } }); // Set up the picture // Layout the demo setLayout(new BorderLayout()); add(comboTypesList, BorderLayout.NORTH); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); } public static void main(String s[]) { JFrame frame = new JFrame("JComboBox Usage Demo"); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); frame.setContentPane(new JComboBoxDemo()); frame.pack(); frame.setVisible(true); } }
favorite count: 0
tagged with: jcombobox
score: 2
upvote count: 2
possible better answer: http://stackoverflow.com/a/21574810
has comment: http://stackoverflow.com/comment/32588340
has answer: http://stackoverflow.com/a/21574810
tagged with: swing
has comment: http://stackoverflow.com/comment/32584053
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21925605
has comment: http://stackoverflow.com/comment/32588684

http://stackoverflow.com/q/21636649
tagged with: java
tagged with: hibernate
type: Question
has answer: http://stackoverflow.com/a/21643540
has comment: http://stackoverflow.com/comment/32699933
linked to: http://stackoverflow.com/q/14810287
linked to: http://stackoverflow.com/q/4334197
answer count: 3
tagged with: spring-roo
has title: call to primitive JPA method throws WrongClassException
tagged with: jpa
downvote count: 0
has answer: http://stackoverflow.com/a/21639306
favorite count: 0
has answer: http://stackoverflow.com/a/21639172
linked to: http://stackoverflow.com/q/21916962
has body: public static UserDetail UserDetail.findUserDetail(Long id) { if (id == null) return null; return entityManager().find(UserDetail.class, id); } We are using spring Roo. Above is Roo generated finder method. Partial stack trace is as follows: Caused by: org.hibernate.WrongClassException: Object with id: 1501237 was not of the specified subclass: com.***.***.user.UserDetail (Discriminator: FacebookUserDetail) Has anyone come across this exception? EDIT This question and following questions are related to same issue. Java class file truncated I have two projects. My one project (say project2) depends on another project(project2). Both projects are maven project and project1 is listed in dependancies of project2. When I compile project2, all the class files from project1 should be copied to project2 (I imagine). But, I see that the file size of one of the class files in project1 is different than file size of class file for the same class in project2. If I decompile the files I get following results. Decompiled FacebookUserDetail.class from project1: package com.***.domain.user.external; import com.***.domain.user.UserDetailType; import java.util.List; import javax.persistence.Entity; import javax.persistence.TypedQuery; import org.aspectj.lang.JoinPoint; import org.aspectj.runtime.internal.CFlowCounter; import org.aspectj.runtime.reflect.Factory; import org.springframework.beans.factory.annotation.Configurable; import org.springframework.beans.factory.aspectj.AbstractDependencyInjectionAspect; import org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect; import org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl; @Configurable @Entity public class FacebookUserDetail extends ExternalUserDetail { public FacebookUserDetail() { JoinPoint localJoinPoint = Factory.makeJP(ajc$tjp_1, this, this); if ((!AnnotationBeanConfigurerAspect.ajc$if$bb0((Configurable)getClass().getAnnotation(Configurable.class))) &amp;&amp; (AbstractDependen…
type: UnansweredQuestion
tagged with: spring
score: 2
has comment: http://stackoverflow.com/comment/32697728
upvote count: 2

http://stackoverflow.com/a/21593078
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/69752096
upvote count: 1
answers question: http://stackoverflow.com/q/21557905
has body: I've got the solution i can simply change XMLWorkerHelper.getInstance().parseXHtml(writer, document, new FileInputStream("html file")); to XMLWorkerHelper.getInstance().parseXHtml(writer, document, new FileInputStream("html file"), new FileInputStream("css file"));
type: Answer

http://stackoverflow.com/a/21630899
score: 1
has comment: http://stackoverflow.com/comment/32692510
has comment: http://stackoverflow.com/comment/37191586
has comment: http://stackoverflow.com/comment/32688245
answers question: http://stackoverflow.com/q/21629802
has comment: http://stackoverflow.com/comment/32690393
has comment: http://stackoverflow.com/comment/32691010
has comment: http://stackoverflow.com/comment/32692280
accepted answer of: http://stackoverflow.com/q/21629802
has comment: http://stackoverflow.com/comment/32687458
has body: This could be solved using positive lookahead: /(?=.*[A-Z]+)(?=.*[0-9]+)(?=.*[.,_-]+).*/ This regex does 'lookahead' for at least one uppercase letter , at least one number and at least one of [.,_-] preceeded by anything and followed by anything. See: http://regex101.com/r/eN9sX4 EDIT: Updated according to Boris-the-Spiders comment: /(?=.*?[A-Z]+)(?=.*?[0-9]+)(?=.*?[.,_-]+).*/ The lookahead uses lazy quantifiers for optimized execution time... http://regex101.com/r/aF0eK4
has comment: http://stackoverflow.com/comment/32686967
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32690706
has comment: http://stackoverflow.com/comment/32688832
downvote count: 2
has comment: http://stackoverflow.com/comment/32687151
type: Answer
has comment: http://stackoverflow.com/comment/32689519
upvote count: 3

http://stackoverflow.com/comment/32767328
comment on: http://stackoverflow.com/q/21676958
has text: what do you mean by lowIndex? it returns the index of the item in the list if it exists.
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/32664769
has text: According to this [commit](https://github.com/spring-projects/spring-data-neo4j/commit/8a440bdedf2961969bfc0a3f10f98077d1258191), which seems to be included in the 3.0.0.RC1, it is depending on Neo4j 2.0.
comment on: http://stackoverflow.com/a/21533549
type: AnswerComment
type: Comment
score: 1

http://stackoverflow.com/comment/79803510
comment on: http://stackoverflow.com/a/46422794
has text: This can never be an answer for a JSF 2.0 project.... jsf-facelets.jar is **NOT** needed there!!!!
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/21645516
has answer: http://stackoverflow.com/a/47123088
has answer: http://stackoverflow.com/a/21655754
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/53459381
has answer: http://stackoverflow.com/a/21768580
tagged with: java
tagged with: hibernate
upvote count: 44
type: Question
accepted answer: http://stackoverflow.com/a/21655754
has answer: http://stackoverflow.com/a/61959155
score: 44
has answer: http://stackoverflow.com/a/21757496
answer count: 13
has answer: http://stackoverflow.com/a/37225924
has answer: http://stackoverflow.com/a/22278250
has answer: http://stackoverflow.com/a/27083410
has answer: http://stackoverflow.com/a/37522551
downvote count: 0
has answer: http://stackoverflow.com/a/48519569
favorite count: 0
has comment: http://stackoverflow.com/comment/32713486
has title: program using hibernate does not terminate
has answer: http://stackoverflow.com/a/48772812
has body: I created a program using Hibernate. The program reaches the main function end, nevertheless the program is running. I wonder if it happens when SessionFactory is configured using Hibernate Version 4.x. Is the way to configure wrong? manual1_1_first_hibernate_apps.java public static void main(String[] args) { args[0] ="list"; if (args.length &lt;= 0) { System.err.println("argement was not given"); return; } manual1_1_first_hibernate_apps mgr = new manual1_1_first_hibernate_apps(); if (args[0].equals("store")) { mgr.createAndStoreEvent("My Event", new Date()); } else if (args[0].equals("list")) { mgr.&lt;Event&gt;listEvents().stream() .map(e -&gt; "Event: " + e.getTitle() + " Time: " + e.getDate()) .forEach(System.out::println); } Util.getSessionFactory().close(); } private &lt;T&gt; List&lt;T&gt; listEvents() { Session session = Util.getSessionFactory().getCurrentSession(); session.beginTransaction(); List&lt;T&gt; events = Util.autoCast(session.createQuery("from Event").list()); session.getTransaction().commit(); return events; } Util.java private static final SessionFactory sessionFactory; /** * build a SessionFactory */ static { try { // Create the SessionFactory from hibernate.cfg.xml // hibernate version lower than 4.x are as follows // # it successful termination. but buildSessionFactory method is deprecated. // sessionFactory = new Configuration().configure().buildSessionFactory(); // version 4.3 and later // # it does not terminate. I manually terminated. Configuration configuration = new Configuration().configure(); StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build(); sessionFactory = configuration.buildSessionFactory(serviceRegistry); } 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); } } /** * @return built SessionFactory */ public s…
possible better answer: http://stackoverflow.com/a/27083410
has answer: http://stackoverflow.com/a/21650568
has comment: http://stackoverflow.com/comment/32733348

http://stackoverflow.com/comment/32786595
has text: @JarrodRoberson How exactly is that different from `a%2!=0`?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21654490
type: Comment

http://stackoverflow.com/comment/32603235
type: QuestionComment
has text: The compiler definitely did not give that error.
type: Comment
comment on: http://stackoverflow.com/q/21582936
score: 1

http://stackoverflow.com/comment/32655007
type: QuestionComment
comment on: http://stackoverflow.com/q/21612385
score: 0
has text: com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'USERNAME'. 1) Make sure username/pwd correct. 2) If you are accessing from remote machine, make sure remote access granted
type: Comment

http://stackoverflow.com/a/21675177
has comment: http://stackoverflow.com/comment/32764789
answers question: http://stackoverflow.com/q/21673668
type: Answer
has body: This is because one of them is element Node and the other two are text nodes and this is because of the structure of your file. You can get one as an answer by formatting your xml as follows: &lt;data-list&gt;&lt;entry&gt;&lt;/entry&gt;&lt;/data-list&gt; instead of: &lt;data-list&gt; &lt;entry&gt; &lt;/entry&gt; &lt;/data-list&gt; output will be one only. You can Check with the following code amendments: NodeList entries = datalist.getChildNodes(); for(int j=0;j&lt;entries.getLength();j++) { System.out.println(entries.item(j).getNodeName() + "&lt;&lt;&lt;&gt;&gt;&gt;&gt;" + entries.item(j).getNodeType()); } where nodetypes can be seen in source for Node class.
upvote count: 2
score: 2
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21673668

rfid
tag name: rfid
tags question: http://stackoverflow.com/q/21528974
type: Tag

http://stackoverflow.com/a/21624813
has body: use .equals() to compare string insted of == if(dummyTextView.getText().equals("1"))
upvote count: 1
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 1
accepted answer of: http://stackoverflow.com/q/21624537
answers question: http://stackoverflow.com/q/21624537

http://stackoverflow.com/a/21709182
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21667254
answers question: http://stackoverflow.com/q/21667254
score: 9
has comment: http://stackoverflow.com/comment/56878807
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/56889717
upvote count: 9
has body: It seems play on my machine fail to generate itself a self signed certificate. If I used my own self signed certificate it works with no problem. keytool -genkey -alias MyKey -keyalg RSA -keysize 2048 -keystore keystore.jks play -Dhttps.port=9443 -Dhttps.keyStore=keystore.jks -Dhttps.keyStorePassword=password run I got the answer from this [post] (Play 2.1 SSL Configuration)
type: Answer

http://stackoverflow.com/comment/32765359
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21635994
type: Comment
has text: That's really interesting but i'm interested by hadoop and i want to solve this problem using it.

http://stackoverflow.com/comment/32561915
has text: The other way makes no sense. Like this, you're saying `l` will have the value of `x`, that is passed as a parameter. The way you had before, you were saying that `x` (that isn't stored anywhere) will have the value of `l` (that doesn't even have a value, so it would be null or trash). Glad it helped, please mark answer as accepted :)
type: AnswerComment
comment on: http://stackoverflow.com/a/21558599
score: 0
type: Comment

http://stackoverflow.com/comment/32710276
type: AnswerComment
comment on: http://stackoverflow.com/a/21643959
type: Comment
has text: So how else would i exit my program? I want it to exit :P
score: 0

http://stackoverflow.com/q/21537636
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21538463
tagged with: spring-mvc
tagged with: java
tagged with: hibernate
type: Question
has answer: http://stackoverflow.com/a/21592096
score: 0
answer count: 3
has title: Spring MVC + Hibernate: How to handle form with relation
has body: I have problem with adding/updating records with relations. Could please some advice how it should work? I have two entities: Question and Category: public class Question { @Id @GeneratedValue private Long questionId; private String name; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "category") private Category category; and @Entity @Table(name = "category") public class Category { @Id @GeneratedValue private Long categoryId; private String name; I have some list of categories and I would like to add new Question with selected Category. So in my QuestionController I have add method: @RequestMapping(value = "/add", method = RequestMethod.GET) public ModelAndView add() { ModelAndView mav = new ModelAndView("question/add"); mav.addObject("question", new Question()); mav.addObject("categoryList", categoryService.getAll()); return mav; } and form: &lt;form:form modelAttribute="question" method="POST" &gt; Name: &lt;form:input path="name" value="${ques.name}" /&gt; Category: &lt;form:select path="category" items="${categoryList}" /&gt; &lt;input type="submit" value="Add" /&gt; &lt;/form:form&gt; Everything looks good for now (I can fill question name and select category). But I don't know how add POST method should work @RequestMapping(value = "/add", method = RequestMethod.POST) public String added(@ModelAttribute Question question, BindingResult bindingResult) { } When I try to use above method I have error: Failed to convert property value of type 'java.lang.String' to required type model.Category I've tried to look for similar problem but I coudln't find anything.. So if someone can help/advice or show link to similar issue I would be grateful! Cheers!
has answer: http://stackoverflow.com/a/21538471

http://stackoverflow.com/comment/32570075
score: 1
comment on: http://stackoverflow.com/q/21564154
type: Comment
type: QuestionComment
has text: Please add a tag for programming language (Java ?).

http://stackoverflow.com/a/21574573
answers question: http://stackoverflow.com/q/21574478
type: Answer
score: 10
upvote count: 10
downvote count: 0
has body: HttpClient is not a class, it is an interface. You cannot use it for development in the way you mean. What you want is a class that implements the HttpClient interface, and that is CloseableHttpClient.

http://stackoverflow.com/q/21648268
tagged with: java
has answer: http://stackoverflow.com/a/21648619
has comment: http://stackoverflow.com/comment/32717982
has comment: http://stackoverflow.com/comment/32719795
type: Question
has title: libGDX compiles only a Black Screen
tagged with: libgdx
has comment: http://stackoverflow.com/comment/32717656
has comment: http://stackoverflow.com/comment/32717869
has comment: http://stackoverflow.com/comment/32717920
answer count: 2
has body: SOLVED!!! Seems the image wasnt in a proportionate size, eg, 64x64, 128x128 Made a basic Hello World and this compiled all good, but when I try and get a basic graphic to display, all that shows is blackness. basically following a tutorial word for word and it still seems to be doing this. Any ideas anyone? package com.me.mygdxgame; import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL10; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture.TextureFilter; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; public class MyGdxGame implements ApplicationListener { SpriteBatch batch; BitmapFont font; Texture mario; @Override public void create() { mario = new Texture(Gdx.files.internal("mario.jpeg")); batch = new SpriteBatch(); font = new BitmapFont(); font.setColor(Color.CYAN); } @Override public void dispose() { batch.dispose(); font.dispose(); } @Override public void render() { Gdx.gl.glClearColor(1, 1, 1, 1); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); batch.begin(); batch.draw(mario, 200, 200); batch.end(); } @Override public void resize(int width, int height) { } @Override public void pause() { } @Override public void resume() { } } Just realised there was an error code coming up. file name is definitely correct. Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: data/mario.png at com.badlogic.gdx.graphics.Pixmap.&lt;init&gt;(Pixmap.java:140) at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64) at com.badlogic.gdx.graphics.Texture.load(Texture.java:142) at com.badlogic.gdx.graphics.Texture.&lt;init&gt;(Texture.java:133) at com.badlogic.gdx.graphics.Texture.&lt;init…
upvote count: 1
has comment: http://stackoverflow.com/comment/32718847
downvote count: 0
tagged with: macos
favorite count: 0
has comment: http://stackoverflow.com/comment/32717744
type: UnansweredQuestion
tagged with: android
has answer: http://stackoverflow.com/a/21648562
score: 1

http://stackoverflow.com/q/21605343
type: Question
has answer: http://stackoverflow.com/a/21607691
has comment: http://stackoverflow.com/comment/32642512
has answer: http://stackoverflow.com/a/21605562
has comment: http://stackoverflow.com/comment/32645322
accepted answer: http://stackoverflow.com/a/21607691
answer count: 3
downvote count: 0
has answer: http://stackoverflow.com/a/21605834
possible better answer: http://stackoverflow.com/a/21605562
favorite count: 0
tagged with: time
tagged with: android
has title: Date in Java is always 1 hour out?
has comment: http://stackoverflow.com/comment/32642438
type: AnsweredQuestion
has body: I'm currently experimenting to achieve the following purpose: I am creating an android app to help me manage rotas at work. More a project in spare time then to really help. For each employee, I can set a start and end time as a string in the following format: "HH:mm". I need to work out the total hours and then work out the total hours including breaks. Below, if someone worked more than 3 hours and 45 minutes but less than 6 hours I want them to have a 15 minute break. Example would be, if someone works 4 hours ( total hours 04:00 ) they would get a 15 minute break ( hours including breaks 03:45). Problem: Currently if I set hours to start at 06:00 and finish at 10:00 I want it to give me total hours as 4 hours and including breaks as 3 hours and 45 minutes. It is actually giving me the total hours as 5 and the hours including breaks as 5 hours and 45 minutes. private String calcDiffInHoursAsString(Date start, Date finish){ try{ DateFormat formatter = new SimpleDateFormat("HH:mm"); long diffInMillis = finish.getTime() - start.getTime(); Date diffAsDate = new Date(diffInMillis); String diffAsHours = formatter.format(diffAsDate); return diffAsHours; }catch(Exception ex){ return ""; } } private Date calcDiffInHoursAsDate(Date start, Date finish){ try{ DateFormat formatter = new SimpleDateFormat("HH:mm"); long diffInMillis = finish.getTime() - start.getTime(); Date diffAsDate = new Date(diffInMillis); return diffAsDate; }catch(Exception ex){ return new Date(); } } private String calcHoursToString(String start, String finish){ if (!(start == "00:00" &amp;&amp; finish == "00:00")){ try{ DateFormat formatter = new SimpleDateFormat("HH:mm"); Date startTime = formatter.parse(start); Date finishTime = formatter.parse(finish); Date HoursExcBreaks = calcDiffInHoursAsDate(startTime, finishTime); String HoursExcBreaksAsString = calcDiffInHoursAsString(startTime, finishTime); Log.d("Difference exc. Breaks", HoursExcBreaksAsString); // Breaks: // &lt; 4 hours - No Break // 4 - 6 …
score: 1
tagged with: java
upvote count: 1

http://stackoverflow.com/q/21554905
tagged with: mysql
type: Question
has answer: http://stackoverflow.com/a/21555060
has comment: http://stackoverflow.com/comment/32552678
has body: I have these two functions, one is on client side and it sends value to server script which then should return multiple values so I can populate textboxes. Here is what I've done: Client side can send multiple values to server side and server side executes mysql sucessfully but I can't figure out how to return multiple values from server to client side. Client: private void formWindowActivated(java.awt.event.WindowEvent evt) { String identifier = "getbasicinfo"; String hostname = "localhost"; int port = 6789; Socket clientSocket = null; DataOutputStream os = null; BufferedReader is = null; try { clientSocket = new Socket(hostname, port); os = new DataOutputStream(clientSocket.getOutputStream()); is = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); } catch (UnknownHostException e) { System.err.println("Don't know about host: " + hostname); } catch (IOException e) { System.err.println("Couldn't get I/O for the connection to: " + hostname); } // If everything has been initialized then we want to write some data // to the socket we have opened a connection to on the given port if (clientSocket == null || os == null || is == null) { System.err.println( "Something is wrong. One variable is null." ); return; } try { os.writeBytes( identifier + "\n" ); os.writeBytes( userdd + "\n" ); os.writeBytes( shop + "\n" ); String name = is.readLine(); String surname = is.readLine(); System.out.println( name + "\n"); System.out.println( surname + "\n"); txtname.setText(name); //it returns only this value txtsurname.setText(surname); os.close(); is.close(); clientSocket.close(); } catch (UnknownHostException e) { System.err.println("Trying to connect to unknown host: " + e); } catch (IOException e) { System.err.println("IOException: " + e); } } Server side of code: public void getBasicInfo(String username, String shop) { //....database code... stmt = conn.prepareStatement("SELECT * FROM workers inner join shops s where idworkers=? and s.idshops=?"); stmt.setSt…
has comment: http://stackoverflow.com/comment/32552554
accepted answer: http://stackoverflow.com/a/21556722
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/21556722
possible better answer: http://stackoverflow.com/a/21555060
tagged with: sockets
type: AnsweredQuestion
tagged with: java
has title: Returning multiple values through java sockets

http://stackoverflow.com/a/21667398
has body: Assign the result of the new command to a variable and interact with it frame aframe = new frame(); aframe.setVisible(true); aframe.Sub123(); You may also consider taking a look at Code Conventions for the Java Programming Language
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21667387
score: 4
accepted answer of: http://stackoverflow.com/q/21667387
upvote count: 4

http://stackoverflow.com/q/21656910
accepted answer: http://stackoverflow.com/a/21667830
has title: Stop MediaPlayer in the background - Android
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
type: Question
has body: In one of my activity, there is a button to play music using mediaPlayer. Also it has an option to play the music in background or stop when the activity is finished. I use this code for that. @Override protected void onStop() { super.onStop(); SharedPreferences perfs = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); if (!perfs.getBoolean("bg_play", true)) { mediaPlayer.stop(); mediaPlayer.release(); } } That works perfectly. Now the problem is when the user is back on the activity and press the play button, it starts a new mediaPlayer and play the new music. I want to stop the previous music running in background when new music is started. Here is my code private void myMediaPlayer() { if (mediaPlayer.isPlaying()) { mediaPlayer.pause(); } else { mediaPlayer.stop(); mediaPlayer.reset(); try { mediaPlayer.setDataSource(Environment.getExternalStorageDirectory()+"file.mp3"); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } try { mediaPlayer.prepare(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } mediaPlayer.start(); } } And the MediaPlayer declaration MediaPlayer mediaPlayer=new MediaPlayer(); before onCreate
tagged with: android-mediaplayer
has comment: http://stackoverflow.com/comment/32752292
has comment: http://stackoverflow.com/comment/32733558
has answer: http://stackoverflow.com/a/21667830
answer count: 1
downvote count: 0
favorite count: 0
tagged with: android

http://stackoverflow.com/comment/32674281
has text: Because this is how it was designed. :)
comment on: http://stackoverflow.com/q/21623706
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/q/21554350
answer count: 1
type: UnansweredQuestion
tagged with: maven
has title: Jboss remote project deployment
has body: Cant catch, how to do it. Have linux vps, wildfly(jboss) and cant deploy my war via intellij idea. Try to do it with IDEA tool, add remote jboss server, but no way to deploy artifact. Try to deploy war from maven via wildfly(jboss) admin panel, but maven cant run all tests, not sure why, artifact compile, build and work fine on local server. Any good way to do it manualy or via IDEA?
has answer: http://stackoverflow.com/a/21570666
tagged with: java
type: Question
tagged with: intellij-idea
tagged with: jboss
tagged with: eclipse
score: 0

http://stackoverflow.com/comment/32703394
type: QuestionComment
comment on: http://stackoverflow.com/q/21639695
has text: http://stackoverflow.com/questions/10237903/how-to-create-a-runnable-jar-file-from-source-code-programmatically
score: 0
type: Comment

http://stackoverflow.com/comment/32602210
type: Comment
has text: Why are you lying about your `Content-Type`?
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21582266

http://stackoverflow.com/q/21561295
tagged with: user-interface
answer count: 1
downvote count: 0
favorite count: 0
type: UnansweredQuestion
tagged with: is-empty
score: 1
tagged with: loops
upvote count: 1
tagged with: methods
type: Question
has answer: http://stackoverflow.com/a/21561406
has title: isEmpty Method for tictactoe game
tagged with: java
has body: public class TicTacToeModel { double xpos,ypos,xr,yr; char[][] position = {{' ',' ',' '}, {' ',' ',' '}, {' ',' ',' '}}; /** * Turns row, col into the center of the cells of any screen of resolution h by w. * This is ideal for the view. */ public void computePos(int row, int col, int h, int w){ xpos=(col+0.5)*w/3.0; ypos=(row+0.5)*h/3.0; xr=w/8.0; yr=h/8.0; } isEmpty() returns true if the cell at xpos ypos is blank. This does not validate that xpos and ypos are within range any idea how I can do this? public boolean isEmpty(int xpos, int ypos){ boolean isPosWithinRange = xpos&gt;=0 &amp;&amp; xpos&lt;9 &amp;&amp; ypos&gt;=0 &amp;&amp; ypos&lt;9; return (position[xpos][ypos] == ' ' &amp;&amp; isPosWithinRange); } Places an O at position xpos and ypos. No additional validation. public void placeO(int xpos, int ypos) { if(isEmpty(xpos, ypos)) { position[xpos][ypos]='O'; } }
has comment: http://stackoverflow.com/comment/32564514

http://stackoverflow.com/comment/32683913
score: 0
comment on: http://stackoverflow.com/q/21629228
type: Comment
type: QuestionComment
has text: What part of the linked question and the answers don't you understand?

http://stackoverflow.com/a/21658626
has comment: http://stackoverflow.com/comment/32735905
has comment: http://stackoverflow.com/comment/32735937
has body: This is a very common issue and there are multiple tutorials on the internetz, including the Super Csv page: http://supercsv.sourceforge.net/examples_reading_variable_cols.html As this line says: As shown below you can execute the cell processors after calling read() by calling the executeProcessors() method. Because it's done after reading the line of CSV, you have an opportunity to check how many columns there are (using listReader.length()) and supplying the correct number of processors.
downvote count: 0
answers question: http://stackoverflow.com/q/21658579
has comment: http://stackoverflow.com/comment/32735877
has comment: http://stackoverflow.com/comment/32736072
type: Answer
has comment: http://stackoverflow.com/comment/32735682
score: 1
has comment: http://stackoverflow.com/comment/32735791
upvote count: 1

http://stackoverflow.com/q/21621922
has body: My understanding of RequireJS was that if you required module B from module A, and then module B required module C, module C would be able to access module A. Is this correct? If not, how would I get module C to use A? Here's my problem: I have a Backbone model Accounts, a coffee file called Core, and the cmsmain file used by the require script tag in my HTML. cmsmain.coffee requirejs.config baseUrl: 'assets/javascripts/cms' paths: jquery: '../lib/jquery' backbone: '../lib/backbone' underscore: '../lib/underscore' AccountModel: 'model/account' require ['core', 'jquery', 'underscore', 'backbone'], (Core, $, _, Backbone) -&gt; Core.Start() core.coffee: define () -&gt; # Declare the app namespace Core = window.Core = Classes: Models: {} Collections: {} Controllers: {} Views: {} Rendered: Models: {} Collections: {} Controllers: {} Views: {} Templates: {} Routes: {} Start: -&gt; alert("Started") return Core model/account.coffee # Account Model define () -&gt; class Core.Classes.Models.Account extends Backbone.Model initialize: -&gt; login: (username, password) -&gt; Everything worked fine until i required the Account model, then I got: Uncaught ReferenceError: Core is not defined Even after I required Core in the accounts model i got: Uncaught TypeError: Cannot read property 'Classes' of undefined Both errors were generated by the account model
tagged with: requirejs
upvote count: 1
tagged with: java
tagged with: coffeescript
type: Question
downvote count: 0
answer count: 1
score: 1
has answer: http://stackoverflow.com/a/21622030
tagged with: playframework-2.2
favorite count: 0
tagged with: backbone.js
has title: How does RequireJS handle modules?
type: UnansweredQuestion

http://stackoverflow.com/q/21568612
linked to: http://stackoverflow.com/q/14618055
tagged with: java
score: -1
has answer: http://stackoverflow.com/a/21568678
accepted answer: http://stackoverflow.com/a/21568678
tagged with: methods
type: Question
downvote count: 1
has answer: http://stackoverflow.com/a/21568982
answer count: 7
favorite count: 0
has answer: http://stackoverflow.com/a/21568986
has comment: http://stackoverflow.com/comment/32578528
possible better answer: http://stackoverflow.com/a/21568982
has answer: http://stackoverflow.com/a/21568661
tagged with: command-line
has title: Recursive method sum of powers of 2 up to Xth power of 2
upvote count: 0
tagged with: return
has answer: http://stackoverflow.com/a/21569065
has answer: http://stackoverflow.com/a/21568796
has body: I am having issues with my recursive method, that will return and print in main() the sum of the powers of 2 up to the Xth power of 2. X is a integer on the commandline argument. So if my commandline argument is : "3" *Output would be: 15 It should work like (1 + 2 + 4 + 2^3) As you can see there's "3" powers of 2 So whatever my number is that's how much powers of 2 will be added. I manage to work out in getting the power of 2^x, but I'm really confused on getting the sum of the powers of 2 to be added into my calculation :o Also, I won't be utilizing Math.pow(), even if it would be easier x) My code atm: public static void main(String[] commandlineArguments) { if (commandlineArguments.length == 0) { System.out.println("Please enter a least one commandline!"); } else { Integer number = new Integer(0); // initialize number try { number = Integer.parseInt(commandlineArguments[0]); } catch (NumberFormatException exception) { // NumberFormatException System.out.println(exception + " is not a integer!"); System.exit(1); // end program } Integer power = power2(number); System.out.println(power); } } public static Integer power2(Integer number){ if (number == 0) { return 1; } else { return 2 * power2(number - 1); } } }
tagged with: recursion
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21568713

http://stackoverflow.com/a/33656283
has body: To compare two lists with the order preserved (strict order) use. assertThat(actualList, contains("item1","item2")); If we want to compare without a specific order we can use below command assertThat(collection, containsInAnyOrder("item1","item2"));
has comment: http://stackoverflow.com/comment/75148842
answers question: http://stackoverflow.com/q/21624592
upvote count: 3
downvote count: 9
has comment: http://stackoverflow.com/comment/67996248
has comment: http://stackoverflow.com/comment/75013138
has comment: http://stackoverflow.com/comment/57582678
has comment: http://stackoverflow.com/comment/75087208
type: Answer
has comment: http://stackoverflow.com/comment/75100514
score: -6

http://stackoverflow.com/q/21632472
score: 0
has comment: http://stackoverflow.com/comment/32692048
type: UnansweredQuestion
tagged with: multithreading
has comment: http://stackoverflow.com/comment/32699369
tagged with: garbage-collection
has comment: http://stackoverflow.com/comment/32690236
has comment: http://stackoverflow.com/comment/32690544
has comment: http://stackoverflow.com/comment/32690572
type: Question
has comment: http://stackoverflow.com/comment/32689993
has body: In one program I need to store weak references in a certain storage engine (an embedded Prolog database in fact). To keep the explanation simple, such storage engine can be considered (in the context of this question) as a collection of weak references. I need to warranty that weak references are going to be retracted from the storage engine as soon as the reference is reclaimed. In other words, it should not be possible to access a weak reference from the engine if its get() method already returns null. I currently implemented this by means of a ReferenceQueue. The following code extends a weak reference by means of a adding a cleanUp() method (which invokes a cleaning task that deletes the weak reference from the engine): public class MyWeakRef&lt;REF_TYPE&gt; extends WeakReference&lt;REF_TYPE&gt; { MyWeakRef(REF_TYPE referent, ReferenceQueue&lt;REF_TYPE&gt; referenceQueue, Runnable cleaningTask, ...) { super(referent, referenceQueue); this.cleaningTask = cleaningTask; ... } void cleanUp() { cleaningTask.run(); } ... } The code below shows how the references are cleaned in a separate thread that takes reclaimed references from a ReferenceQueue and invokes their cleanUp() method: public class WeakReferencesCleaner extends Thread { private static WeakReferencesCleaner referencesCleaner = new WeakReferencesCleaner(new ReferenceQueue&lt;Object&gt;()); public static WeakReferencesCleaner getWeakReferencesCleaner() { return referencesCleaner; } public synchronized static void startWeakReferencesCleaner() { if(!referencesCleaner.isAlive()) referencesCleaner.start(); } private ReferenceQueue&lt;?&gt; referenceQueue; public WeakReferencesCleaner(ReferenceQueue&lt;?&gt; referenceQueue, int priority) { this.referenceQueue = referenceQueue; this.setDaemon(true); } public ReferenceQueue&lt;?&gt; getReferenceQueue() { return referenceQueue; } @Override public void run() { while(true) { try { MyWeakRef&lt;?&gt; ref = (JTermRef&lt;?&gt;) referenceQueue.remove(); try { ref.cleanUp…
tagged with: java
has title: Cleaning up resources associated with weak reference
has comment: http://stackoverflow.com/comment/32694521
answer count: 1
has answer: http://stackoverflow.com/a/21685023
tagged with: weak-references

http://stackoverflow.com/q/21578301
tagged with: android
has title: Parsing table data with jsoup
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21579175
tagged with: string-parsing
upvote count: 1
tagged with: html-parsing
type: Question
tagged with: java
has body: I am using jsoup in my android app to parse my html code but now I need parse table data and I can not get it to work. I try many ways but not successful so I want try luck here if anyone have experience. Here is part of my html: My header My sub header Food Menu 1 vegetable and beef Allergens: 1, 3 Food Menu 2 Potato salad and pork Allergens: 6 etc My java/android code: try { String tableHtmlCode=""; Document fullHtmlDocument = Jsoup.connect(urlOfFoodDay).get(); Element elm1 = fullHtmlDocument.select("#editacia_jedla").first(); for( Element element : elm1.children() ) { tableHtmlCode+=element.getElementsByIndexEquals(2); //this set table content because 0=h2, 1=h3 } Document parsedTableDocument = Jsoup.parse(tableHtmlCode); //Element th = parsedTableDocument.select("td[class=jedlo neparna]").first(); THIS IS BAD String foodContent=""; String foodAllergens=""; } So now I want extract text vegetable and beef and save it to string foodContent and numbera 1, 3(together) from div class jedlo_box_alergeny save to string foodAllergens. Someone can help? I will very grateful for any ideas
tagged with: jsoup
answer count: 1
downvote count: 0
score: 1
has answer: http://stackoverflow.com/a/21579175
favorite count: 0

http://stackoverflow.com/comment/32654698
score: 2
comment on: http://stackoverflow.com/q/21612335
has text: `nameinput.nextLine()`?
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32583940
has text: yes makes sense, I will try to add a check similar to the above to avoid the filecopy all together if both absolute paths are equal.
type: Comment
comment on: http://stackoverflow.com/a/21571897
score: 0
type: AnswerComment

http://stackoverflow.com/a/21658411
score: 17
has comment: http://stackoverflow.com/comment/32735470
upvote count: 17
has comment: http://stackoverflow.com/comment/32760580
downvote count: 0
has comment: http://stackoverflow.com/comment/32735453
has comment: http://stackoverflow.com/comment/32735972
type: Answer
has comment: http://stackoverflow.com/comment/32735742
has body: No, you cannot use external synchronization to ensure atomicity of compound operations over ConcurrentHashMap. To be precise, you can use external synchronization to ensure atomicity of compound operations, but only if all operations with ConcurrentHashMap are synchronized over the same lock as well (though use of ConcurrentHashMap won't make sense in this case - you can replace it with regular HashMap). Approach with external synchronization works with Hashtable and Collections.synchronizedMap() only because they guarantee that their primitive operations are synchronized over these objects as well. Since ConcurrentHashMap doesn't provide such a guarantee, primitive operations may interfere with execution of your compound operations, breaking their atomicity. However, ConcurrentHashMap provides number of methods that can be used to implement compound operations in optimistic manner: putIfAbsent(key, value) remove(key, value) replace(key, value) replace(key, oldValue, newValue) You can use these operation to implement certain compound operations without explict synchronization, the same way as you would do for AtomicReference, etc.
answers question: http://stackoverflow.com/q/21658335

http://stackoverflow.com/q/21602411
has body: I have two beans annotated with @ManagedBean, @ViewScoped and an ejb annotated with @Stateless. I'm using @EJB and @ManagedProperty to inject ejb and bean into another. Thats is working, but I understand that it is butter to use CDI annotation. When I change to @Named and @ConversationScoped, I have an Exception: javax.el.PropertyNotFoundException: /dashboardBacker.xhtml @15,80 binding="#{dashboardBacker.dashboard}": Target Unreachable, identifier 'dashboardBacker' resolved to null at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:133) at com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(ApplicationImpl.java:1949) at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:1144) at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.createComponent(ComponentTagHandlerDelegateImpl.java:504) at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:157) at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120) at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98) at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137) at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184) at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120) at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98) at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137) at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184) at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120) at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:…
has answer: http://stackoverflow.com/a/21616710
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21616710
type: Question
has comment: http://stackoverflow.com/comment/32642844
tagged with: jsf
score: 0
has title: Change @ManagedBean and @ViewScoped to @Named and @CoversationScoped, javax.el.PropertyNotFoundException
tagged with: java
answer count: 1
has comment: http://stackoverflow.com/comment/32641663
tagged with: jakarta-ee
has comment: http://stackoverflow.com/comment/32638823
has comment: http://stackoverflow.com/comment/32642356
has comment: http://stackoverflow.com/comment/32643689

http://stackoverflow.com/q/21644186
tagged with: string
favorite count: 0
has body: I'm working on a recursive method that will return and print in my main method a String that will count down by 1 for N. Deleting one letter for each recursion for the string. Until N becomes 1 or until the string has 1 letter. (N being a int on the commandline) For example if my command lines aruments are: 5 valentine It should output too: 5 valentine, 4 alentine, 3 lentine, 2 entine, 1 ntine, So far I managed to count down the number inputted on the commandline argument. I just don't know how to go about deleting one letter from the string? :o My code so far: public static void main(String[] args){ int number = Integer.parseInt(args[0]); String word = new String(""); word = args[1]; String method = recursive.method1(number); System.out.println(method); } public static String method1(int number){ if (number &lt; 0){ return ""; } else{ return number + ", " + method1(number - 1); } }
has answer: http://stackoverflow.com/a/21644319
type: AnsweredQuestion
tagged with: recursion
tagged with: command-line
score: 1
has comment: http://stackoverflow.com/comment/32710604
tagged with: java
upvote count: 1
tagged with: methods
has title: Recursive method print string and counts down by 1 and deletes 1 letter for each recursion
type: Question
accepted answer: http://stackoverflow.com/a/21644319
answer count: 1
downvote count: 0

http://stackoverflow.com/q/21580147
favorite count: 0
has title: Mongo connection leak with morphia
has body: I have a Servlet with static Mongo = new Mongo() and Morphia morphia = new Morphia() objects. Each time GET is invoked, I do the following: doGet(...){ ... datastore = morphia.createDatastore(mongo, dbName); ... } I don't close datastore, because there is no close method. Each time i invoke the servlet, number of used connections in mongo grow: { "current" : 113, "available" : 706, "totalCreated" : NumberLong(122) } &gt; db.serverStatus().connections { "current" : 115, "available" : 704, "totalCreated" : NumberLong(124) } &gt; db.serverStatus().connections { "current" : 116, "available" : 703, "totalCreated" : NumberLong(125) } &gt; db.serverStatus().connections { "current" : 121, "available" : 698, "totalCreated" : NumberLong(130) } &gt; db.serverStatus().connections { "current" : 122, "available" : 697, "totalCreated" : NumberLong(131) } &gt; db.serverStatus().connections { "current" : 128, "available" : 691, "totalCreated" : NumberLong(137) } what is the right way to close connections with mongo and morphia and where the connection is really leaking? Thanks.
has answer: http://stackoverflow.com/a/21580487
type: AnsweredQuestion
score: 3
upvote count: 3
tagged with: java
type: Question
tagged with: mongodb
accepted answer: http://stackoverflow.com/a/21580487
tagged with: morphia
answer count: 1
downvote count: 0

http://stackoverflow.com/q/21582954
tagged with: mysql
type: Question
has body: I'm running what would seem as an otherwise simple piece of code. On its simplified form, it looks like this: public class ReadDB throws SQLException { private Connection conn; private PreparedStatement myStmt; public ReadDB(Connection connection) { conn = connection; } public List&lt;GameEvent&gt; getEvents(int gameId) { List&lt;GameEvent&gt; ret = new ArrayList&lt;GameEvent&gt;(); myStmt = conn.prepareStatement("select * from logs where gameid=? order by id"); myStmt.setInt(1, gameId); myStmt.setQueryTimeout(10); // Wasn't there before, doesn't really help ResultSet rs = myStmt.executeQuery(); while( rs.next() ) { // Do stuff, using "rs.getString()" } rs.close(); myStmt.close() return ret; } } And this is what the database initialization looks like (the connection parameter): String url=“jdbc:mysql://server.example.com/database_name”; cProperties = new Properties(); cProperties.put(“user”, user); cProperties.put(“password”, password); // truncate field values that are too long cProperties.put(“jdbcCompliantTruncation”, “false”); connection=DriverManager.getConnection(url,cProperties); Now, my problem is: after calling the getEvents method several times (around 30), executeQuery() will just hang. No exception, no return value, nothing - it just stops there, probably in some kind of loop. The database is read only, so there are no INSERT of any kind. Connecting to the (MySQL) database, show processlist lists the connection as Sleep while the connection time goes up. Of course, I can run the query just fine in a parallel window, but the Java program for some reason cannot. Also, it always hangs in a different gameId, so it's not related to that particular set. Given that a very similar piece of code used to run just fine, I'm guessing that either I'm not opening/closing the connection the right way, or a network-related problem. Ideas, anyone? Edit: I updated the code according to address some of the comments, still with no positive results. Regarding debugging, the …
has answer: http://stackoverflow.com/a/52815585
tagged with: java
has comment: http://stackoverflow.com/comment/32647648
score: 0
has title: Why is my executeQuery hanging up?
has comment: http://stackoverflow.com/comment/32603678
answer count: 1
has comment: http://stackoverflow.com/comment/32603627
has comment: http://stackoverflow.com/comment/32603635
has comment: http://stackoverflow.com/comment/32648691
type: UnansweredQuestion

http://stackoverflow.com/a/21651006
accepted answer of: http://stackoverflow.com/q/21648710
answers question: http://stackoverflow.com/q/21648710
type: Answer
has comment: http://stackoverflow.com/comment/32726085
score: 1
upvote count: 1
has body: are your form fields named with A[numericIndex]? for example: (where A is your list) &lt;c:forEach items="${A}" varStatus="status"&gt; … &lt;form:input path="A[${status.index }].attribute"/&gt; … &lt;/c:forEach&gt;
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/40669748
has body: Check for 'org.eclipse.wst.common.component' in your '.settings' folder in your maven project location. Check that the dependencies in that file are configured correctly. Make sure that a file (jar) is not added as a dependency at a placeholder for a folder. I faced this issue when I added jar dependencies which were sibling modules to my project. I removed the 'dependency' tags and let maven configure the deployment descriptor for me automatically. This worked for me and I cannot seem to find any other resource on google for this.
answers question: http://stackoverflow.com/q/21531500
type: Answer
score: 0

http://stackoverflow.com/a/21764544
type: AcceptedAnswer
downvote count: 0
score: 4
type: Answer
has body: The JAX-RS specification doesn't say anything about how multipart/form-data should be handled. Different JAX-RS implementations have their own proprietary ways to deal with this. As far as I can find, Apache Wink (that we build on top of) doesn't support @FormParam for multipart. It does seems that there are some support types in Wink for multi part: http://wink.apache.org/documentation/1.1.1/html/7.8%20MultiPart.html but these classes are not exposed by the Amdatu Wink bundle, and I have never tried using this either. A workaround I use myself is the example below. This is useful when multipart is used to upload files together with other form fields (this is why multipart is mostly used). I use Apache File Upload to parse the request and get access to both the uploaded files and form fields. @POST @Consumes(MediaType.MULTIPART_FORM_DATA) public void test(@Context HttpServletRequest request) { ServletFileUpload uploader = new ServletFileUpload(new DiskFileItemFactory()); try { List&lt;FileItem&gt; parseRequest = uploader.parseRequest(request); for (FileItem fileItem : parseRequest) { if (fileItem.isFormField()) { System.out.println(fileItem.getFieldName() + ": " + fileItem.getString()); } } } catch (FileUploadException e) { e.printStackTrace(); } }
answers question: http://stackoverflow.com/q/21643724
upvote count: 4
accepted answer of: http://stackoverflow.com/q/21643724

http://stackoverflow.com/a/21542105
type: Answer
score: 0
has body: It could be you exceeded the memory allowed by the app. Do you have a lot of images or inputs in the app? You could try decreasing the amount of memory used. http://developer.android.com/training/articles/memory.html
answers question: http://stackoverflow.com/q/21542067

http://stackoverflow.com/a/21587015
type: Answer
has comment: http://stackoverflow.com/comment/32611572
has body: Futuer#cancel(boolean) javadoc states This attempt will fail if the task has already completed, has already been cancelled, or could not be cancelled for some other reason. If successful, and this task has not started when cancel is called, this task should never run. If the task has already started, then the mayInterruptIfRunning parameter determines whether the thread executing this task should be interrupted in an attempt to stop the task. So either the ExecutorService hasn't executed the Runnable/Callable and can remove it from its queue or it has and the ExecutorService has to call Thread#interrupt() and your Runnable/Callable code has to handle it. There's no other way through the Future interface to interrupt a thread. If your Runnable doesn't have a way to handle interrupts, then a number of things can happen. If an InterruptedException occurs, it will bubble up to the ExecutorService and be wrapped in a ExecutionException that will be thrown from Future#get(). If no InterruptedException occurs in the thread executing the Runnable, your Runnable will continue unhindered. You should really consider changing your Runnable to handle interrupts.
accepted answer of: http://stackoverflow.com/q/21586586
has comment: http://stackoverflow.com/comment/32611623
score: 2
answers question: http://stackoverflow.com/q/21586586
has comment: http://stackoverflow.com/comment/32611906
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32611810
upvote count: 2

http://stackoverflow.com/comment/32515761
type: Comment
comment on: http://stackoverflow.com/a/21527930
has text: telescoping constructors tend to be more trouble than they are worth. chapter 2 of Effective Java shows a couple of different and better ways to handle this - static factory methods and builders.
type: AnswerComment
score: 0

http://stackoverflow.com/a/21626188
answers question: http://stackoverflow.com/q/21625534
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21625534
has comment: http://stackoverflow.com/comment/32678612
type: Answer
upvote count: 11
has body: You need to remove the Phone explicitly from the phones collection, it's not enough to remove it with the EntityManager. From the other side, it might be sufficient to use orphanRemoval, so if you remove an entity from a collection, it gets automatically deleted. Something like: @OneToMany(mappedBy="person", orphanRemoval="true") private List&lt;Phone&gt; phones; See also: http://docs.oracle.com/cd/E19798-01/821-1841/giqxy/index.html Cascade.REMOVE only removes the child entity if the parent entity is removed as well. Cascase.MERGE has nothing to do with this problem.
score: 11
has comment: http://stackoverflow.com/comment/32678680

http://stackoverflow.com/a/21667917
answers question: http://stackoverflow.com/q/21667864
has body: Create a method to generate a certain number of # to a string, like so: public static String generateNumberSigns(int n) { String s = ""; for (int i = 0; i &lt; n; i++) { s += "#"; } return s; } And then use that method to generate a string to pass to the DecimalFormat class: double value = 1234.567890; int numPlaces = 5; String numberSigns = generateNumberSigns(numPlaces); DecimalFormat fmt = new DecimalFormat ("0." + numberSigns); System.out.println(fmt.format(value)); OR simply do it all at once without a method: double value = 1234.567890; int numPlaces = 5; String numberSigns = ""; for (int i = 0; i &lt; numPlaces; i++) { numberSigns += "#"; } DecimalFormat fmt = new DecimalFormat ("0." + numberSigns); System.out.println(fmt.format(value));
score: 7
upvote count: 7
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32752491
has comment: http://stackoverflow.com/comment/32752508
accepted answer of: http://stackoverflow.com/q/21667864
type: Answer

http://stackoverflow.com/q/21515979
answer count: 0
type: UnansweredQuestion
has body: I integrated Google+ button, and I see it in my app but it's "greyed out" or white, it's not red and white and when I click it nothing happens. Here's my code: public class Menu extends Activity implements OnClickListener, ConnectionCallbacks, OnConnectionFailedListener{ private static final int REQUEST_CODE_RESOLVE_ERR = 9000; private ProgressDialog mConnectionProgressDialog; private PlusClient mPlusClient; private ConnectionResult mConnectionResult; private PlusOneButton mPlusOneButton; ImageButton exit; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final PlusOneButton mPlusOneButton = new PlusOneButton(this); mPlusClient = new PlusClient.Builder(this, this, this).clearScopes() .build(); mPlusOneButton.initialize("https://market.android.com/details?id=" + getPackageName(), new OnPlusOneClickListener() { @Override public void onPlusOneClick(Intent intent) { mPlusOneButton.setVisibility(View.INVISIBLE); startActivityForResult(intent, 0); } }); setContentView(R.layout.menu); inicijalizujVars(); } @Override protected void onStart() { super.onStart(); mPlusClient.connect(); } @Override protected void onStop() { super.onStop(); mPlusClient.disconnect(); } @Override public void onConnectionFailed(ConnectionResult result) { if (mConnectionProgressDialog.isShowing()) { if (result.hasResolution()) { try { result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR); } catch (SendIntentException e) { mPlusClient.connect(); } } } mConnectionResult = result; } @Override protected void onActivityResult(int requestCode, int responseCode, Intent intent) { if (requestCode == REQUEST_CODE_RESOLVE_ERR &amp;&amp; responseCode == RESULT_OK) { mConnectionResult = null; mPlusClient.connect(); } } private void inicijalizujVars() { exit = (ImageButton) findViewById(R.id.imageButtonExit); exit.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub finish(); } }); } @Overri…
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32508581
tagged with: google-plus
score: 0
tagged with: android
has comment: http://stackoverflow.com/comment/32511258
has title: My Google+ button doesn't do anything. Why?

ant
tags question: http://stackoverflow.com/q/21577761
tags question: http://stackoverflow.com/q/21588186
tags question: http://stackoverflow.com/q/21554810
type: Tag
tags question: http://stackoverflow.com/q/21603973
tags question: http://stackoverflow.com/q/21639210
tags question: http://stackoverflow.com/q/21547126
tags question: http://stackoverflow.com/q/21527082
tags question: http://stackoverflow.com/q/21583042
tag name: ant
tags question: http://stackoverflow.com/q/21554088
tags question: http://stackoverflow.com/q/21621893
tags question: http://stackoverflow.com/q/21674284
tags question: http://stackoverflow.com/q/21591636
tags question: http://stackoverflow.com/q/21543022
tags question: http://stackoverflow.com/q/21673618
tags question: http://stackoverflow.com/q/21674778

http://stackoverflow.com/comment/32591153
score: 0
type: Comment
has text: Then take a look at my edit in the answer. `\\d+` will detect inputs as `1234`, but not `name1`. You should use `\\D+` to match only non-digits.
comment on: http://stackoverflow.com/a/21575879
type: AnswerComment

http://stackoverflow.com/q/21634112
downvote count: 2
upvote count: 1
has answer: http://stackoverflow.com/a/21634233
has answer: http://stackoverflow.com/a/21634620
favorite count: 0
has body: Its like there are many class like Login.java, Updatedetails.java, Result.java etc. Here is the java code for Login.java package com.example.catxam; import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONException; import org.json.JSONObject; import com.example.catxam.JSONParser; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; import android.app.ProgressDialog; import android.content.Intent; import android.os.AsyncTask; import android.util.Log; import android.widget.EditText; import android.view.Window; import android.view.WindowManager; import android.widget.TextView; public class Login extends Activity { private EditText inputUserid, inputPassword, server; TextView forgotPassword; private Button b1; public static String serve; // Progress Dialog private ProgressDialog pDialog; // JSON parser class JSONParser jsonParser = new JSONParser(); // JSON Node names private static final String resp = "success"; private static final String Flag = "flag"; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.login); inputUserid = (EditText) findViewById(R.id.Username_edit); inputPassword = (EditText) findViewById(R.id.User_password); server = (EditText) findViewById(R.id.serverSelection); forgotPassword = (TextView) findViewById(R.id.forgotPassword); forgotPassword.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent passForget = new Intent(getApplicationContext(), ForgotPassword.class); startActivity(passForget); } }); b1 = (Button) findViewById(R.id.loginbutton); // login button b1.setOnClickListener(new View.OnClickListene…
tagged with: android
type: UnansweredQuestion
has title: i want to call variables from one java class to different java class in android
tagged with: java
score: -1
type: Question
answer count: 2

http://stackoverflow.com/comment/32536811
has text: Well look at the error - the value it's parsing is simply not a date. It looks like the problem is in `readLVD` (or `writeLVD`), not the parsing. Unfortunately you haven't provided that code, so we can't help you find the problem in it.
score: 2
comment on: http://stackoverflow.com/q/21545766
type: QuestionComment
type: Comment

http://stackoverflow.com/q/21624841
type: AnsweredQuestion
tagged with: list
tagged with: clone
has answer: http://stackoverflow.com/a/21625110
has answer: http://stackoverflow.com/a/21624937
tagged with: java
has answer: http://stackoverflow.com/a/21624960
type: Question
linked to: http://stackoverflow.com/q/3941850
score: 0
has title: Make a deep copy with clone
has answer: http://stackoverflow.com/a/21624943
has body: I am having a list of company objects. I am trying to clone this list with: public static List&lt;Company&gt; cloneList(List&lt;Company&gt; list) { List&lt;Company&gt; clone = new ArrayList&lt;Company&gt;(list.size()); for(Company item: list) clone.add(item.clone()); return clone; } However my compiler says: Multiple markers at this line - The method add(Company) in the type List&lt;Company&gt; is not applicable for the arguments (Object) Why is this not possible to make a deep copy with clone()?
possible better answer: http://stackoverflow.com/a/21624937
accepted answer: http://stackoverflow.com/a/21624960
answer count: 4

http://stackoverflow.com/a/21559087
has body: Create your class which implements MouseListener, and pass it by addMouseListener method... ? http://docs.oracle.com/javase/tutorial/uiswing/events/mouselistener.html
score: 1
answers question: http://stackoverflow.com/q/21558916
upvote count: 1
type: Answer
downvote count: 0

http://stackoverflow.com/q/21580896
accepted answer: http://stackoverflow.com/a/23943613
answer count: 1
has body: I wrote a CXF SOAP client and would like to create numbered log files for each run. I have tried configuring FileHandler using "logging.properties" file. I have this line there: handlers= java.util.logging.FileHandler .level= INFO java.util.logging.FileHandler.pattern = campaignStatusCXF%u.log java.util.logging.FileHandler.limit = 50000 java.util.logging.FileHandler.count = 1 java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter # Limit the message that are printed on the console to WARNING and above. java.util.logging.ConsoleHandler.level = WARNING java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter But it does not work just by itself. I had to add FileHandler in the code: System.setProperty("java.util.logging.config.file", "/logging.properties"); LOG = Logger.getLogger(BulkEmailDownloader.class.getName()); try { FileHandler logFile; logFile = new FileHandler("campaignStatus.log"); logFile.setFormatter(new SimpleFormatter()); LOG.addHandler(logFile); } catch (SecurityException e1) { } catch (IOException e2) { } The problem with this approach is - it simply rewrites the log all the time. I read numerous examples and answers, for example this, but could not find the answer I am looking for.
has answer: http://stackoverflow.com/a/23943613
tagged with: logging
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/15758685
score: 0
tagged with: java
has title: Java Logging to files using pattern
type: Question

http://stackoverflow.com/comment/32725231
type: Comment
has text: Might be worth adding a note about `Arrays.asList(Files.readAllBytes(path))` since he wants an `ArrayList`.
comment on: http://stackoverflow.com/a/21652572
score: 0
type: AnswerComment

http://stackoverflow.com/q/21526370
has body: In my program I have two dices with 100 faces. I make it count the amount of rolls it takes for dice one (d1) to equal 99 AND dice two (d2) to equal 26. package diceroll; import java.util.Random; public class DiceRoll { public static void main(String[] args) { int count = 0; int d1 = 0; int d2 = 0; while (d1 != 99 &amp;&amp; d2 != 29) { d1 = (int) (Math.random() * 100) + 1; d2 = (int) (Math.random() * 100) + 1; count += 1; } System.out.println(count + " " + d1 + " " + d2); } When using the AND operator (&amp;&amp;) the while loop only works until one of the numbers is found, however when using the OR operator (d1 != 99 || d2 != 29) the while loop works until both of them are matched. Can somebody explain why OR gives the expected results, whilst AND doesn't?
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21526453
has title: Rolling two dices. Count number of iterations for both of them to match condition
tagged with: java
downvote count: 3
has comment: http://stackoverflow.com/comment/32502570
accepted answer: http://stackoverflow.com/a/21526454
has answer: http://stackoverflow.com/a/21526453
type: Question
upvote count: 0
tagged with: dice
favorite count: 0
has answer: http://stackoverflow.com/a/21526454
has answer: http://stackoverflow.com/a/21526455
has comment: http://stackoverflow.com/comment/32502565
score: -3
has comment: http://stackoverflow.com/comment/32502736
has answer: http://stackoverflow.com/a/21552694
answer count: 4

http://stackoverflow.com/q/21565606
tagged with: eclipse
type: Question
has answer: http://stackoverflow.com/a/21565647
favorite count: 0
has title: Java eclipse location coding error
downvote count: 3
tagged with: android
answer count: 1
upvote count: 0
type: UnansweredQuestion
score: -3
has body: GETTING A LED LINE UNDER LOCATIONLISTENER (LOCATIONLISTENER CANNOT BE RESOLVED TO A TYPE) PLEASE HAVE A LOOK. I FOLLOWED THE METHOD FROM GOOGLE DEVELOPERS SITE. THANKS "package com.xxxxxxx; import com.google.android.maps.MapActivity; import android.app.Activity; import android.content.Context; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.view.View; public class MainActivity&lt;MapController&gt; extends MapActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Acquire a reference to the system Location Manager LocationManager locationManager = (LocationManager) this.getSystemService (Context.LOCATION_SERVICE); // Define a listener that responds to location updates LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { // Called when a new location is found by the network location provider. makeUseOfNewLocation(location); } public void onStatusChanged(String provider, int status, Bundle extras) {} public void onProviderEnabled(String provider) {} public void onProviderDisabled(String provider) {} }; // Register the listener with the Location Manager to receive location updates locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); } protected void makeUseOfNewLocation(Location location) { // TODO Auto-generated method stub } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } }" GETTING A LED LINE UNDER LOCATIONLISTENER (LOCATIONLISTENER CANNOT BE RESOLVED TO A TYPE) PLEASE HAVE A LOOK. I FOLLOWED THE METHOD FROM GOOGLE DEVELOPERS SITE. THANKS
tagged with: java
has comment: http://stackoverflow.com/comment/32572866

http://stackoverflow.com/comment/32734107
has text: Np feel free to mark the answer which has answered your question
comment on: http://stackoverflow.com/a/21657557
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/32546258
comment on: http://stackoverflow.com/a/21550317
has text: And where will I mention the source(in ubuntu) and destination(in windows) of csv file.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32506424
has text: http://stackoverflow.com/questions/17739362/java7-try-with-resources-statement-advantage
comment on: http://stackoverflow.com/q/21528485
type: Comment
type: QuestionComment
score: 1

http://stackoverflow.com/comment/32767139
has text: "stack" the literal will be in the constant pool but s will refer to a copy of it which will be on the heap (due to `new String(...)`).
type: Comment
comment on: http://stackoverflow.com/a/21676426
score: 2
type: AnswerComment

http://stackoverflow.com/q/21534734
tagged with: android-layout
has comment: http://stackoverflow.com/comment/32527162
has comment: http://stackoverflow.com/comment/32518503
has comment: http://stackoverflow.com/comment/32527115
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32520388
has comment: http://stackoverflow.com/comment/32527171
has body: I'm trying to dynamically set the text of my textView but I can't display neither the text nor the logcat message. The app launch don't cause any errors. I've tried to use the onClick attribute in xml file instead of the click listener to launch a method that set the text but even so doesn't work,please help me. Here's my code: public class Anteprima extends Activity{ TextView tx; Button button; ZoomControls zoom; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.anteprima); tx = (TextView)findViewById(R.id.textView1); button = (Button)findViewById(R.id.button1); tx.setText("0000000"); button.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { tx.setText("clickk"); Log.i("anteprima ","click"); }}); targetPath = getIntent().getExtras().getString("target"); contenutoPath = getIntent().getExtras().getString("contenuto"); zoom = (ZoomControls)findViewById(R.id.zoomControls1); zoom.setIsZoomInEnabled(true); zoom.setIsZoomOutEnabled(true); zoom.setOnZoomInClickListener(new View.OnClickListener(){ @Override public void onClick(View v) { tx.setText("piu"); } }); zoom.setOnZoomOutClickListener(new View.OnClickListener(){ @Override public void onClick(View v) { tx.setText("meno"); } }); } } and here it is the layout &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="Button" /&gt; &lt;ZoomControls android:id="@+id/zoomControls1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_cente…
answer count: 1
has comment: http://stackoverflow.com/comment/32518496
score: 0
tagged with: android
has answer: http://stackoverflow.com/a/21536117
has comment: http://stackoverflow.com/comment/32518000
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32518049
has title: OnClickListener and textView set text

http://stackoverflow.com/comment/32644122
type: AnswerComment
score: 0
type: Comment
has text: @birryree so if i add in the pom just this: org.hibernate hibernate-core 4.3.0.Final
comment on: http://stackoverflow.com/a/21605826

http://stackoverflow.com/q/21623327
type: UnansweredQuestion
downvote count: 2
has answer: http://stackoverflow.com/a/21631585
upvote count: 1
tagged with: spring
tagged with: websphere-liberty
tagged with: profile
tagged with: java
score: -1
type: Question
tagged with: websphere
has body: i am getting the error while starting the application. kindly look at log and help me out 00000013 com.ibm.ws.app.manager.internal.statemachine.StartAction I CWWKZ0018I: Starting application program-integration-portal. [2/7/14 13:02:45:201 IST] 00000013 com.ibm.ws.logging.internal.impl.IncidentImpl I FFDC1015I: An FFDC Incident has been created: "java.lang.IllegalArgumentException: No enum constant com.ibm.ws.javaee.ddmodel.common.ResourceRefType.ResAuthEnum.CONTAINER com.ibm.ws.app.manager.internal.statemachine.StartAction 135" at ffdc_14.02.07_13.02.45.0.log [2/7/14 13:02:45:209 IST] 00000013 com.ibm.ws.logging.internal.impl.IncidentImpl I FFDC1015I: An FFDC Incident has been created: "java.lang.IllegalArgumentException: No enum constant com.ibm.ws.javaee.ddmodel.common.ResourceRefType.ResAuthEnum.CONTAINER com.ibm.ws.app.manager.internal.statemachine.StartAction$1 applicationStartFail" at ffdc_14.02.07_13.02.45.1.log [2/7/14 13:02:45:210 IST] 00000013 com.ibm.ws.app.manager.internal.statemachine.StartAction E CWWKZ0002E: An exception occurred while starting the application program-integration-portal. The exception message was: java.lang.IllegalArgumentException: No enum constant com.ibm.ws.javaee.ddmodel.common.ResourceRefType.ResAuthEnum.CONTAINER [2/7/14 13:02:45:248 IST] 00000017 com.ibm.ws.kernel.feature.internal.FeatureManager I CWWKF0008I: Feature update completed in 3.307 seconds. [2/7/14 13:02:45:248 IST] 00000017 com.ibm.ws.kernel.feature.internal.FeatureManager A CWWKF0011I: The server websphere is ready to run a smarter planet.
answer count: 1
favorite count: 0
has title: getting following error when i start websphere v8.5 liberty profile

http://stackoverflow.com/comment/32547151
comment on: http://stackoverflow.com/a/21551296
score: 2
has text: @mrt181 that's just because java has signed bytes and C# has unsigned bytes; 176 and -80 are the same thing (binary 10110000)
type: AnswerComment
type: Comment

http://stackoverflow.com/a/21523268
has body: You need to add the other xml to your current view :- package com.example.testdynamicviews; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); LinearLayout main = (LinearLayout)findViewById(R.id.mainView); // Your custom view will be added in this layout TextView text = myView(); text.setText("Rahul GuptaRahul GuptaRahul GuptaRahul GuptaRahul GuptaRahul GuptaRahul Gupta"); main.addView(text); // You forgot to add this line Button button = myCustomButton(); button.setText("Custom Button"); main.addView(button); } public TextView myView(){ View v; LayoutInflater li = LayoutInflater.from(getBaseContext()); v = li.inflate(R.layout.textview, null); int width = (int) (getResources().getDimension(R.dimen.testwidth)/ getResources().getDisplayMetrics().density); v.setLayoutParams(new LinearLayout.LayoutParams(width,LinearLayout.LayoutParams.WRAP_CONTENT)); return (TextView) v; } public Button myCustomButton(){ View v; LayoutInflater li = LayoutInflater.from(getBaseContext()); v = li.inflate(R.layout.custombutton, null); v.setBackgroundColor(Color.RED); int width = (int) (getResources().getDimension(R.dimen.testwidth)/ getResources().getDisplayMetrics().density); LinearLayout.LayoutParams params= new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT); params.setMargins(0, 10, 0, 0); v.setLayoutParams(params); return (Button) v; } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } } textv…
answers question: http://stackoverflow.com/q/21523192
score: 0
type: Answer

http://stackoverflow.com/comment/32705493
score: 0
comment on: http://stackoverflow.com/q/21639882
has text: I'm going to try that now! FirstName is a string I should have mentioned that, and the value is taken from a text box.
type: QuestionComment
type: Comment

http://stackoverflow.com/q/21647628
has answer: http://stackoverflow.com/a/21647685
tagged with: java
has body: I hope someone can direct me to the right direction. I have the below code in enum with department names and their codes. I want to be able to print the departments' full names with their descriptions on the screen. I want to accomplish that by using a switch statement, but I am unsure where to place the switch statement. enum DepartmentName { FINANCE ("FIN") , SALES ("SAL") , PAYROLL ("PYR") , LOGISTIC ("LGT") ; private final String department; DepartmentName(String abbr) { department = abbr; } public String getDepartmentCode() {return department;} @Override public String toString() { return "The department name is " + getDepartmentCode(); } } Any help is appreciated.
possible better answer: http://stackoverflow.com/a/21647685
downvote count: 0
has comment: http://stackoverflow.com/comment/32716405
has comment: http://stackoverflow.com/comment/32716448
type: AnsweredQuestion
score: 1
favorite count: 0
has answer: http://stackoverflow.com/a/21647679
type: Question
answer count: 2
has title: Switch statement with enum in Java
upvote count: 1
accepted answer: http://stackoverflow.com/a/21647679
tagged with: enums

http://stackoverflow.com/comment/32705830
type: Comment
type: QuestionComment
has text: For better help sooner, post a [MCTaRE](http://stackoverflow.com/help/mcve) (Minimal Complete Tested and Readable Example). You might want to change `canvas.stop();` to `System.out.println(arg0); canvas.stop();` to check the method is being called (or use a debugger to do the same).
score: 0
comment on: http://stackoverflow.com/q/21636437

http://stackoverflow.com/a/21596993
score: 4
answers question: http://stackoverflow.com/q/21596834
type: AcceptedAnswer
type: Answer
upvote count: 4
has body: This is because the column name in your sql query is max(tr_id). You can write it as ResultSet rs = db.getData("SELECT MAX(tr_id) as tr_id FROM transaction"); now you will be able to get it.
downvote count: 0
has comment: http://stackoverflow.com/comment/32628447
accepted answer of: http://stackoverflow.com/q/21596834

http://stackoverflow.com/q/21568188
favorite count: 0
has title: Identifying Tomcat start up Programmatically
upvote count: 1
type: AnsweredQuestion
score: 1
tagged with: java
has body: I am developing a automation tool where I have to manage tomcat through java. I can start and stop the tomcat using Runtime.getRuntime().exec("c:/program files/tomcat/bin/startup.bat"); and Runtime.getRuntime().exec("c:/program files/tomcat/bin/shutdown.bat"); and I can deploy the war files by copying to the web apps folder on startup of tomcat. The Issue is how to identify the tomcat is started programmatically .so that once it is started I can copy files into it.
type: Question
tagged with: tomcat
has answer: http://stackoverflow.com/a/21568222
answer count: 1
downvote count: 0
accepted answer: http://stackoverflow.com/a/21568222

http://stackoverflow.com/comment/32621795
comment on: http://stackoverflow.com/a/21593189
has text: @ansible That's true, I didn't see that at first glance (that they were using `=`. I edited that into the answer, thanks.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32534542
has text: Now the code worked partially after cleaning again it gives me first question and as i click radiobutton on second page it crashes I have added the logcat check it
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/21544097
score: 0

http://stackoverflow.com/comment/32487884
score: 0
comment on: http://stackoverflow.com/a/21517415
has text: Thank you so much for your help! I'm discovering the stresses of programming! Perhaps the same stresses that resulted in you becoming Mad. Who knows...
type: Comment
type: AnswerComment

http://stackoverflow.com/a/21549007
upvote count: 1
answers question: http://stackoverflow.com/q/21548862
type: Answer
has comment: http://stackoverflow.com/comment/32542565
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/32542706
has body: Try this: public static void main(String a[]) { String className = str[0]; // Make sure the class name is correct Class c = null; try { c = Class.forName(className); // create instance at runtime Object o = c.newInstance(); } catch (ClassNotFoundException exception) { // Handle } catch (InstantiationException exception) { // Handle } catch (IllegalAccessException exception) { // Handle } } Note: This will fail if the classname is incorrect. Please provide class-name along with the package hierarchy.
has comment: http://stackoverflow.com/comment/32543279

http://stackoverflow.com/comment/32663912
has text: Hi, thanks for this, but I tried adapting it to mine by changing the arraylist name and the place where it is getting stored but it does not work.
comment on: http://stackoverflow.com/a/21616901
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/21554901
tagged with: jaxb
upvote count: 1
type: Question
has title: XMLMarshalException when throwing custom WebApplicationException with Jersey 2.5.1
tagged with: jersey
downvote count: 0
has comment: http://stackoverflow.com/comment/32597751
tagged with: jersey-2.0
tagged with: moxy
favorite count: 0
has body: I upgraded from Jersey 2.4.1 to 2.5.1 and suddenly have an issue with my error reporting within my code. I apologize for the wall of text, but I figured a well documented question would be beneficial. Part of my pom.xml: org.glassfish.jersey.containers jersey-container-servlet 2.5.1 org.glassfish.jersey.core jersey-client 2.5.1 org.glassfish.jersey.media jersey-media-moxy 2.5.1 org.glassfish.jersey.ext jersey-bean-validation 2.5.1 Here are my POJOs: Abstract package com.mimi.rest.common; public abstract class AbstractRestStatus { protected int statusCode = 0; protected String statusMessage = "OK"; protected String userMessage = null; protected String internalMessage = null; protected boolean exception = false; // constructors, getters/setters } Implementation level: package com.mimi.product.rest; @XmlRootElement(name = "restStatus") public class RestStatus extends AbstractRestStatus { // constructors, getters/setters @Override public String getInternalMessage() { if (!RestConfiguration.INTERNAL_MESSAGES_ENABLED) { return null; } return internalMessage; } } Here are the exceptions: Abstract: package com.mimi.rest.common; public abstract class AbstractRestException extends WebApplicationException { private static final long serialVersionUID = 1L; private AbstractRestStatus restStatus = null; /** * Build a rest exception with the provided information to relay to Jersey * * @param status * @param restStatus */ public AbstractRestException(Status status, AbstractRestStatus restStatus) { super(Response.status(status).entity(restStatus.asException()).build()); this.restStatus = restStatus; } public AbstractRestException(Status status) { super(Response.status(status).build()); } //restStatus getter } Impl: package com.mimi.product.rest; public class RestException extends AbstractRestException { private static final long serialVersionUID = 1L; public RestException(Status status, RestStatus error) { super(status, error); } public RestException(Status status) { super(status); …
type: UnansweredQuestion
answer count: 0
score: 1
tagged with: java

http://stackoverflow.com/a/21518715
downvote count: 0
score: 1
upvote count: 1
has body: The short answer is, yes, you should drop your current approach and seek something else. Many hundreds of developer hours have gone into producing libraries that are capable of parsing XML files in standardised manner. There are any number of libraries available for parsing XML. You could start by taking a look at the inbuilt APIs, Java API for XML Processing (JAXP). Generally it comes down to two approaches. SAX or DOM. SAX is basically inline processing of the XML as it's parsed. This means, that as the XML document is being processed, you are been given the opportunity to process that parsing. This is good for large documents and when you only need linear access to the content. DOM (or Document Object Model) generates a model of the XML, which you can process at your leisure. It's better suited to smaller XML documents, as the entire model is normally read into memory and when you want to interact with the document in a non-linear fashion, such as searching for example... The following is a simple snippet of loading a XML document in a DOM... try { DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); try { Document doc = builder.parse(new File("Album.xml")); } catch (SAXException | IOException ex) { ex.printStackTrace(); } } catch (ParserConfigurationException exp) { exp.printStackTrace(); } Once you have the Document, you are ready to process it in any way you see fit. To my mind, it'd take a look at XPath, which is a query API for XML For example... import java.io.File; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.s…
type: Answer
answers question: http://stackoverflow.com/q/21518607

http://stackoverflow.com/comment/32567771
score: 0
comment on: http://stackoverflow.com/a/21562900
type: AnswerComment
type: Comment
has text: hm, yeah, this gives a full matrice at least :D Thanks a bunch!! :)) Do you know why mine stopped anyway?? Kinda curious about what happened, been working on it for a while before posting.

http://stackoverflow.com/q/21568826
favorite count: 0
has body: Java is no longer installed by default on OS X, but fortunately if a user tries to launch a Java app, they receive the following message: I really like this, as is clearly explains that Java is required and provides a one-click way to install it. It's simple and painless for end users. However, this prompts to install Java SE 6 rather than Java SE 7, which has been out for some time. This even happens on OS 10.9.1, the latest version as of this writing. I'm considering making my app require Java SE 7, but I want to ensure that users will be downloading the proper version (I'm aware I can bundle the JRE, but I would prefer not to add it since it would quadruple the app size). Ideally, I'd like for the dialog box shown above to continue to be shown, but instead of downloading Java SE 6, it downloads Java SE 7. I tried changing the JVMVersion key in the Info.plist file of my application to 1.7+, but that didn't make any difference and it still prompted to download Java SE 6 (which if it actually did require it, would result in an incompatibility). So is there a way that I can get OS X to prompt the user to download Java 7 when they launch my app? To be clear, I want this to be something on the user side. I know that I can install Java, but I want it so that it is as painless as possible to the end user.
upvote count: 2
type: UnansweredQuestion
score: 2
tagged with: java
type: Question
has title: How to Get OS X to Automatically Install Java 7 on App Launch Instead of Java 6
downvote count: 0
answer count: 1
has answer: http://stackoverflow.com/a/21612466
tagged with: macos

http://stackoverflow.com/q/21551373
has title: Error when setting multiple ActiveMQ brokers in same machine
has body: I fallowed the exact steps in [1] in order to setup multiple ActiveMQ brokers in the same server. When I start the second instance I always get the same error. One thing I noticed is configurations on both instances are same. for instance configurations like port s are same in both activemq.xml and jetty.xml. I even change the ports of the second instance so it won't get crashed with the first intance. But I get the same Exception. https://sbforge.org/display/BITMAG/Running+multiple+activemq+instances+on+the+same+server INFO | Apache ActiveMQ 5.9.0 (instance1, ID:udara-54224-1391513355578-0:1) is shutdown INFO | Closing org.apache.activemq.xbean.XBeanBrokerFactory$1@33e228bc: startup date [Tue Feb 04 06:29:14 EST 2014]; root of context hierarchy WARN | Exception thrown from LifecycleProcessor on context close java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.apache.activemq.xbean.XBeanBrokerFactory$1@33e228bc: startup date [Tue Feb 04 06:29:14 EST 2014]; root of context hierarchy at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:360) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1057) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010) at org.apache.activemq.hooks.SpringContextHook.run(SpringContextHook.java:30) at org.apache.activemq.broker.BrokerService.stop(BrokerService.java:782) at org.apache.activemq.xbean.XBeanBrokerService.stop(XBeanBrokerService.java:122) at org.apache.activemq.broker.BrokerService.start(BrokerService.java:574) at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:73) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.Delegat…
tagged with: broker
has answer: http://stackoverflow.com/a/21553360
score: 2
accepted answer: http://stackoverflow.com/a/21553360
type: AnsweredQuestion
tagged with: activemq-classic
tagged with: java
type: Question
upvote count: 2
downvote count: 0
answer count: 1
tagged with: linux
favorite count: 0

http://stackoverflow.com/a/21561074
has comment: http://stackoverflow.com/comment/32564149
has comment: http://stackoverflow.com/comment/32564501
score: 0
answers question: http://stackoverflow.com/q/21559984
has comment: http://stackoverflow.com/comment/32564353
type: Answer
has body: If db_date is the date in your table, arg_begins_on &amp; arg_ends_on are the date arguments that act like boundary dates passed to the query, then: SELECT * FROM sample_table WHERE (db_date &gt; :arg_ends_on ) OR (db_date &lt; :arg_begins_on);
has comment: http://stackoverflow.com/comment/32564449

http://stackoverflow.com/a/21604088
answers question: http://stackoverflow.com/q/21604009
has body: Integer literals in java can be in the form of decimal (eg. 32), hexadecimal (eg. 0x20) and octal (eg. 040). The differences being decimal: no prefix, hexadecimal: prefix 0x and octal: prefix 0. Thus, int mike = FF + 0x20 * AA + 0x200 * NN; is really just int mike = FF + 32 * AA + 512 * NN; Oh and the fact that FF is also on "hex form" doesn't matter at all, it's just a method parameter and might as well be called steven... :-) Cheers,
accepted answer of: http://stackoverflow.com/q/21604009
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/comment/32553976
score: 2
comment on: http://stackoverflow.com/q/21555569
type: QuestionComment
has text: Why shouldn't they? Surely it makes sense for these classes to implement `Serializable` rather than having to write all the logic manually everytime you want to serialize an object? It doesn't *force* you to serialize them, it just makes it easy to if you need to.
type: Comment

http://stackoverflow.com/comment/32540025
has text: In many to one relationship, the relationship is applied from child object to parent object right that's why I mapped like that. And While deleting single child object from the table it will through exception. The exception like you cant delete Parent Class object. Thank you
type: AnswerComment
comment on: http://stackoverflow.com/a/21547156
score: 0
type: Comment

http://stackoverflow.com/comment/32733681
type: QuestionComment
has text: Do the threads mutate the array? If so you need to think about locking and resource starvation. Otherwise JIT will cache local copies if it thinks it would help.
comment on: http://stackoverflow.com/q/21657454
score: 1
type: Comment

http://stackoverflow.com/comment/32510473
score: 0
type: AnswerComment
has text: You can open `Project Properties -> Deployment Assembly` and then add the Maven Libraries. Then try again to import it.
type: Comment
comment on: http://stackoverflow.com/a/21530438

http://stackoverflow.com/comment/32654004
type: QuestionComment
comment on: http://stackoverflow.com/q/21611950
has text: By the way, an `int` variable doesn't reference an object.
score: 1
type: Comment

http://stackoverflow.com/q/21661403
tagged with: resize
linked to: http://stackoverflow.com/q/12267311
possible better answer: http://stackoverflow.com/a/21664393
score: 0
has body: I'm trying with Swing layouts to leave a gap above controls that's calculated from the current size of the window. It basically works, except that the control only moves when the window is resized horizontally - if I resize vertically, it stays where it is - then resizing 1 pixel horizontally, it snaps into the correct place. Can anyone explain why the resizing gets ignored when I'm only resizing vertically? I've proved the at the componentResized () is still being called on vertical resizes, and that contentPane.getWidth () and contentPane.getHeight () still give the right values. So the size of the Dimension is being set correctly, just being ignored. Its like I need to put a call into contentPane.payAttentionToUpdatesSizesOfYourComponents (), but I can't find any method that does this. contentPane.invalidate () has no effect. Also noticed if I strip out the BorderLayout, and set the BoxLayout directly in the contentPane, then it works as I want. However while that's fine for this tiny example, the real window I have this problem on has some components in a JPanel set at NORTH with a gap above, some components in another JPanel set at SOUTH with a gap below, and a BorderLayout was the only way I could get these to position correctly so I can't strip it out. Any advice or suggestions would be welcome! import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import javax.swing.Box.Filler; import javax.swing.BoxLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.WindowConstants; public final class ResizeOnlyWorksHorizontally { public static final void main (final String [] args) { final JFrame frame = new JFrame (); frame.setDefaultCloseOperation (WindowConstants.EXIT_ON_CLOSE); final JPanel contentPane = new JPanel (); frame.setContentPane (contentPane); contentPane.setLayout (new BorderLayout ()); final JPanel top = new JPanel (); to…
tagged with: swing
has answer: http://stackoverflow.com/a/21663102
type: AnsweredQuestion
has title: Swing layout ignores horizontal resize
tagged with: java
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/21664393
accepted answer: http://stackoverflow.com/a/21663102

http://stackoverflow.com/a/21627985
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21627654
score: 0
answers question: http://stackoverflow.com/q/21627654
type: Answer
has body: In special, How can I choose "local" archetype from the first list? I installed my own archetype, but I can't find it in the first list. After applying "File-->New Project-->Maven-->Next" Check "Create from Archetype" and click "Add Archetype" button Fill in the archetype GAV coordinates and optionally the Repository if you had deployed your archetype to a Maven repository. Next time you will create a new maven project in IDEA, your own archetype will appear in the archetypes list
has comment: http://stackoverflow.com/comment/32681792
has comment: http://stackoverflow.com/comment/32681979
has comment: http://stackoverflow.com/comment/32682263

http://stackoverflow.com/comment/32607730
has text: @user3187463. Fixed. I had `i <= lines.size()` instead of `i < lines.size()` towards the end. My mistake
type: AnswerComment
comment on: http://stackoverflow.com/a/21581565
type: Comment
score: 0

http://stackoverflow.com/comment/32531412
type: AnswerComment
type: Comment
has text: Old habits die hard I suspect but, null to me means "Not worked on" so, no point in doing any other work or checks on it. It SHOULD be worked on but, if not: if (text != null) tells me don't worry about doing any thing else with it. also I tried .isEmpty() as well but, it required API level 9, this old code is level 8 :(
comment on: http://stackoverflow.com/a/21541878
score: 0

http://stackoverflow.com/a/21664518
downvote count: 0
answers question: http://stackoverflow.com/q/21664478
type: Answer
has comment: http://stackoverflow.com/comment/32748175
has body: First you should check if books itself isn't null, then simply check whether books[i] != null: if(books==null) throw new IllegalArgumentException(); for (int i = 0; i &lt; books.length; i++){ if(books[i] != null){ total += books[i].getPrice(); } }
accepted answer of: http://stackoverflow.com/q/21664478
upvote count: 12
has comment: http://stackoverflow.com/comment/86923642
score: 12
has comment: http://stackoverflow.com/comment/32748109
type: AcceptedAnswer

http://stackoverflow.com/q/21550198
has comment: http://stackoverflow.com/comment/32545532
has body: I have a Hibernate persist on an entity with primary key constructor, but it does not take effect in the database after something I don't know while I need it in some other methods Here is my code: Base_Document document = new Base_Document(workItem.getProcessInstanceId()); this.getEntityManager().persist(document); this.getEntityManager().flush(); this.getEntityManager().close(); and some where else I have : Object o = this.getEntityManager().find(Base_Document.class, workItem.getProcessInstanceId()); where o is null. Any help? my entity code : @Entity public class Base_Document implements Serializable { private static final long serialVersionUID = 1L; @Id private Long processInstanceId; private DocumentStatus status; @ManyToOne private Base_Roles creatorRole; @Temporal(javax.persistence.TemporalType.TIMESTAMP) private Date createDate; public Base_Document() {} public Base_Document(Long processInstanceId) { this.processInstanceId = processInstanceId; this.createDate = new Date(); this.status = DocumentStatus.DRAFT; try { String currentUser = PublicUtils.getHttpServletRequest().getUserPrincipal().getName(); this.setCreatorRole(PublicUtils.getEntityManager().find(Base_Roles.class, currentUser)); } catch (PolicyContextException ex) { Logger.getLogger(Base_Document.class.getName()).log(Level.SEVERE, null, ex); } } public Long getId() { return processInstanceId; } public void setId(Long id) { this.processInstanceId = id; } public Long getProcessInstanceId() { return processInstanceId; } public void setProcessInstanceId(Long processInstanceId) { this.processInstanceId = processInstanceId; } public DocumentStatus getStatus() { return status; } public void setStatus(DocumentStatus status) { this.status = status; } public Base_Roles getCreatorRole() { return creatorRole; } public void setCreatorRole(Base_Roles creatorRole) { this.creatorRole = creatorRole; } public Date getCreateDate() { return createDate; } public void setCreateDate(Date createDate) { this.createDate = cre…
tagged with: persist
score: 0
has comment: http://stackoverflow.com/comment/32582605
answer count: 1
has title: EntityManager find nothing right after persist
has comment: http://stackoverflow.com/comment/32546159
has answer: http://stackoverflow.com/a/21557192
type: AnsweredQuestion
tagged with: transactions
tagged with: java
tagged with: hibernate
has comment: http://stackoverflow.com/comment/32544457
accepted answer: http://stackoverflow.com/a/21557192
type: Question

http://stackoverflow.com/q/21589184
tagged with: raspberry-pi
has title: Pin 21 / 27 does not work with Pi4j
has answer: http://stackoverflow.com/a/21610571
answer count: 1
accepted answer: http://stackoverflow.com/a/21610571
has comment: http://stackoverflow.com/comment/32618562
tagged with: gpio
has comment: http://stackoverflow.com/comment/32640840
type: AnsweredQuestion
tagged with: java
has body: I have a Raspberry Pi rev. 2 (512mb ram version). I have some LEDs that I am controlling over Pi4J. Every LED works except the ones that i attach/connect to pin 21/27. I have changed the LEDs to see if one is broken but it was not broken. I did some research on google and found this. Unfortunately I could not find a way to change Pin21 to 27 because Pi4j uses another numbering scheme. (For numbering see here) I couldn't find an error in my code but it looks like this: package gpio; import com.pi4j.io.gpio.GpioController; import com.pi4j.io.gpio.GpioFactory; import com.pi4j.io.gpio.GpioPinDigitalOutput; import com.pi4j.io.gpio.RaspiPin; public class GPIOController { final long second = 1000L; final GpioController gpio = GpioFactory.getInstance(); final GpioPinDigitalOutput red_1 = gpio .provisionDigitalOutputPin(RaspiPin.GPIO_03); final GpioPinDigitalOutput red_2 = gpio .provisionDigitalOutputPin(RaspiPin.GPIO_02); final GpioPinDigitalOutput yellow_1 = gpio .provisionDigitalOutputPin(RaspiPin.GPIO_00); final GpioPinDigitalOutput yellow_2 = gpio .provisionDigitalOutputPin(RaspiPin.GPIO_07); final GpioPinDigitalOutput green_1 = gpio .provisionDigitalOutputPin(RaspiPin.GPIO_06); final GpioPinDigitalOutput green_2 = gpio .provisionDigitalOutputPin(RaspiPin.GPIO_05); final GpioPinDigitalOutput green_3 = gpio .provisionDigitalOutputPin(RaspiPin.GPIO_04); final GpioPinDigitalOutput green_4 = gpio .provisionDigitalOutputPin(RaspiPin.GPIO_01); public GPIOController() { gpio.shutdown(); } // level 1 = red_1, level 8 = green_4 public void pulse(int level) { allLow(); switch(level) { case 1: red_1.pulse(second); break; case 2: red_2.pulse(second); break; case 3: yellow_1.pulse(second); break; case 4: yellow_2.pulse(second); break; case 5: green_1.pulse(second); break; case 6: green_2.pulse(second); break; case 7: green_3.pulse(second); break; case 8: green_4.pulse(second); break; } } public void high(int level) { allLow(); switch(level) { case 1: red_1.high(); break; case 2: red…
type: Question
score: 0

http://stackoverflow.com/a/21643018
downvote count: 0
score: 1
has body: Got it by myself String url = "http://www.google.com/search?q="+URLEncoder.encode(keywords); Document response = Jsoup.connect(url) .userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6") .referrer("http://www.google.com").get(); Elements records = response.select("body #ires li.g"); for (int i = 0; i &lt; records.size()-1; i++) { System.out.println(records.get(i)); }
upvote count: 1
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/21629597
answers question: http://stackoverflow.com/q/21629597

http://stackoverflow.com/a/21617430
answers question: http://stackoverflow.com/q/21617386
downvote count: 0
has comment: http://stackoverflow.com/comment/32664396
has body: int number; You name the variable number here, but later you call it value. You'll want to pick one or the other. value = input("'Please Enter a Number between 1 and 10 (1-10)'"); You should look up how to display a prompt and ask for user input. You've got the right idea, but this input() function you're trying to call doesn't exist. As a human being I understand what you want, but the computer has no idea. I recommend googling for "input number in java" or similar. You should be able to find some helpful links (for example, this Stack Overflow question). while ( value &lt; 1 || value &gt; 10) This is good loop logic. So what happens while the value is out of range? What do you want to happen inside the loop? You've got the start of the loop but no loop body. Presumably you'll want to give the user another chance to enter the number. while (value &lt; 1 || value &gt; 10) { // loop body: ask the user to try again }
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/comment/32513184
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21530765
type: Comment
has text: Yes. There are very few legitimate uses of sleep().

http://stackoverflow.com/q/21661272
has answer: http://stackoverflow.com/a/21661279
linked to: http://stackoverflow.com/q/513832
has body: I am writing a program that takes a user input and depending on their answer gives them a different answer. How do I use a string that the user entered with an if - else statement? I have this so far: import java.io.*; import static java.lang.System.*; import java.util.Scanner; class t1_lesson07_template{ public static void main (String str[]) throws IOException { Scanner scan = new Scanner(System.in); System.out.print("Hello, welcome to the companion planting guide. "); System.out.print("Lets get started! To begin, just input the desired plant in the box to learn what plants to grow with it!"); String plant = scan.nextLine(); if (plant == "Asparagus") { System.out.print("Tomatoes, parsley, and basil."); } } } I am wondering about the syntax for the if statement in this case.
favorite count: 0
duplicate of: http://stackoverflow.com/q/513832
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32740262
tagged with: statements
has answer: http://stackoverflow.com/a/21661295
answer count: 4
has title: Strings in If - Else Statements in Java
tagged with: syntax
tagged with: java
has answer: http://stackoverflow.com/a/21661301
downvote count: 1
type: Question
tagged with: if-statement
upvote count: 0
score: -1
has comment: http://stackoverflow.com/comment/32740278
has answer: http://stackoverflow.com/a/21661314

http://stackoverflow.com/a/21667769
score: 5
type: AcceptedAnswer
downvote count: 0
type: Answer
has body: Each @Entity must have an @Id field. You probably don't have it in your new class.
accepted answer of: http://stackoverflow.com/q/21667715
upvote count: 5
has comment: http://stackoverflow.com/comment/32752250
has comment: http://stackoverflow.com/comment/32760287
answers question: http://stackoverflow.com/q/21667715

http://stackoverflow.com/comment/32595429
type: Comment
has text: I am unable to reproduce this on either Ubuntu 12 or Mac OS X 10.9 using JDK 6. What platform and version are you using?
type: AnswerComment
comment on: http://stackoverflow.com/a/21574810
score: 1

http://stackoverflow.com/q/21590786
tagged with: supportmapfragment
tagged with: android
accepted answer: http://stackoverflow.com/a/21591051
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32618045
type: Question
has title: Extending SupportMapFragment - how to instantiate new fragment?
tagged with: android-fragments
tagged with: java
has answer: http://stackoverflow.com/a/21591051
score: 0
tagged with: google-maps-api-2
answer count: 1
linked to: http://stackoverflow.com/q/9245408
has body: In the documentation for MapFragment and SupportMapFragment they create a new fragment by calling newInstance() instead of using new SupportMapFragment(). My app project extends SupportMapFragment, and I tried to call MyMapFragment.newInstance() on my fragment class, resulting in the map showing up as expected but none of my overridden methods such as onCreateView() and onActivityCreated() were being called. Took me a while before I tried instantiating my fragment by using new MyMapFragment() instead - and voíla, my overridden methods started getting called! I didn't override newInstance() in my class, and in hindsight it's obvious that newInstance() returns an instance of SupportMapFragment, not an instance of my extended class (duh!). But my question is - why is there a newInstance() method and why does the documentation use it, when it seems to work just as well using new SupportMapFragment()? What's the difference of using one or the other? I haven't been able to find the source code for SupportMapFragment, so...

http://stackoverflow.com/comment/32717909
has text: Thanks for that, JLabels sound better. But I hope you won't mind me asking this on here also: do you think it'll be possible/a nice approach to store jlabels in an array and then lay them out in a panel? so far, it's the way i prefer and could think of to control the jlabels and use `setIcon` to "fill them up" with the tokens upon an event from the user. Hope you won't mind sharing your opinion on this
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/21648174

http://stackoverflow.com/comment/32860863
type: AnswerComment
type: Comment
has text: Just did some tests, and it seems like tasks added later to a very busy system (with both fixed delay and rate) seem to get left behind. They will be executed, but not regularly. First task added was executed 692 times, while the 20th task added was only executed 76 times.
comment on: http://stackoverflow.com/a/21677368
score: 0

http://stackoverflow.com/comment/32550219
has text: How should i close it in my script?
comment on: http://stackoverflow.com/a/21553239
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/32647758
score: 0
comment on: http://stackoverflow.com/q/21608500
type: Comment
type: QuestionComment
has text: Can you be more precise? If I have 15° 30' 45" then you want ... what, 15° 30.75'? Or do you want 15.5125°?

http://stackoverflow.com/a/21544097
has body: Try out to get the string as below : First change your onItemClickListener as below: You need to assign value to your itm variable and then call the selectItem() method so that your itm variable is not null. getListView().setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int pos, long arg3) { itm = getListView().getItemAtPosition(pos).toString(); selectItem(pos); } }); Get the String in your another activity as below: String topic1 =getIntent().getStringExtra("itemname");
has comment: http://stackoverflow.com/comment/32534231
has comment: http://stackoverflow.com/comment/32534280
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32534542
downvote count: 0
has comment: http://stackoverflow.com/comment/32534771
answers question: http://stackoverflow.com/q/21543066
type: Answer
has comment: http://stackoverflow.com/comment/32534371
accepted answer of: http://stackoverflow.com/q/21543066
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/32534247
has comment: http://stackoverflow.com/comment/32534346

http://stackoverflow.com/q/21588470
has answer: http://stackoverflow.com/a/21588510
type: Question
has body: How to get all 64 bits of a long as a String in Java? So I want to do something like this - long value = 10; String bits = getBits(value); System.out.println(bits); I suppose the output would be 0000...1010 (64 bits) And no, this is not homework! :)
answer count: 2
has title: Get bits from Java long as String
has comment: http://stackoverflow.com/comment/32613934
duplicate of: http://stackoverflow.com/q/5263187
score: 0
tagged with: java
tagged with: bit-manipulation
upvote count: 1
downvote count: 1
accepted answer: http://stackoverflow.com/a/21588510
tagged with: long-integer
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21588522
favorite count: 0
has answer: http://stackoverflow.com/a/21588522
linked to: http://stackoverflow.com/q/5263187

http://stackoverflow.com/a/21661076
answers question: http://stackoverflow.com/q/21661046
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 2
upvote count: 2
has body: The return type is clearly an integer array (as specified in the method definition), but I have not assigned the returned data to any integer array, but the program still works. Yes, because it's simply not an error to ignore the return value of a method. Not as far as the compiler is concerned. It may well represent a bug, but it's a perfectly valid use of the language. For example: Console.ReadLine(); // User input ignored! "text".Substring(10); // Result ignored! Sometimes I wish it could be used as warning - and indeed Resharper will give warnings when it can detect that "pure" methods (those without any side-effects) are called without using the return value. In particular, call which cause problems in real life: Methods on string such as Replace and Substring, where users assume that calling the method alters the existing string Stream.Read, where users assume that all the data they've requested has been read, when actually they should use the return value to see how many bytes have actually been read There are times where it's entirely appropriate to ignore the return value for a method, even when it normally isn't for that method. For example: TValue GetValueOrDefault&lt;TKey, TValue&gt;(Dictionary&lt;TKey, TValue&gt; dictionary, TKey key) { TValue value; dictionary.TryGetValue(key, out value); return value; } Normally when you call TryGetValue you want to know whether the key was found or not - but in this case value will be set to default(TValue) even if the key wasn't found, so we're going to return the same thing anyway.
accepted answer of: http://stackoverflow.com/q/21661046

http://stackoverflow.com/q/21672969
linked to: http://stackoverflow.com/q/2793150
has answer: http://stackoverflow.com/a/21673412
has comment: http://stackoverflow.com/comment/32760648
score: 0
has comment: http://stackoverflow.com/comment/32761581
has comment: http://stackoverflow.com/comment/32760609
answer count: 1
has title: Is there any API for raw sockets in Java also example would be helpful
type: UnansweredQuestion
tagged with: sockets
has comment: http://stackoverflow.com/comment/32761458
tagged with: java
has body: I want to create a simple http asyn client interface that sends the get request and recieve the response from the server. Though I want to control the number of request sends per second also the response is a asyn handling. The key is I want to specify number of request per second so as to load the server. I have searched that Ning AsyncHttpClient interface but it does allow to set the number of requests per second. So I think to use RAW sockets in Java and create interface like it. Can you please help me in suggesting what framework provide these functionality or else what API I use to achieve this functionlaity. Thanks, Manish
type: Question

http://stackoverflow.com/comment/32560902
score: 0
type: Comment
has text: Show us the code around line 405.
type: QuestionComment
comment on: http://stackoverflow.com/q/21558975

http://stackoverflow.com/q/21579944
tagged with: java
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/32598061
has comment: http://stackoverflow.com/comment/32597948
has answer: http://stackoverflow.com/a/21598147
score: 0
has comment: http://stackoverflow.com/comment/32598029
has title: an irrelevant error with a (if) condition: syntax error on token invalid character, delete this token
has answer: http://stackoverflow.com/a/21580087
has comment: http://stackoverflow.com/comment/32598080
has comment: http://stackoverflow.com/comment/32598078
type: UnansweredQuestion
has body: i was working on a Java code that i faced this error: syntax error on token invalid character delete this token i don't have any idea how to solve this problem. the original code: if ((base[i - 1][j] != 0) &amp;&amp;‌ (base[i - 1][j] != c))//the error is on this line { for (int p = 1; p &lt; i; p++) { if (base[i - p - 1][j] != 0) { break; } if (base[i - p - 1][j] != c) { break; location[0] = i - p - 1; location[1] = j; } if (location != null) { int[] temploc1 = new int[2]; int[] temploc2 = new int[2]; temploc1[0] = i; temploc1[1] = j; temploc2[0] = i - p - 1; temploc2[1] = j; paint(temploc1, temploc2); } } }
has comment: http://stackoverflow.com/comment/32598005
has comment: http://stackoverflow.com/comment/32597859

eclipse
tags question: http://stackoverflow.com/q/21575069
tags question: http://stackoverflow.com/q/21590991
tag name: eclipse
tags question: http://stackoverflow.com/q/21546924
tags question: http://stackoverflow.com/q/21672981
tags question: http://stackoverflow.com/q/21674284
tags question: http://stackoverflow.com/q/21528235
tags question: http://stackoverflow.com/q/21564394
tags question: http://stackoverflow.com/q/21538345
tags question: http://stackoverflow.com/q/21633677
tags question: http://stackoverflow.com/q/21639465
tags question: http://stackoverflow.com/q/21552106
tags question: http://stackoverflow.com/q/21527232
tags question: http://stackoverflow.com/q/21565606
tags question: http://stackoverflow.com/q/21634410
tags question: http://stackoverflow.com/q/21590156
tags question: http://stackoverflow.com/q/21565624
tags question: http://stackoverflow.com/q/21570142
tags question: http://stackoverflow.com/q/21611662
tags question: http://stackoverflow.com/q/21569655
tags question: http://stackoverflow.com/q/21519780
tags question: http://stackoverflow.com/q/21669353
tags question: http://stackoverflow.com/q/21662536
tags question: http://stackoverflow.com/q/21639096
tags question: http://stackoverflow.com/q/21582108
tags question: http://stackoverflow.com/q/21540699
tags question: http://stackoverflow.com/q/21630389
tags question: http://stackoverflow.com/q/21571886
tags question: http://stackoverflow.com/q/21612047
tags question: http://stackoverflow.com/q/21554461
tags question: http://stackoverflow.com/q/21515184
tags question: http://stackoverflow.com/q/21569325
tags question: http://stackoverflow.com/q/21599096
tags question: http://stackoverflow.com/q/21632111
tags question: http://stackoverflow.com/q/21676957
tags question: http://stackoverflow.com/q/21617661
tags question: http://stackoverflow.com/q/21666381
tags question: http://stackoverflow.com/q/21599776
tags question: http://stackoverflow.com/q/21598373
tags question: http://stackoverflow.com/q/21619305
tags question: http://stackoverflow.com/q/21648644
tags question: http://stackoverflow.com/q/21571582
tags question: http://stackoverflow.com/q/21616544
tags question: http://stackoverflow.com/q/21591869
tags question: http://stackoverflow.com/q/21660136
tags question: http://stackoverflow.com/q/21620937
tags question: http://stackoverflow.com/q/21659189
tags question: http://stackoverflow.com/q/21559670
tags question: http://stackoverflow.com/q/21575029
tags question: http://stackoverflow.com/q/21576404
tags question: http://stackoverflow.com/q/21587804
tags question: http://stackoverflow.com/q/21561920
tags question: http://stackoverflow.com/q/21603932
tags question: http://stackoverflow.com/q/21632136
tags question: http://stackoverflow.com/q/21677639
tags question: http://stackoverflow.com/q/21562408
tags question: http://stackoverflow.com/q/21543022
tags question: http://stackoverflow.com/q/21527774
tags question: http://stackoverflow.com/q/21523149
tags question: http://stackoverflow.com/q/21652190
tags question: http://stackoverflow.com/q/21616339
tags question: http://stackoverflow.com/q/21630849
tags question: http://stackoverflow.com/q/21581247
tags question: http://stackoverflow.com/q/21627851
tags question: http://stackoverflow.com/q/21670867
tags question: http://stackoverflow.com/q/21528147
tags question: http://stackoverflow.com/q/21568532
tags question: http://stackoverflow.com/q/21567388
tags question: http://stackoverflow.com/q/21556114
tags question: http://stackoverflow.com/q/21541820
tags question: http://stackoverflow.com/q/21576146
tags question: http://stackoverflow.com/q/21631874
tags question: http://stackoverflow.com/q/21537324
tags question: http://stackoverflow.com/q/21633745
tags question: http://stackoverflow.com/q/21525948
tags question: http://stackoverflow.com/q/21627773
tags question: http://stackoverflow.com/q/21546509
tags question: http://stackoverflow.com/q/21598788
tags question: http://stackoverflow.com/q/21634490
tags question: http://stackoverflow.com/q/21575508

http://stackoverflow.com/comment/32564587
score: 0
type: Comment
has text: How do I make these automated tests?
comment on: http://stackoverflow.com/a/21535488
type: AnswerComment

rtmp
tag name: rtmp
tags question: http://stackoverflow.com/q/21551251
type: Tag

opennlp
type: Tag
tags question: http://stackoverflow.com/q/21589436
tags question: http://stackoverflow.com/q/21520818
tags question: http://stackoverflow.com/q/21617540
tag name: opennlp

http://stackoverflow.com/a/21585773
has comment: http://stackoverflow.com/comment/32609292
has comment: http://stackoverflow.com/comment/32609368
type: Answer
answers question: http://stackoverflow.com/q/21585608
has body: Consider using @SecondaryTable it should work for legacy schemas, using this annotation you can have fields in one entity, and just define which ones will form part of other table, but you only have 2 entities. Check this tutorial Idea is split fields from one entity in different tables without need the creation of other entities, just define which fields are in which table. @SecondaryTables{@SecondaryTable(name="XX")} and to move fields between tables use @Column(table="XX") In your config try something like this. @Entity @SecondaryTables{@SecondaryTable(name="TableOne"), @SecondaryTable(name="TableTwo")} table MainClass PK id @Column(table="TableOne") FK main_class_id @Column(table="TableOne") FK table_two_id @Column(table="TableTwo") PK id @Column(table="TableTwo") FK table_one_id @Column(table="TableTwo") FK other_entity_id For ID in middle tables consider remove @Id and set it automatically, it should work !!
has comment: http://stackoverflow.com/comment/32678988
score: 0

http://stackoverflow.com/comment/80277063
score: 0
comment on: http://stackoverflow.com/a/21553322
type: Comment
type: AnswerComment
has text: I would expect Spring injects a dynamically generated proxy class instead - such a class has application scope, but when accessed, it delegates to a session scope instance, or throws an exception it there is no request bound to the currently running thread

http://stackoverflow.com/q/21529030
score: 4
answer count: 2
has answer: http://stackoverflow.com/a/21529481
favorite count: 0
possible better answer: http://stackoverflow.com/a/21529481
has title: TCP Client Socket. Connect and wait for input stream
tagged with: sockets
tagged with: android
upvote count: 4
has answer: http://stackoverflow.com/a/21529624
accepted answer: http://stackoverflow.com/a/21529624
type: AnsweredQuestion
has body: I have a wifi sd card which sends me TCP packages with information about new images on the memory after I shoot a photo with the camera. On the terminal I can read the inputstream with this netcat command. netcat connects to ip 192.168.11.254 and listen on port 5566. the second line is the image path which I receive. $ nc 192.168.11.254 5566 &gt;/mnt/sd/DCIM/109_0302/IMGP0101.JPG On my app I have a Java client socket which is connected to the same ip and port. But I don't receive the inputstream like in netcat, nothing happens. void startListenForTCP (){ Thread TCPListenerThread = new Thread(new Runnable() { @Override public void run() { Boolean run = true; String serverMessage = null; InetAddress serverAddr = null; try { serverAddr = InetAddress.getByName("192.168.11.254"); Socket clientSocket = new Socket(serverAddr, 5566); try{ BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); while (run) { serverMessage = in.readLine(); mHandler.post(new DisplayToast(context, "TCP : " + serverMessage)); } } catch(UnknownHostException e) { mHandler.post(new DisplayToast(context, "UnknownHostException")); } catch(IOException e) { mHandler.post(new DisplayToast(context, "IOException")); } finally { clientSocket.close(); } } catch (IOException e) { e.printStackTrace(); } } }); TCPListenerThread.start(); }
downvote count: 0
tagged with: tcp
tagged with: java
type: Question

http://stackoverflow.com/comment/32658685
type: Comment
comment on: http://stackoverflow.com/a/21591610
type: AnswerComment
has text: No. `index` is the last element of the line in your input file (e.g. "2" in the line "e f g h 2").
score: 0

http://stackoverflow.com/comment/32697696
type: Comment
comment on: http://stackoverflow.com/a/21635784
has text: Hmm, well, I thought that was what I was doing to begin with but I guess not because that worked...thanks!
score: 0
type: AnswerComment

http://stackoverflow.com/q/21548411
tagged with: java
upvote count: 1
has answer: http://stackoverflow.com/a/21548740
has title: How to make a NEW image appear in JFrame?
type: Question
has body: I have this code: import java.lang.*; import javax.swing.*; import java.awt.event.*; import java.awt.*; import java.lang.*; import java.io.*; import java.util.*; import java.text.*; import java.*; public class LottoGUI extends JFrame implements ActionListener { Random rand = new Random(); int randomNum = rand.nextInt((4 - 1) + 1) + 1; String mine="",mine2=""; String help; JTextArea test = new JTextArea(0,0); JTextArea test2 = new JTextArea(0,0); JTextArea test4 = new JTextArea(0,0); JTextArea test3 = new JTextArea(0,0); JTextArea test5 = new JTextArea(10,30); JScrollPane test55 =new JScrollPane(test5); /* Random rand = new Random(); int randomNum = rand.nextInt((max - min) + 1) + min; JLabel MyImage = new JLabel(new ImageIcon("image"+randomNum+".png")); */ JLabel lab = new JLabel(mine); JLabel lab2 = new JLabel(mine2); JLabel lab3 = new JLabel("Type 1 for a new seat."); JTextField labf = new JTextField(10); JTextField lab2f = new JTextField(10); JTextField lab3f = new JTextField(10); JButton labb = new JButton("OK!"); JButton lab2b= new JButton("Clear!"); JButton lab3b= new JButton("Again!"); JLabel MyImage2 = new JLabel(new ImageIcon("smea"+randomNum+".gif")); JLabel MyImage = new JLabel(new ImageIcon("lottery.png")); int col1,col2,col3; public LottoGUI(String one, String two,String three) { Container C= getContentPane(); C.setLayout(new FlowLayout()); Font font = new Font("Impact", Font.ITALIC +Font.BOLD, 30); test.setFont(font); col1=ColorGen(); col2=ColorGen(); col3=ColorGen(); test.setForeground(new Color(col1,col2,col3)); test.setBackground(new Color(255-col1,255-col2,255-col3)); test.setText(one); test.setEditable(false); Font font2 = new Font("Verdana", Font.BOLD, 12); test2.setFont(font2); col1=ColorGen(); col2=ColorGen(); col3=ColorGen(); test2.setForeground(new Color(col1,col2,col3)); test2.setBackground(new Color(255-col1,255-col2,255-col3)); test2.setText(two); test2.setEditable(false); Font font3 = new Font("Sans", Font.BOLD, 12); test3.setFont(font3);…
tagged with: image
tagged with: imageicon
answer count: 3
has answer: http://stackoverflow.com/a/21549102
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/21549833
type: UnansweredQuestion
tagged with: swing
score: 1

http://stackoverflow.com/q/21608888
accepted answer: http://stackoverflow.com/a/21609088
upvote count: 5
has answer: http://stackoverflow.com/a/64300375
tagged with: groovy
has title: MongoDB unique index is not working
type: AnsweredQuestion
downvote count: 0
possible better answer: http://stackoverflow.com/a/64300375
favorite count: 0
type: Question
answer count: 2
score: 5
has answer: http://stackoverflow.com/a/21609088
tagged with: java
has body: I'm using Mongodb from Java. I create a collection and an index like this: collection = mongoClient.getDB(DB_NAME).getCollection(COLLECTION_NAME) collection.ensureIndex(new BasicDBObject(['customerReference': 1, 'unique': true])) when I check in the mongo shell i see: { "v" : 1, "key" : { "customerReference" : 1, "unique" : true }, "ns" : "diagnostics.diagnosticData", "name" : "customerReference_1_unique_" } but i can still insert duplicates: { "_id" : ObjectId("52f3ba8a7d841c01680e0bc5"), "customerReference" : 3, "data" : "original data", "created" : ISODate("2014-02-06T16:38:34.191Z") } { "_id" : ObjectId("52f3ba8a7d841c01680e0bc6"), "customerReference" : 3, "data" : "duplicate data", "created" : ISODate("2014-02-06T16:38:34.194Z") } why?
tagged with: mongodb

http://stackoverflow.com/q/21567374
tagged with: tomcat
favorite count: 0
tagged with: classloader
tagged with: maven
type: AnsweredQuestion
downvote count: 0
tagged with: java
tagged with: stream
has answer: http://stackoverflow.com/a/60248270
type: Question
score: 3
has title: Java class loader bug: Caused by: java.io.IOException: Stream closed
has answer: http://stackoverflow.com/a/21568989
accepted answer: http://stackoverflow.com/a/21568989
has body: I'm getting a strange bug regarding I believe class loader issues when I deploy my webapp to Tomcat. The bug doesn't appear when I run my webapp locally using Jetty. It seems like my input streams for my .yml resource files are being closed for some reason when they shouldn't be. This bug first appeared when I tried to convert my single module project into a multi module project. Before that, it was working fine on Tomcat using the exact same code: Caused by: org.yaml.snakeyaml.error.YAMLException: java.io.IOException: Stream closed at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:200) at org.yaml.snakeyaml.reader.StreamReader.&lt;init&gt;(StreamReader.java:60) at org.yaml.snakeyaml.Yaml.load(Yaml.java:412) at com.config.ConfigProvider.&lt;init&gt;(ConfigProvider.java:20) ... 49 more Caused by: java.io.IOException: Stream closed at java.io.PushbackInputStream.ensureOpen(PushbackInputStream.java:57) at java.io.PushbackInputStream.read(PushbackInputStream.java:149) at org.yaml.snakeyaml.reader.UnicodeReader.init(UnicodeReader.java:90) at org.yaml.snakeyaml.reader.UnicodeReader.read(UnicodeReader.java:122) at java.io.Reader.read(Reader.java:123) at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:184) ... 55 more Here's the line that causes the bug: String s = ConfigProvider.getConfig().getString("test"); Here's the ConfigProvider class. It basically scans for all resource files of regex ^.*\\.config\\.yml$, converts it into a Map&lt;String, Object&gt;, and combines all the obtained Map&lt;String, Object&gt; into a single Map&lt;String, Object&gt;: 1 public class ConfigProvider { 2 protected static final String CONFIG_PACKAGE = ConfigProvider.class.getPackage().getName(); 3 protected static final Pattern CONFIG_PATH_REGEX = Pattern.compile("^.*\\.config\\.yml$"); 4 5 private static final ConfigProvider INSTANCE = new ConfigProvider(); 6 private Map&lt;String, Object&gt; configMap; 7 8 protected ConfigProvider() { 9 configMap = new HashM…
upvote count: 3
answer count: 2
possible better answer: http://stackoverflow.com/a/60248270

http://stackoverflow.com/a/21537329
score: 1
answers question: http://stackoverflow.com/q/21535476
upvote count: 1
type: Answer
has body: In C# if you want to look at next element without advancing the enumerator. LinkedList will give more control while you are looping You can also use Queue but be careful with this collection because every call to dequeue removes item from list. this collection has peek method.
downvote count: 0

http://stackoverflow.com/q/21585932
has answer: http://stackoverflow.com/a/21585972
has answer: http://stackoverflow.com/a/21585985
answer count: 6
has answer: http://stackoverflow.com/a/21585974
has title: fibonacci works in python but fails in Java
has answer: http://stackoverflow.com/a/21586329
accepted answer: http://stackoverflow.com/a/21585974
possible better answer: http://stackoverflow.com/a/21589234
has answer: http://stackoverflow.com/a/21585991
has comment: http://stackoverflow.com/comment/32609558
upvote count: 21
favorite count: 0
tagged with: python
downvote count: 1
has body: I have this code for calculating fibonacci number in python. It works and gives the expected result. but when I translated the same to Java, it fails. Any idea of what is going wrong here? In python: def fib3(n): a,b=0,1 while n&gt;0: a,b=b,a+b n-=1 return a fib3(12) --&gt; 144 In Java: public static int fib2(int n){ int a = 0; int b =1; while(n-- &gt;0){ a=b; b=a+b; } return a; } fib2(12) --&gt; 2048
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21589234
has comment: http://stackoverflow.com/comment/32608970
tagged with: java
type: Question
score: 20
tagged with: fibonacci

http://stackoverflow.com/a/21660600
upvote count: 1
answers question: http://stackoverflow.com/q/21660448
score: 1
downvote count: 0
type: Answer
has body: I had a test , the GCD_UDPServer.java have a exception like Exception in thread "main" java.lang.NumberFormatException: For input string: "12" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:492) at java.lang.Integer.parseInt(Integer.java:527) at GCD_UDPServer.main(GCD_UDPServer.java:24) and simply change line 24 ar[i] = Integer.parseInt(Number); to ar[i] = Integer.parseInt(Number.trim()); and it works properly.

http://stackoverflow.com/comment/32732364
has text: yes, it has. I also added the contents of the manifest.
score: 0
comment on: http://stackoverflow.com/q/21650556
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/37868775
has text: I cant believe it, I had THE EXACT SAME PROBLEM, you saved my day. Gl state machine is so obscure^^
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21645636

storage
tag name: storage
tags question: http://stackoverflow.com/q/21618071
type: Tag
tags question: http://stackoverflow.com/q/21669503

http://stackoverflow.com/comment/32517654
type: QuestionComment
has text: Well, JFugues internal representation (called `MusicString`) does, like shown in the [examples](http://www.jfugue.org/examples.html). But i'm not sure about the MIDI file parser.
type: Comment
comment on: http://stackoverflow.com/q/21523067
score: 0

http://stackoverflow.com/comment/32648175
type: QuestionComment
has text: @Johnride Would that be the fastest way though? Can we get sub-linear?
score: 0
type: Comment
comment on: http://stackoverflow.com/q/21608646

http://stackoverflow.com/comment/32580854
type: Comment
has text: Both packages are under the same directory. In my system it is in E:/Projects. I use NetBeans IDE.
score: 0
comment on: http://stackoverflow.com/a/21569843
type: AnswerComment

http://stackoverflow.com/comment/32600799
has text: How can I style the custom scroll bars?
comment on: http://stackoverflow.com/a/21581263
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/21636017
tagged with: java
tagged with: android-actionmode
linked to: http://stackoverflow.com/q/14099299
type: Question
score: 0
tagged with: android-listview
has title: Refresh ListView from ActionMode.Callback.onDestroyActionMode()
answer count: 1
has body: This is a question that has been floating around on StackOverflow for a little while, and before you mark this question as a duplicate I am aware of this link. However, this question is vague, has no code, and doesn't seem to have been fully answered. So on to my question: I have a ListFragment (MainListFragment) that, onLongItemClick, opens up a Contextual Action Bar. One of the menu items within this Contextual Action Bar enables the deletion of the ListView item that was long-clicked. Within the class that implements ActionMode.Callback, I am able to delete the long-clicked item, but I need the ListView to refresh itself after this deletion so users don't have to switch Fragments to see the effects of the deletion. Here you can see my onLongItemClickListener within MainListFragment: this.getListView().setOnItemLongClickListener(new OnItemLongClickListener(){ @Override public boolean onItemLongClick(AdapterView&lt;?&gt; adapter, View view, int pos, long id) { // TODO Auto-generated method stub Log.d("My Debug Bitches", "made it to the listener"); MainListContextualMenu menu = new MainListContextualMenu(); //view.startActionMode(menu); ActionMode mode = getActivity().startActionMode(menu); Object[] tags = new Object[2]; tags[0] = view.getRootView().getContext(); tags[1] = pos; mode.setTag(tags); //view.setSelected(true); return true; } }); And here is my ActionMode.Callback-implementing class: public class MainListContextualMenu implements ActionMode.Callback{ @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { // TODO Auto-generated method stub switch(item.getItemId()){ case R.id.main_list_contextual_menu_delete: //MainActivity activity = (MainActivity) mode.getCustomView().getContext(); //activity.getLists().remove(mode.getTag()); Object[] tags = (Object[]) mode.getTag(); MainActivity activity = (MainActivity) tags[0]; int index = (Integer) tags[1]; //Log.d("My Debug Bitches","" +index); //Log.d("My Debug Bitches", "size before " + acti…
type: UnansweredQuestion
tagged with: android
has answer: http://stackoverflow.com/a/21671472
tagged with: android-fragments

http://stackoverflow.com/q/21520695
has comment: http://stackoverflow.com/comment/32493310
score: 0
has comment: http://stackoverflow.com/comment/32493083
answer count: 3
has comment: http://stackoverflow.com/comment/32493435
has answer: http://stackoverflow.com/a/21522079
has answer: http://stackoverflow.com/a/21521325
has comment: http://stackoverflow.com/comment/32492820
has comment: http://stackoverflow.com/comment/32492940
tagged with: actionevent
type: UnansweredQuestion
tagged with: swing
tagged with: checkbox
has answer: http://stackoverflow.com/a/42052182
tagged with: java
type: Question
has title: Limit the selection of CheckBoxes in Java
has body: I have multiple checkboxes in my program. I want the user to select only 3 checkboxes and when 3 of them are checked, others should be disabled. Additionally, when one is unchecked, then all others should be enabled.

http://stackoverflow.com/q/21561942
has comment: http://stackoverflow.com/comment/32565806
has answer: http://stackoverflow.com/a/21562017
tagged with: java
type: Question
score: 0
tagged with: nullpointerexception
has body: When I run my code in Debug from Android Studio my app work good, but when I create the APK and install it on device and start my app, the app get NullPointerException error and get killed( using Android Debug Monitor). Here is the code: public class MusicService extends IntentService { boolean INTERNET_CONNECTION = false; boolean COMMAND_DOWNALOAD_SDCARD = false; String TABLE_NAME = ""; String COMMAND_ARGUMENT = ""; // Here throw sometimes the error - Line 42 AudioManager audio; MediaPlayer mp = new MediaPlayer(); long TIME_ELAPSED = 0; long TIME_STARTED = 0; boolean ALIVE = true; long SLEEP_TIME = 5000; String SERVER_URL = "http://xxx.xxx"; public MusicService() { super("Service"); } @Override protected void onHandleIntent(Intent intent) { Log.d("SERVICE", "STARTED"); initialize(); initializeTimer(); while (ALIVE) { ... } } private void initialize() { // Get phone number set the table name TABLE_NAME = "t" + getPhoneNumber(); audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); // Wait for internet connection INTERNET_CONNECTION = waitInternetConnection(); Log.d("INITIALIZE", "COMPLETED"); } ... } I start my app when boot is completed. After some times of trying to run it I got error at line 42 and I changed the line from: AudioManager audio = null; to AudioManager audio; But still get the error but now don't show any more the line.
has title: AudioManager NullPointerException for Release version
answer count: 1
tagged with: service
tagged with: android-audiomanager
type: UnansweredQuestion
tagged with: android

http://stackoverflow.com/q/21608328
answer count: 1
has answer: http://stackoverflow.com/a/21608962
accepted answer: http://stackoverflow.com/a/21608962
has body: I have a Jtable in my gui in which I project some results ! I have also 3 JCheckBoxes that are used as filters ! The problem is that when I check a JCheckBox for first time the results are filtered correctly , but when I uncheck the JCheckBox the results remain the same as with the filter applied , which I don't want to ! JCheckBox Listener : cEntertainment.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent e){ int state = e.getStateChange(); if (state == ItemEvent.SELECTED) { man.setEnabled(true); woman.setEnabled(true); child.setEnabled(true); newFilter(cEntertainment.getText()); } else { man.setEnabled(false); man.setSelected(false); woman.setEnabled(false); woman.setSelected(false); child.setEnabled(false); child.setSelected(false); } } }); newFilter method : private void newFilter(String type){ RowFilter&lt;DefaultTableModel,Object&gt; rf = null; try{ rf = RowFilter.regexFilter(type); }catch(java.util.regex.PatternSyntaxException e){ return; } sorter.setRowFilter(rf); }
type: AnsweredQuestion
has title: Jtable false results after remove filtering
tagged with: java
has comment: http://stackoverflow.com/comment/32647721
tagged with: swing
has comment: http://stackoverflow.com/comment/32647679
type: Question
tagged with: jcheckbox
has comment: http://stackoverflow.com/comment/32647931
has comment: http://stackoverflow.com/comment/32647572
tagged with: jtable
score: 0

http://stackoverflow.com/comment/86864627
type: Comment
has text: Use this to set an initial value of 3 `(def local (proxy [ThreadLocal] [] (initialValue [] 3)))`
score: 2
comment on: http://stackoverflow.com/a/21608858
type: AnswerComment

http://stackoverflow.com/comment/118741812
score: 0
has text: how about concurrent scenerios?
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21661277

http://stackoverflow.com/q/21517967
has title: Error java.lang.NumberFormatException: For input string: ""
tagged with: string
favorite count: 0
has answer: http://stackoverflow.com/a/21518124
tagged with: exception
type: UnansweredQuestion
tagged with: integer
downvote count: 0
has answer: http://stackoverflow.com/a/21517997
tagged with: java
has body: I'm trying to read this file C101 VEHICLE NUMBER CAPACITY 25 200 CUSTOMER CUST NO. XCOORD. YCOORD. DEMAND READY TIME DUE DATE SERVICE TIME 0 40 50 0 0 1236 0 1 45 68 10 912 967 90 2 45 70 30 825 870 90 3 42 66 10 65 146 90 4 42 68 10 727 782 90 5 42 65 10 15 67 90 6 40 69 20 621 702 90 7 40 66 20 170 225 90 8 38 68 20 255 324 90 But when I read the file, the program throws me this exception: Exception in thread "main" java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:504) at java.lang.Integer.parseInt(Integer.java:527) at VRP.main(VRP.java:43) Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) I cheked my code and debugged, but I can't find the problem. I used an array to save all the spaces between the columns (I only read the first four columns) and then an ArrayList but it doesn't worked. public static void main(String[] args) throws Exception { File f = new File("C101.txt"); FileReader fr = new FileReader(f); BufferedReader reader = new BufferedReader(fr); String nada = reader.readLine(); //C101 nada = reader.readLine(); //espacio en blanco nada = reader.readLine(); //vehicle=25 nada = reader.readLine(); //number, capacity nada = reader.readLine(); //25, 200 nada = reader.readLine(); //espacio en blanco nada = reader.readLine(); //customer nada = reader.readLine(); //encabezados nada = reader.readLine(); //espacio en blanco String[] espacios; int capacity = 200; int custno, xcoord, ycoord, demand; ArrayList&lt;String&gt; guardar = new ArrayList&lt;String&gt;(); while (reader.ready()) { espacios = reader.readLine().trim().split(" "); for (int i = 0; i &lt; espacios.length; i++) { guardar.add(espacios[i]); } custno = Integer.parseInt(espacios[0]); xcoord = Integer.parseInt(espacios[1]); ycoord = Integer.parseInt(espacios[2]); demand = Integer.parseInt(espacios[3]); } } Sorry for the inconvenient and thank you for your time.
type: Question
score: 3
upvote count: 3
tagged with: numberformatexception
answer count: 2

http://stackoverflow.com/comment/32670675
type: Comment
type: QuestionComment
has text: I can't use nextInt function because it has whitespace in it still.
score: 0
comment on: http://stackoverflow.com/q/21621288

http://stackoverflow.com/comment/32584337
has text: That sounds possible, I had no idea Hibernate used ZipFileInputStreams for that. Anyway it just seems that it's accumulating too many of these Finalizer instances, seems to me it might be having some trouble finalizing objects. Question is why? There does not seem to be any info on the net about this.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21567424

http://stackoverflow.com/a/21562595
answers question: http://stackoverflow.com/q/21562525
upvote count: 1
has body: UIDs in this context can also be used to distinguish between two objects being written to disk. Source: http://www.mkyong.com/java-best-practices/understand-the-serialversionuid/ As others have said, the UID is optional and shouldn't impact your program.
type: Answer
downvote count: 0
score: 1

gson
tags question: http://stackoverflow.com/q/21571367
tags question: http://stackoverflow.com/q/21636163
tags question: http://stackoverflow.com/q/21553285
tags question: http://stackoverflow.com/q/21546780
tags question: http://stackoverflow.com/q/21558334
tags question: http://stackoverflow.com/q/21520184
tags question: http://stackoverflow.com/q/21556332
tags question: http://stackoverflow.com/q/21591148
tags question: http://stackoverflow.com/q/21547731
tags question: http://stackoverflow.com/q/21665546
tags question: http://stackoverflow.com/q/21632560
tags question: http://stackoverflow.com/q/21609406
tag name: gson
tags question: http://stackoverflow.com/q/21614119
tags question: http://stackoverflow.com/q/21599614
tags question: http://stackoverflow.com/q/21556849
tags question: http://stackoverflow.com/q/21536987
tags question: http://stackoverflow.com/q/21641022
tags question: http://stackoverflow.com/q/21608038
tags question: http://stackoverflow.com/q/21528963
tags question: http://stackoverflow.com/q/21663120
tags question: http://stackoverflow.com/q/21646047
type: Tag
tags question: http://stackoverflow.com/q/21547498
tags question: http://stackoverflow.com/q/21577848

http://stackoverflow.com/a/21586105
downvote count: 0
score: 1
upvote count: 1
has body: A superclass's method shouldn't be relying on information such as which subclass is calling it. If you are going to do something based on which subclass called it, then that logic should be in the subclass, not in the superclass. Override the method in the subclass, calling the superclass method explicitly, then add your own subclass-specific logic. Superclass: public void aMethod() { // do superclass logic here. } Subclass: @Override public void aMethod() { super.aMethod(); // Subclass-specific logic goes in the overriding method. }
answers question: http://stackoverflow.com/q/21586004
type: Answer

http://stackoverflow.com/a/21525009
has comment: http://stackoverflow.com/comment/32501514
has comment: http://stackoverflow.com/comment/32501313
has comment: http://stackoverflow.com/comment/32501476
has comment: http://stackoverflow.com/comment/32501404
type: AcceptedAnswer
downvote count: 0
has body: If you want to add rows dynamically, you want to make use of the DefaultTableModel. By default on NetBeans, the TableModel given to JTables are DefaultTableModel. You can its methods and API here. What you want to do is use the methos addRow(...), which will update your table for you every time you add a row. You can use the graphical design view to set the headers. Highlight/select the table from design view. Go to the properties window on the right. Click the ... on the right of the model property In the Table Setting tab set the rows to 0 and the number of columns you want. You can click on each column to give it a title header. When you want to add rows dynamically, say after entering text in a few fields you can do something like this private void jButton1ActionPerformed(java.awt.event.ActionEvent e) { DefaultTableModel model = (DefaultTableModel)jTable2.getModel(); String firstName = jTextField1.getText(); String mi = jTextField2.getText(); String lastName = jTextField3.getText(); String[] row = {firstName, mi, lastName}; model.addRow(row); }
has comment: http://stackoverflow.com/comment/32501386
has comment: http://stackoverflow.com/comment/32501170
has comment: http://stackoverflow.com/comment/32501676
type: Answer
has comment: http://stackoverflow.com/comment/32501100
has comment: http://stackoverflow.com/comment/32501084
answers question: http://stackoverflow.com/q/21524447
has comment: http://stackoverflow.com/comment/32501640
has comment: http://stackoverflow.com/comment/32501421
accepted answer of: http://stackoverflow.com/q/21524447
upvote count: 1
has comment: http://stackoverflow.com/comment/32501616
has comment: http://stackoverflow.com/comment/32501441
has comment: http://stackoverflow.com/comment/32501033
has comment: http://stackoverflow.com/comment/32501206
has comment: http://stackoverflow.com/comment/32501282
score: 1

http://stackoverflow.com/q/21594840
tagged with: java
possible better answer: http://stackoverflow.com/a/21594867
duplicate of: http://stackoverflow.com/q/4931892
type: Question
has answer: http://stackoverflow.com/a/21594867
linked to: http://stackoverflow.com/q/4931892
has title: Why do I need to add an 'f' to value so my code outputs the right value?
has answer: http://stackoverflow.com/a/21594892
accepted answer: http://stackoverflow.com/a/21594892
score: 0
answer count: 3
has body: The following is my code that works :: public class AvgSpeed{ public static void main(String[] args){ double kph, km, hours, seconds, minutes, time; km = (1.6 * 24); hours = 1; minutes = 2/3f; seconds = 35/3600f; time = hours + minutes + seconds; kph = km/time; System.out.println(kph); } } If I remove the f's for minutes and seconds, it keeps printing out 38.4, which is not right. It should be some number close to 22.906 I don't even know the reason why I need to add the f, I did it on a whim. I thought declaring the two variables as a double was enough?
upvote count: 1
downvote count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/21595051
tagged with: double
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32624827

http://stackoverflow.com/a/21608665
has comment: http://stackoverflow.com/comment/32648320
downvote count: 0
has comment: http://stackoverflow.com/comment/32648628
accepted answer of: http://stackoverflow.com/q/21608570
answers question: http://stackoverflow.com/q/21608570
has comment: http://stackoverflow.com/comment/32648167
upvote count: 3
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32648511
has body: Are you trying to avoid using -clean altogether? If not, you can always add the "-clean" value at the first line of your eclipse.ini file located in your Eclipse install directory.
type: Answer
has comment: http://stackoverflow.com/comment/32648332
score: 3

http://stackoverflow.com/q/21622462
has title: Groovy Error on eclipse
type: Question
has body: for the above code it appears error on "if(recJsonObj instanceof JSONObject){" line i'm totally new to groovy.code as bellows..what may be the error???i am really frustrating about this language.help me.. import org.json.*; class Convert { def JSONDifference(JSONObject recJsonObj, JSONObject expJsonObj){ //File logFile = new File("C:\\TestCases\\my1.txt") def pass = true def recArrStrElements = recJsonObj.getNames(recJsonObj) def expArrStrElements = expJsonObj.getNames(expJsonObj) def found = false def foundMacthForCurrentElement = false for (int x = 0; x &lt; recArrStrElements.size(); x++) { def recCurrVal = recJsonObj.get(recArrStrElements[x].toString()) foundMacthForCurrentElement = false for (int y = 0; y &lt; expArrStrElements.size(); y++) { def expCurrVal = expJsonObj.get(expArrStrElements[y].toString()) if(recArrStrElements[x] == expArrStrElements[y]){ if(recCurrVal instanceof JSONArray){ recCurrValJsonArray = (JSONArray)recCurrVal expCurrValJsonArray = (JSONArray)expCurrVal for(int i = 0; i&lt;recCurrValJsonArray.length(); i++){ recNestedJsonObj = recCurrValJsonArray.get(i) //for(int j = 0; j&lt;expCurrValJsonArray.length(); j++){ //if(foundMacthForCurrentElement){break} //else{ expNestedJsonObj = expCurrValJsonArray.get(i) if(recNestedJsonObj instanceof JSONObject){ foundMatch = JSONDifference(recNestedJsonObj, expNestedJsonObj) } else{ } // if(foundMatch){ // foundMacthForCurrentElement = true // } //} //} } found=true } else if(recCurrVal instanceof JSONObject){ recCurrValJSONObject = (JSONObject)recCurrVal expCurrValJSONObject = (JSONObject)expCurrVal JSONDifference(recCurrValJSONObject, expCurrValJSONObject) found=true } else{ if(recCurrVal == expCurrVal){ //log.info "Element matched " + recCurrVal + ":" + recArrStrElements[x] //logFile.append("Matched "+recArrStrElements[x]) //logFile.append("\n") found=true } else{ found=false } } } } if (!found){ pass = false log.info "Element not received " + recArrStrElements[x] + ":"+ recCurrVal + " ====/==== " + …
has answer: http://stackoverflow.com/a/21627090
score: 0
tagged with: groovy
has comment: http://stackoverflow.com/comment/32672734
answer count: 1
has comment: http://stackoverflow.com/comment/32681496
has comment: http://stackoverflow.com/comment/32673020
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32676474
tagged with: java

http://stackoverflow.com/q/21617098
downvote count: 0
accepted answer: http://stackoverflow.com/a/22729809
has body: I'm trying to implement a stable (first in first out) priority queue in Java. Supposing that the key is a name and the value is an age, I know I can make an unstable priority queue like this: Queue&lt;Map.Entry&lt;String, Integer&gt;&gt; pq = new PriorityQueue&lt;Map.Entry&lt;String, Integer&gt;&gt;(100, ageComparator); This does pretty much everything that I need it to, except that it doesn't maintain order of key-value pairs as I insert them (or remove them). I've found a "work around" by making a LinkedList, which offers essentially all of the same functionality, except that it doesn't include a constructor with a comparator option, and I feel that it must be slower since I maintain value ordering by calling Collections.sort() after each queue operation. So I guess that really there are two options that I'm interested in. First, how could I edit the PriorityQueue above to maintain insertion and removal order? Or second, how could I force my LinkedList option to use a comparator immediately rather than having to call a sort on each operation? Thanks! EDIT: Thanks for the good question in the first comment that was posted. By FIFO, I mean that for key-value pairs with equal values, the pair which is put in first should be extracted first.
tagged with: comparator
answer count: 3
has comment: http://stackoverflow.com/comment/32663853
favorite count: 0
has answer: http://stackoverflow.com/a/40957965
tagged with: priority-queue
has answer: http://stackoverflow.com/a/64893582
possible better answer: http://stackoverflow.com/a/40957965
type: AnsweredQuestion
tagged with: linked-list
has answer: http://stackoverflow.com/a/22729809
upvote count: 5
tagged with: java
tagged with: queue
type: Question
has comment: http://stackoverflow.com/comment/32663914
score: 5
has title: Making a Java PriorityQueue into a stable priority queue

http://stackoverflow.com/a/21515233
type: Answer
has body: After implementing equals() and hashcode() for class Fraction, do assertEquals(new Fraction(10,8), f2.add(f1)); Or if you're not sure about equals() and hashcode() methods, just hack out assertEquals("10/8", f2.add(f1).toString()); The add method returns Fraction but when you write assertEquals("10/8", f2.add(f1)), the "10/8" is of String type but f2.add(f1) is returning Fraction so since there's a type mismatch, test fails.
downvote count: 0
has comment: http://stackoverflow.com/comment/32483785
score: 1
has comment: http://stackoverflow.com/comment/32483668
answers question: http://stackoverflow.com/q/21515190
has comment: http://stackoverflow.com/comment/32483654
upvote count: 1
has comment: http://stackoverflow.com/comment/32483819
has comment: http://stackoverflow.com/comment/32483700

http://stackoverflow.com/comment/32629915
comment on: http://stackoverflow.com/a/21598027
has text: String method = recursive1.method1(word, number); System.out.println(method);
type: AnswerComment
type: Comment
score: 1

http://stackoverflow.com/a/21561257
has body: I've found it's best to control the maximum number of mappers by setting the input files' block size when moving data into HDFS. For example, if you set the block size to 1/30 of the total size, you'll end up with 30 blocks, and therefore, a maximum of 30 map tasks. hadoop fs -D fs.local.block.size=134217728 -put local_name remote_location
type: Answer
answers question: http://stackoverflow.com/q/21560613
score: 0

http://stackoverflow.com/comment/32499545
type: AnswerComment
comment on: http://stackoverflow.com/a/21524541
has text: @DanieleVitali - [Working example](http://ideone.com/XAYwJ4). Are you sure you're using the exact same format?
type: Comment
score: 0

http://stackoverflow.com/comment/32516278
type: Comment
type: QuestionComment
has text: If it is a class, it should be "extended" not "override"...
comment on: http://stackoverflow.com/q/21533664
score: 0

http://stackoverflow.com/q/21531377
downvote count: 0
has answer: http://stackoverflow.com/a/40426271
answer count: 7
possible better answer: http://stackoverflow.com/a/29719606
favorite count: 0
has answer: http://stackoverflow.com/a/33729813
has answer: http://stackoverflow.com/a/35585197
accepted answer: http://stackoverflow.com/a/21531443
type: AnsweredQuestion
score: 53
has answer: http://stackoverflow.com/a/43541088
type: Question
has body: I' trying to build a in IntelliJ IDEA project that is not mine and I got the following error: java: diamond operator is not supported in -source 1.6 (use -source 7 or higher to enable diamond operator) How do I change this setting in IntelliJ IDEA?
tagged with: java
has answer: http://stackoverflow.com/a/29719606
has answer: http://stackoverflow.com/a/21531443
has title: How to change from -source 1.6 to -source 7 in IntelliJ IDEA
has answer: http://stackoverflow.com/a/21531441
upvote count: 53
tagged with: intellij-idea

http://stackoverflow.com/q/21545197
has comment: http://stackoverflow.com/comment/32535779
possible better answer: http://stackoverflow.com/a/21545240
has answer: http://stackoverflow.com/a/21545240
tagged with: string
has comment: http://stackoverflow.com/comment/32535790
answer count: 5
has body: I have this code String str1 = (String) optionlist1.get(i);//str1=apple String str2 = (String) optionlist2.get(i);//str2=mango String str3 = (String) optionlist3.get(i);//str3=water for(int k=1;k&lt;4;k++){ String str="str"+k; sb.append("&lt;p&gt;"+k+")"+str+"&lt;/p&gt;"); } When I print this I just get str1,str2,str3 instead of the actual data i.e apple,mango,water. Is there a way to do this ? Let me know if more info is required.
accepted answer: http://stackoverflow.com/a/21545263
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21545259
tagged with: java
tagged with: stringbuffer
has answer: http://stackoverflow.com/a/21545248
has title: Append a int variable to a StringBuffer
type: Question
has answer: http://stackoverflow.com/a/21545263
has answer: http://stackoverflow.com/a/21545299
score: 0

http://stackoverflow.com/q/21647122
has answer: http://stackoverflow.com/a/21647138
possible better answer: http://stackoverflow.com/a/21647150
answer count: 4
has answer: http://stackoverflow.com/a/21647150
has title: Initializing a for loop with 2 variables
linked to: http://stackoverflow.com/q/19341216
has comment: http://stackoverflow.com/comment/32715631
type: Question
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21647138
has answer: http://stackoverflow.com/a/21647144
has answer: http://stackoverflow.com/a/48485170
tagged with: java
tagged with: for-loop
has body: I really don't understand why this wont work... for (int i = 1, int k = 2; i&lt;=4000000; i++) { } While this will... for (int i = 1; i&lt;=4000000; i++) { } I need to initialize two variables but when I try the first code it wont compile, the code looks correct??
score: 0

http://stackoverflow.com/q/21600271
has comment: http://stackoverflow.com/comment/32633471
has comment: http://stackoverflow.com/comment/32633782
has comment: http://stackoverflow.com/comment/32633612
score: 0
has body: I am developing a Music Player. All songs are placed in the ListView with a ImageButton. This button is playing and pause the songs. So I am using getview(). But when I am clicking on the ImageButton, the songs are playing and pausing, but the image of play/pause is not changing. My main issue as I think, is that, when I am clicking on the ImageButton it is not calling the getview(). So please help me. @Override protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_ringtones); super.onCreate(savedInstanceState); setContentView(R.layout.activity_ringtones); mAdapter = new RingtonesMusicAdapter(this, R.layout.ringtones_row); mListView.setAdapter(mAdapter); } public void invalidatePlayButtons(int position) { for (int i = 0; i &lt; mTrackData.size(); i++) { if (i != position) { try { //mTrackData.get(i).getRowItem().mPlayButton.setImageResource(R.drawable.play); if (MusicManager.getInstance().isPlaying(mTrackData.get(i))) { MusicManager.getInstance().stop(); mTrackData.get(i).getRowItem().mProgressBar .setProgress(0); } } catch (Exception ex) { ex.printStackTrace(); } } else mTrackData.get(i).getRowItem().mPlayButton .setImageResource(R.drawable.pause); } } public void onPlayClick(View view) { Object obj = view.getTag(); if (obj != null &amp;&amp; obj.getClass() == RowItem.class) { final RowItem rowItem = (RowItem) obj; if(rowItem.mPosition != mChantIndex ){ if (!MusicManager.getInstance().isPlaying(rowItem)) { invalidatePlayButtons(rowItem.mPosition); MusicManager.getInstance().showProgressAnimation(rowItem.mProgressBar); // rowItem.mPlayButton.setImageResource(R.drawable.pause); if(rowItem.isPause){ //rowItem.mPlayButton.setImageResource(R.drawable.pause); MusicManager.getInstance().setLengthTrack(); }else{ rowItem.mMusicListener = this; MusicManager.getInstance().playDownloadedTrack(rowItem); if(rowItem.mPosition == mProgressbarIndex) { mProgressbarIndex = -1; } else { mProgressbarIndex = rowItem.mPosition; } } }else if(MusicManager.ge…
has comment: http://stackoverflow.com/comment/32633521
tagged with: java
type: UnansweredQuestion
tagged with: android-music-player
tagged with: listview
has comment: http://stackoverflow.com/comment/32636087
answer count: 0
has comment: http://stackoverflow.com/comment/32634150
has comment: http://stackoverflow.com/comment/32633998
has comment: http://stackoverflow.com/comment/32633819
has title: getview() is not calling on button click?
has comment: http://stackoverflow.com/comment/32633695
type: Question
tagged with: audio-player
tagged with: android

http://stackoverflow.com/a/21583102
answers question: http://stackoverflow.com/q/21582421
type: Answer
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/32603562
upvote count: 2
accepted answer of: http://stackoverflow.com/q/21582421
has body: The docs say that StringArray does not define any item attributes. In your case "value" is an attribute. Here's the reference: http://developer.android.com/guide/topics/resources/string-resource.html#StringArray
type: AcceptedAnswer

jboss6.x
tag name: jboss6.x
tags question: http://stackoverflow.com/q/21673420
type: Tag

http://stackoverflow.com/a/21605046
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/21604939
has body: If you are using the url in form of a string, a string is immutable so you have to assign the replaced string to a new one. String url = theOriginalUrlString.replaceAll(" ", "%20"); The replacement is reflected in the new string.
downvote count: 0
score: 1

http://stackoverflow.com/comment/32713021
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21622705
has text: Both, i dont know how to handle an array,first i need to send data from cursor to an array,and after to viewpageradapter. The last code is my last try in this

http://stackoverflow.com/comment/32702598
type: QuestionComment
has text: I would say, add the entry: `ant.apache.org localhost` in the file `/etc/hosts`, run a `httpd server` on your machine and put the packages in the correct directories. Basically, fool ant into thinking that it is downloading from internet.
comment on: http://stackoverflow.com/q/21639210
score: 0
type: Comment

http://stackoverflow.com/comment/32626699
type: Comment
has text: @maaartinus Do you have any performance benchmark or something to prove that? According to my understanding that should not make any difference.
comment on: http://stackoverflow.com/a/21571516
score: 0
type: AnswerComment

http://stackoverflow.com/comment/109545214
type: AnswerComment
score: 4
comment on: http://stackoverflow.com/a/48245094
type: Comment
has text: this is the best solution without adding extra parsing libraries

http://stackoverflow.com/comment/32569064
comment on: http://stackoverflow.com/a/21563687
has text: Ok so it appears there's two schools of thought here. I'll revisit the accepted answer in the coming days...
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/32741834
has text: My question is about how to generate code for an exception not to have Eclipse catch it.
comment on: http://stackoverflow.com/a/21662106
type: Comment
score: 1
type: AnswerComment

http://stackoverflow.com/comment/32711506
score: 2
comment on: http://stackoverflow.com/q/21644737
type: Comment
type: QuestionComment
has text: "empty array so that i can enter any number of elements i want": an array always has a fixed length. If you are looking for a dynamic structure use a `List`.

http://stackoverflow.com/a/21567520
upvote count: 1
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/32578769
answers question: http://stackoverflow.com/q/21567468
score: 1
has body: You're getting 6 numbers on the first line, because you start counting at i=0, and only print the newline once i=5; at which point the number you've just printed is 6, not 5 - you're printing i+1 in each iteration. If you made your logic such that it printed EITHER a comma OR a newline but not both, you'd get rid of the commas at the ends of the lines.

http://stackoverflow.com/comment/32664244
comment on: http://stackoverflow.com/a/21617322
has text: You should use the same function or method both for storage and for comparison, it does not matter which. For example, using Date().getTime() in both instances is ok.
type: AnswerComment
score: 1
type: Comment

http://stackoverflow.com/a/21615416
has body: We cant know the issue until you add your log cat, but I did spot the following: You add your items to the array before there's anything in them, fix it like this items.add("First Item"); items.add("Second Item"); itemsAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, items); lvItems.setAdapter(itemsAdapter);
type: Answer
has comment: http://stackoverflow.com/comment/32660727
score: 0
answers question: http://stackoverflow.com/q/21615329

http://stackoverflow.com/comment/32616708
score: 0
type: Comment
type: QuestionComment
has text: ProgressBar class http://developer.android.com/reference/android/widget/ProgressBar.html (You would need to tweak to implement it into a button im sure)
comment on: http://stackoverflow.com/q/21590067

http://stackoverflow.com/q/21658579
has answer: http://stackoverflow.com/a/27179116
tagged with: http://stackoverflow.com/tag/csv
has title: How to deal with CSV files having an unknown number of columns using Super CSV
has body: For a project I need to deal with CSV files where I do not know the columns before runtime. The CSV files are perfectly valid, I only need to perform a simple task on several different files over and over again. I do need to analyse the values of the columns, which is why I would need to use a library for working with CSV files. For simplicity, lets assume that I need to do something simple like appending a date column to all files, regardless how many columns they have. I want to do that with Super CSV, because I use the library for other tasks as well. What I am struggeling with is more a conceptual issue. I am not sure how to deal with the files if I do not know in advance how many columns there are. I am not sure how I should define POJOs that map arbitrary CSV files or how I should define the Cell Processors if I do not know which and how many columns will be in the file. How can I dynamically create Cell processors that match the number of columns? How would I define POJOs for instance based on the header of the CSV file? Consider the case where I have two CSV files: products.csv and address.csv. Lets assume I want to append a date column with today’s date for both files, without having to write two different methods (e.g. addDateColumnToProduct() and addDateColumnToAddress()) which do the same thing. product.csv: name, description, price "Apple", "red apple from Italy","2.5€" "Orange", "orange from Spain","3€" address.csv: firstname, lastname "John", "Doe" "Coole", "Piet" Based on the header information of the CSV files, how could I define a POJO that maps the product CSV? The same question for Cell Processors? How could I define even a very simple cell processor that just basically has the right amount of parameters for the constructor, e.g. for the product.csv CellProcessor[] processor = new CellProcessor[] { null, null, null }; and for the address.csv: CellProcessor[] processor = new CellProcessor[] { null, null }; Is this even possible? Am I on the wrong …
tagged with: java
accepted answer: http://stackoverflow.com/a/27179116
type: Question
type: AnsweredQuestion
tagged with: supercsv
has answer: http://stackoverflow.com/a/21658626
tagged with: pojo
score: 4
upvote count: 4
answer count: 2
possible better answer: http://stackoverflow.com/a/21658626
downvote count: 0
favorite count: 0

http://stackoverflow.com/a/21604647
has comment: http://stackoverflow.com/comment/32644888
has body: The export command is a shell command, specific to certain command shells, not a separate executable. That's why you're getting that error. You could wrap the execution of your ant script in a shell script. The shell script would set any prerequisite environment variables, then call ant. For example: #!/bin/bash export PROJECT_ENV=prod ant -f build.xml
accepted answer of: http://stackoverflow.com/q/21603973
score: 1
upvote count: 1
type: AcceptedAnswer
type: Answer
answers question: http://stackoverflow.com/q/21603973
downvote count: 0

http://stackoverflow.com/comment/32734241
comment on: http://stackoverflow.com/q/21657506
has text: `OutOfMemoryError`...you are loading too many images.
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/32752410
score: 0
type: AnswerComment
type: Comment
has text: I thought that is what the professor wanted... he wants me to set an initial value of annualInterestRate which is 0 right? line 3 already has a vaule of 4.5 for the annualInterestRate.. does that do anything at all? i am so confused...
comment on: http://stackoverflow.com/a/21667846

http://stackoverflow.com/comment/32683302
type: QuestionComment
comment on: http://stackoverflow.com/q/21627815
has text: i think you should detect when app(activity) moves to Background and remove messages from your handler.
score: 0
type: Comment

http://stackoverflow.com/comment/32519787
type: QuestionComment
comment on: http://stackoverflow.com/q/21534467
has text: When variables could be null, like con, check if before using the dot operator.
score: 0
type: Comment

http://stackoverflow.com/a/21581696
accepted answer of: http://stackoverflow.com/q/21581152
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32601579
type: Answer
has comment: http://stackoverflow.com/comment/32601672
has body: It won't be an infinite loop because you have to use the PlanDTO object result which you have just created before the loop. See the code below. Note : Still I suggest to go for a framework which will do this stuff for you. public class PlanAssembler { public static PlanDTO makeDTO(Plan p) { PlanDTO result = new PlanDTO(); result.setProperty(p.getProperty); ... for (Activity a: p.getActivity()) { ActivityDTO activityDTO = new ActivityDTO(); // Here I need to iterate over each activity to convert it to DTO // But in ActivityAssembler, I also need PlanDTO //Code to convert Activity to ActivityDTO. activityDTO.setPlan(result); }
answers question: http://stackoverflow.com/q/21581152
score: 3
has comment: http://stackoverflow.com/comment/32601292
has comment: http://stackoverflow.com/comment/32601502
upvote count: 3
has comment: http://stackoverflow.com/comment/32601393

http://stackoverflow.com/q/21551391
tagged with: java
upvote count: 1
has title: Is there a way to get security baseline in an applet?
has comment: http://stackoverflow.com/comment/32589670
type: AnsweredQuestion
type: Question
has comment: http://stackoverflow.com/comment/32588815
answer count: 1
downvote count: 0
tagged with: applet
favorite count: 0
tagged with: security
has answer: http://stackoverflow.com/a/21584150
accepted answer: http://stackoverflow.com/a/21584150
has body: With recent changes in applet security and resulting problems (mostly with LiveConnect), I was wondering if there is a way to check current security baseline from within applet code and compare it with current JRE version. This way some action could be taken, like warning the user, instead of just silently failing. EDIT: To clarify, as of Java 7, Oracle introduced the "Security baseline", which is lowest JRE version considered "secure". Eg. currently it is (i think) 1.7.0_45. So if user has lower JRE installed, applets will start, but some features won't work. In my case, JavaScript to applet calls are blocked. The applet plugin dynamically checks what is current baseline, so I wanted to know if there is a way for an applet to determine this baseline.
score: 1

http://stackoverflow.com/q/21641455
has comment: http://stackoverflow.com/comment/32717899
tagged with: android
has comment: http://stackoverflow.com/comment/32708660
has answer: http://stackoverflow.com/a/21641718
answer count: 1
has comment: http://stackoverflow.com/comment/32721005
score: 0
tagged with: java
tagged with: file
has comment: http://stackoverflow.com/comment/32708272
has comment: http://stackoverflow.com/comment/32718316
has body: I'm very new to the Android SDK and I can't get the file writing/reading to work. Please note that I'm also fairly new to Java. The program is supposed to simply write a string to a file, read the same string, and then change a TextView to that read string. The program runs but does not change the TextView. Can someone please tell me what I'm doing wrong? Thanks. MainActivity.java package com.example.test; import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.FileReader; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.Menu; import android.widget.TextView; public class MainActivity extends Activity { public String readFileLine(String filepath) throws java.io.FileNotFoundException, java.io.IOException { //opens file and returns first line FileReader fr = new FileReader (new File(filepath)); BufferedReader inputStream = new BufferedReader (fr); String temp = inputStream.readLine(); inputStream.close(); return temp; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FileOutputStream outputStream_local; try { outputStream_local = openFileOutput("local.txt", Context.MODE_PRIVATE); outputStream_local.write("asdf".getBytes()); outputStream_local.close(); } catch (Exception e) { e.printStackTrace(); } TextView temp = (TextView) findViewById(R.id.getMe); try { temp.setText(readFileLine(getFilesDir().toString() + "local.txt")); } catch (Exception e) { e.printStackTrace(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } } activity_main.xml &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android…
has comment: http://stackoverflow.com/comment/32718775
type: UnansweredQuestion
has title: Android SDK - Cannot write/read files
tagged with: sdk
type: Question

http://stackoverflow.com/comment/32501640
has text: Yes! It's working!!!! Thank you so much!! Just want to know, what happens when I hit Ctrl+Shift+I ? There will be a code addition?
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/21525009
type: Comment

http://stackoverflow.com/q/21666849
type: Question
tagged with: java
tagged with: struts
has comment: http://stackoverflow.com/comment/32760152
tagged with: jstl
tagged with: jsp
score: 0
has comment: http://stackoverflow.com/comment/32754846
has body: I am using display:table with display:column along with bean:write to print out some values from my request. &lt;bean:write name="DisplayBookForm" property="bookType" /&gt; I have an import like &lt;%@page import="org.model.MyConstants"%&gt; In there I have a simple function public static String getBookTypeName(int id){ //lots of if's based on id String bookTypeName = "Fantasy"; return bookTypeName; } Is there anyway I could pass in my DisplayBookForm bookType property value into this function and then display its String return? Something like: &lt;c:out value="&lt;%=MyConstants.getBookTypeName(${DisplayBookForm.bookType}) %&gt;" /&gt; &lt;%=MyConstants.getBookTypeName(${DisplayBookForm.bookType})%&gt; Which seem to not work, perhaps set the bean using c:set and then use it in the &lt;% tags?
has title: jsp scriplet use function with bean value
answer count: 0
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/7121303

http://stackoverflow.com/a/21560367
score: 1
answers question: http://stackoverflow.com/q/21560082
upvote count: 1
has comment: http://stackoverflow.com/comment/32562978
has comment: http://stackoverflow.com/comment/32563015
type: Answer
has body: Maybe I misunderstood your question. Are you asking why &lt;bean class="com.user.services.MessageService_BindingImpl" scope="request"/&gt; is failing with a class like public class MessageService_BindingImpl implements com.user.service.MessageService_PortType { public MessageService_BindingImpl (String hello) { } ... } ? If so, then the answer is that by not providing any constructor-arg, Spring will try to use your class' no-argument constructor. Since you don't have one, it can't use it.
downvote count: 0

http://stackoverflow.com/q/21571069
favorite count: 0
possible better answer: http://stackoverflow.com/a/21572356
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21592894
has answer: http://stackoverflow.com/a/21572356
score: 1
accepted answer: http://stackoverflow.com/a/21572439
upvote count: 1
type: Question
has body: Is it possible to split the output of a mapreduce job into multiple files instead of a single 'part-r-00000' file? I've came across the MultipleOutputFormat class, but from what I've read it seems that it only breaks the output into files based on the key. MultipleOutputFormat What I am looking for is, to take the WordCount job as an example, to just divide the output into more than 1 file.
tagged with: java
tagged with: mapreduce
tagged with: hadoop
answer count: 3
downvote count: 0
tagged with: hdfs
has title: Splittig MapReduce output into multiple output files
has answer: http://stackoverflow.com/a/21572439

http://stackoverflow.com/comment/32698247
score: 0
type: Comment
has text: Or press Ctrl+Shit+O and clear
type: AnswerComment
comment on: http://stackoverflow.com/a/21636608

http://stackoverflow.com/a/21657328
upvote count: 2
has body: Eclipse has a "feature" where you can run code which doesn't compile. I highly recommend you not use this as it only delays finding bugs (which maximises the cost of fixing them) When you turn this feature off you will find the line of code which is not compiling and it might not have anything to do with the use of sub-classes. In short, you can do this, the error is probably something unrelated.
answers question: http://stackoverflow.com/q/21657307
downvote count: 0
type: Answer
score: 2

android-viewpager
tag name: android-viewpager
type: Tag
tags question: http://stackoverflow.com/q/21577697
tags question: http://stackoverflow.com/q/21618480
tags question: http://stackoverflow.com/q/21571759
tags question: http://stackoverflow.com/q/21622705

http://stackoverflow.com/q/21528968
tagged with: multithreading
has comment: http://stackoverflow.com/comment/32507712
upvote count: 1
has comment: http://stackoverflow.com/comment/32507678
has answer: http://stackoverflow.com/a/21529319
has answer: http://stackoverflow.com/a/21529317
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32507783
has title: Synchronized objects accessed from unsynchronized methods
type: Question
has comment: http://stackoverflow.com/comment/32508352
has body: Suppose I have a class in which there is a StringBuffer declared as a member variable. Two threads are trying to manipulate the object like below public class SomeService { private StringBuffer sb = new StringBuffer(); public void printName(String name) { sb.append(name); System.out.println(sb); } } public class StringBufferSynchronizationTest implements Runnable { private SomeService service = new SomeService(); public StringBufferSynchronizationTest() { Thread thread = new Thread(this); thread.start(); } public static void main(String[] args) { new StringBufferSynchronizationTest().service.printName("oops"); } @Override public void run() { service.printName("java"); } } And I get this output oopsjava oopsjava I thought I will get oops oopsjava as output. When I synchronized printName method I got the second output. So I understood that even I use a synchronized class I have to synchronize blocks/methods that use the synchronized classes. Am I right?
has comment: http://stackoverflow.com/comment/32507730
has comment: http://stackoverflow.com/comment/32507645
has answer: http://stackoverflow.com/a/21529200
has comment: http://stackoverflow.com/comment/32508054
downvote count: 0
has comment: http://stackoverflow.com/comment/32507369
has comment: http://stackoverflow.com/comment/32507260
answer count: 3
tagged with: synchronization
favorite count: 0
type: UnansweredQuestion

http://stackoverflow.com/q/21570417
has answer: http://stackoverflow.com/a/21570482
tagged with: java
tagged with: indexoutofboundsexception
has comment: http://stackoverflow.com/comment/32581507
has title: java.lang.indexoutofboundsexception index 0 size 0
type: Question
has comment: http://stackoverflow.com/comment/32581679
upvote count: 0
score: -2
answer count: 1
has body: I've been getting this java.lang.indexoutofboundsexception error when adding system functions objects in an array through checkbox: SEVERE: Servlet.service() for servlet spis threw exception java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:604) at java.util.ArrayList.get(ArrayList.java:382) at com.spis.dao.impl.CodesValueDaoImpl.getDescription(CodesValueDaoImpl.java:95) at com.spis.bo.impl.CodesValueBoImpl.getDescription(CodesValueBoImpl.java:103) at com.spis.controller.SystemUserController.viewPaged(SystemUserController.java:408) at com.spis.controller.SystemUserController.systemUser(SystemUserController.java:48) Here is the for the systemFunctions: whenever i add systemFunction to a user it displays the error or when the systemFunction colummn in the database is null. But when i set systemFunction=" " in the database the page displays correctly although withouth the array of systemFunctions obviously.. String[] systemFunctions=(String[])request.getParameterValues("systemFunctions"); String appendedSysFunctions =""; //Append system functions if(systemFunctions!=null){ for(int i=0;i&lt;systemFunctions.length;i++){ if(i==(systemFunctions.length-1)){ appendedSysFunctions+=systemFunctions[i]; } else{ appendedSysFunctions+=systemFunctions[i] + ","; } } } Another code: StringTokenizer st = new StringTokenizer(su.getAllowedSysFunc(), ","); while (st.hasMoreTokens()){ appendedSystemFunc = appendedSystemFunc + codesValueMethods.getDescription (3, st.nextToken()); if(st.hasMoreTokens()){ appendedSystemFunc = appendedSystemFunc + ", \n"; } }
favorite count: 0
has comment: http://stackoverflow.com/comment/32581706
has comment: http://stackoverflow.com/comment/32581497
type: UnansweredQuestion
downvote count: 2
has comment: http://stackoverflow.com/comment/32581551
has comment: http://stackoverflow.com/comment/32581641
has comment: http://stackoverflow.com/comment/32581774

http://stackoverflow.com/a/21643261
accepted answer of: http://stackoverflow.com/q/21643257
type: AcceptedAnswer
has body: You missed to give data type of variable y for(int y=0; y&lt;rows; y++){ //Error here --------^ writer.append("" + sum[y]); // and here: that "y is not public....." writer.append(','); }
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/21643257
downvote count: 0

http://stackoverflow.com/a/21672419
score: 0
has body: It is because you mixed annotating both fields and getters. According to the JPA spec, you must remain consistent, in which you JPA annotate either only the fields, or only the getters. (usually JPA looks at the ID field and than decides to consider the fields or getters).
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32761133
has comment: http://stackoverflow.com/comment/32761255
type: Answer
accepted answer of: http://stackoverflow.com/q/21669992
has comment: http://stackoverflow.com/comment/32766149
answers question: http://stackoverflow.com/q/21669992

http://stackoverflow.com/q/21640835
tagged with: jenkins
tagged with: maven
score: 11
type: AnsweredQuestion
tagged with: java
tagged with: jenkins-plugins
type: Question
accepted answer: http://stackoverflow.com/a/27350388
tagged with: java.util.logging
answer count: 1
downvote count: 0
favorite count: 0
has body: I'm writing a Jenkins plugin, and testing it using mvn verify and JenkinsRule. So far so good, but I'd like to be able to quieten the output; it's pages per test. What kind of config file do I use, and where do I put it? I've tried a suitable log4j.properties (and just to be sure, a logging.properties) in src/test/resources (and thus target/test-classes); I've tried putting them in target/jenkins-for-test/WEB-INF/classes, that didn't help either. In case it jogs anyone's memory, the output I'm trying to suppress are things like Feb 08, 2014 2:26:40 PM jenkins.InitReactorRunner$1 onAttained INFO: Started initialization Feb 08, 2014 2:26:40 PM jenkins.InitReactorRunner$1 onAttained INFO: Listed all plugins and Feb 08, 2014 2:26:44 PM hudson.PluginWrapper stop INFO: Stopping javadoc Feb 08, 2014 2:26:44 PM hudson.PluginWrapper stop INFO: Stopping maven-plugin
has answer: http://stackoverflow.com/a/27350388
linked to: http://stackoverflow.com/q/3939072
has title: How do I set the java.util.logging log level in maven (for Jenkins plugin (JenkinsRule) tests)
upvote count: 11

http://stackoverflow.com/comment/110107896
score: 1
has text: Spring resolves type parameters, so that should work as expected (only exception are nested type parameters with Kotlin types, what not always works).
comment on: http://stackoverflow.com/a/50350428
type: AnswerComment
type: Comment

swing
tags question: http://stackoverflow.com/q/21548866
tags question: http://stackoverflow.com/q/21676470
tags question: http://stackoverflow.com/q/21531632
tags question: http://stackoverflow.com/q/21615307
tags question: http://stackoverflow.com/q/21618886
tags question: http://stackoverflow.com/q/21572055
tags question: http://stackoverflow.com/q/21676631
tags question: http://stackoverflow.com/q/21518521
tags question: http://stackoverflow.com/q/21520695
tags question: http://stackoverflow.com/q/21585941
tags question: http://stackoverflow.com/q/21675836
tags question: http://stackoverflow.com/q/21558107
tags question: http://stackoverflow.com/q/21539847
tags question: http://stackoverflow.com/q/21581671
tags question: http://stackoverflow.com/q/21516299
tags question: http://stackoverflow.com/q/21579782
tags question: http://stackoverflow.com/q/21580998
tags question: http://stackoverflow.com/q/21568851
tags question: http://stackoverflow.com/q/21677969
tags question: http://stackoverflow.com/q/21623340
tags question: http://stackoverflow.com/q/21533692
tags question: http://stackoverflow.com/q/21653184
tags question: http://stackoverflow.com/q/21552417
tags question: http://stackoverflow.com/q/21637198
tags question: http://stackoverflow.com/q/21540308
tags question: http://stackoverflow.com/q/21576455
tags question: http://stackoverflow.com/q/21642617
tags question: http://stackoverflow.com/q/21548411
tags question: http://stackoverflow.com/q/21590006
tags question: http://stackoverflow.com/q/21633623
tags question: http://stackoverflow.com/q/21611270
tags question: http://stackoverflow.com/q/21652914
tags question: http://stackoverflow.com/q/21622148
tags question: http://stackoverflow.com/q/21654777
tags question: http://stackoverflow.com/q/21555711
tags question: http://stackoverflow.com/q/21595590
tags question: http://stackoverflow.com/q/21643307
tags question: http://stackoverflow.com/q/21539135
tags question: http://stackoverflow.com/q/21524128
tags question: http://stackoverflow.com/q/21584703
tags question: http://stackoverflow.com/q/21588060
tags question: http://stackoverflow.com/q/21645026
tags question: http://stackoverflow.com/q/21625051
tags question: http://stackoverflow.com/q/21663590
tags question: http://stackoverflow.com/q/21611142
tags question: http://stackoverflow.com/q/21675981
tags question: http://stackoverflow.com/q/21618715
tags question: http://stackoverflow.com/q/21610712
tags question: http://stackoverflow.com/q/21645114
tags question: http://stackoverflow.com/q/21608291
tags question: http://stackoverflow.com/q/21656912
tags question: http://stackoverflow.com/q/21622419
tags question: http://stackoverflow.com/q/21663660
tags question: http://stackoverflow.com/q/21644646
tags question: http://stackoverflow.com/q/21632736
tags question: http://stackoverflow.com/q/21529667
tags question: http://stackoverflow.com/q/21661464
tags question: http://stackoverflow.com/q/21603911
tags question: http://stackoverflow.com/q/21578482
tags question: http://stackoverflow.com/q/21617038
tags question: http://stackoverflow.com/q/21659479
tags question: http://stackoverflow.com/q/21532761
tags question: http://stackoverflow.com/q/21524191
tags question: http://stackoverflow.com/q/21674207
tags question: http://stackoverflow.com/q/21545462
tags question: http://stackoverflow.com/q/21545615
tags question: http://stackoverflow.com/q/21643817
tags question: http://stackoverflow.com/q/21654735
tags question: http://stackoverflow.com/q/21516220
tags question: http://stackoverflow.com/q/21653445
tags question: http://stackoverflow.com/q/21585604
tags question: http://stackoverflow.com/q/21589521
tags question: http://stackoverflow.com/q/21580236
tags question: http://stackoverflow.com/q/21534755
tags question: http://stackoverflow.com/q/21641264
tags question: http://stackoverflow.com/q/21653372
tags question: http://stackoverflow.com/q/21625170
tags question: http://stackoverflow.com/q/21554530
type: Tag
tags question: http://stackoverflow.com/q/21525356

http://stackoverflow.com/a/22025747
has body: You can ask your jax-ws implementation to generate asynchronous bindings for the web service. This has two advantages that I can see: As discussed in Asynchronous web services calls with JAX-WS: Use wsimport support for asynchrony or roll my own? , jax-ws will generate well-tested (and possibly fancier) code for you, you need not instantiate the ExecutorService yourself. So less work for you! (but also less control over the threading implementation details) The generated bindings include a method where you specify a callback handler, which may suit your needs better than synchronously get() ting all response lists on the thread calling retrieveAllLists(). It allows for per-service-call error handling and will process the results in parallel, which is nice if processing is non-trivial. An example for Metro can be found on the Metro site. Note the contents of the custom bindings file custom-client.xml : true When you specify this bindings file to wsimport, it'll generate a client which returns an object that implements javax.xml.ws.Response<T>. Response extends the Future interface that others also suggest you use when rolling your own implementation. So, unsurprisingly, if you go without the callbacks, the code will look similar to the other answers: public void retrieveAllLists() throws ExecutionException{ // first fire all requests Response<List<StudentsResults>> students1 = ws1.getStudents(); Response<List<StudentsResults>> students2 = ws2.getStudents(); Response<List<StudentsResults>> students3 = ws3.getStudents(); Response<List<DoctorsResults>> doctors1 = ws4.getDoctors(); Response<List<DoctorsResults>> doctors2 = ws5.getDoctors(); Response<List<DoctorsResults>> doctors3 = ws6.getDoctors(); Response<List<PatientsResults>> patients1 = ws7.getPatients(); Response<List<PatientsResults>> patients2 = ws8.getPatients(); Response<List<PatientsResults>> patients3 = ws9.getPatients(); // then await and collect all the responses studentsResults.addAll(students1.get()); st…
type: Answer
score: 2
answers question: http://stackoverflow.com/q/21670451
upvote count: 3
downvote count: 1
has comment: http://stackoverflow.com/comment/33391252
has comment: http://stackoverflow.com/comment/33390990

http://stackoverflow.com/comment/32752491
has text: Is it possible that I just add the `DecimalFormat fmt = new DecimalFormat ("0." + numberSigns);`, and not have to add the String method?
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21667917
type: AnswerComment

http://stackoverflow.com/comment/32501421
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21525009
has text: Did you change the name to `jTable2` instead of `jTbable1`?
type: AnswerComment

http://stackoverflow.com/comment/32681807
has text: Good question. I can't answer the OP without the answer to this counter-question!
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21627918
type: Comment

http://stackoverflow.com/q/21635681
answer count: 3
tagged with: regex
has comment: http://stackoverflow.com/comment/32695799
tagged with: pattern-matching
has comment: http://stackoverflow.com/comment/32696647
has comment: http://stackoverflow.com/comment/32696153
has title: Regular expression - Negative lookahead
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32696860
tagged with: java
possible better answer: http://stackoverflow.com/a/21636162
has answer: http://stackoverflow.com/a/21636162
accepted answer: http://stackoverflow.com/a/21636515
has answer: http://stackoverflow.com/a/22723422
type: Question
score: 0
tagged with: string
has comment: http://stackoverflow.com/comment/32696052
has body: Using the following expression: (?&lt;!XYZ\d{8})(?&gt;REF[A-Z]*)?(\d{3}+)(\d{6}+)(\d{3}+) I am getting unexpected matches. Please could you explain why the following matches occur: Input XYZ12345678123456789123 - Matches on 123456781234 - I was expecting it to only match on 123456789123 because it is the only sequence not preceded by (?&lt;!XYZ\d{8}) Weirdly enough, if i use XYZ12345678REF123456789876 as input, it returns a match on 123456789876 but not REF123456789876. It correctly ignored the XYZ12345678, but it didn't pick up the optional REF characters. Basically what i want to achieve is to extract a 12 digit identifier from a string that contains two identifiers. The first identifier has the format XYZ\d{8} and the second identifier has the format (?&gt;REF[A-Z]*)?(\d{3}+)(\d{6}+)(\d{3}+) To avoid a match on the wrong 12 digits in a string such as XYZ12345678123456789123, i want to say - get the twelve digits as long as the digits are not part of an XYZ\d{8} type identifier. Edit Here are a couple of examples of what i want to achieve XYZ12345678123456789123 match on 123456789123 123456789123 match on 123456789123 XYZ12345678REF123456789123 should match on REF123456789123 12345678912 no match because not 12 digits REF123456789123 match on REF123456789123 REF12345678912 no match because not 12 digits XYZ12345678123456789123ABC match on 123456789123 XYZ123456789123 No match XYZ1234567891234 no match
has answer: http://stackoverflow.com/a/21636515
has comment: http://stackoverflow.com/comment/32696325

http://stackoverflow.com/a/21626059
has comment: http://stackoverflow.com/comment/32680712
has comment: http://stackoverflow.com/comment/33141789
answers question: http://stackoverflow.com/q/21625978
has comment: http://stackoverflow.com/comment/32682724
accepted answer of: http://stackoverflow.com/q/21625978
has comment: http://stackoverflow.com/comment/32682697
has comment: http://stackoverflow.com/comment/32679444
has body: I think this is the closest for your case: var page = { url: "", timeout: 0, pvs: [ { url: "", layout: "", headers: ["", ""], ttl: 0 } ] } Seeing that Javascript isn't so typed as Java, I've used some generic types for your Java types Layout and Map that I don't really know what is. UPDATE: See this Fiddle. Is just a example of how work with js objects, instance, properties and methods. It's to study and learn. Hope you like.
type: AcceptedAnswer
score: 0
type: Answer

http://stackoverflow.com/a/21663602
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21663275
has body: Since you're not going into detail about the problem itself, I guess what you are asking for is a data structure to accommodate the matrix, and not the algorithm to solve the problem. A valid datastructure would be a two-dimensional array int[8][8] or even boolean[8][8], since you only need two states per field. If you're asking for a datastructure that verifies the rule of not more or less than eight marked fields, you can implement a wrapper class around such array that contain the logic to validate. I might have grossly misunderstood you though.

http://stackoverflow.com/comment/32683121
type: Comment
has text: What you're saying doesn't sound like you know what you're working on.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21621052

http://stackoverflow.com/a/21548594
has comment: http://stackoverflow.com/comment/32541854
downvote count: 0
has comment: http://stackoverflow.com/comment/32541669
has body: Try this: String b = a.replaceAll("(\d)([a-zA-Z])","$1*$2"); The above will look for a digit next to a alphabet, then using capture groups will insert a * in between the two.
has comment: http://stackoverflow.com/comment/32541703
type: Answer
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/21548534

http://stackoverflow.com/q/21611916
answer count: 1
has body: I am trying to achieve following: I have two Maps (not sure yet which safe to use and works properly) Both are like Map&lt;Integer, Object&gt; (let's say from now Map1 and Map2 Object is always inserted to Map1 first The Integer value is incremented with AtomicInteger every time Object is inserted to Map1 After insertion I need to get the first inserted Object from the Map1 and move it to Map2 and then perform asynchronous operation with the Object In the callback of that operation I need to remove the Object from Map2 and repeat Map1 is sort of a queue and Map2 contains all running operations. The amount of running operations can be adjusted to be more than 1 at a time. For example I execute 5 operations in a row and max amount for running operations is 4, the sequence would be: Put all 5 into Map1 with 0,1,2,3,4 ids. Then indexes 0,1,2,3 should be removed and moved to Map2. When first Object from Map2 is ready, it should be removed and the last from Map1 moved to Map2. I tried with ConcurrentHashMap but iterating it with Iterator.next() started from the last inserted item and had some problems removing item from Map2 when the object got ready.
has answer: http://stackoverflow.com/a/21611969
type: AnsweredQuestion
tagged with: java
tagged with: multithreading
type: Question
accepted answer: http://stackoverflow.com/a/21611969
score: 0
has title: Handling two Maps with multiple threads

http://stackoverflow.com/q/21625465
has answer: http://stackoverflow.com/a/24438522
downvote count: 0
favorite count: 0
has title: How to verify tooltip text using Selenium WebDriver with java on a webpage
has answer: http://stackoverflow.com/a/33392999
tagged with: selenium-webdriver
type: UnansweredQuestion
has body: I want to verify tooltip text on NEW Button of my webpage. The html backend code of NEW Button before mousehover is as below: New After mousehover on NEW Button the html backend code of NEW Button is as below: area-describdby="ui-tooltip-27"New Now I want to verify that tooltip text "Create a new Configuration Package" should come after mousehover on NEW Button. I'm able to store the text in a string before mouseover by following code: WebElement NewButton = driver.findElement(By.id("newBtn")); String Tooltip = NewButton.getAttribute("title"); System.out.println(Tooltip); Its printing text "Create a new Configuration Package" But when I'm moving mouse over NEW button and writing code Actions ActionChains = new Actions(driver); WebElement NewButton = driver.findElement(By.id("newBtn")); actions.moveToElement(NewButton).build().perform(); ActionChains.clickAndHold(NewButton).perform(); String Tooltip = NewButton.getAttribute("title"); System.out.println(Tooltip); I'm not geting anything i m getting blank message Because after mousehover the title is "" in backend html code of NEW Button. How can I do that?
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/23239284
score: 1
tagged with: java
tagged with: tooltip
has comment: http://stackoverflow.com/comment/48211850
answer count: 3

http://stackoverflow.com/q/21594842
has comment: http://stackoverflow.com/comment/32624686
downvote count: 1
has title: Learnstreet java lesson 3 part 8, reversing a string
tagged with: java
score: -1
type: Question
answer count: 2
upvote count: 0
tagged with: string
favorite count: 0
has answer: http://stackoverflow.com/a/21594914
has body: question asks to reverse characters "mug" set as a string into "gum" I tried the suggested "mug".charAt(2) + "mug".charAt(1) + "mug".charAt(0) once input it says incorrect
has answer: http://stackoverflow.com/a/21594918
has comment: http://stackoverflow.com/comment/32624974
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32624800

http://stackoverflow.com/q/21553557
tagged with: jdbc
upvote count: 6
has answer: http://stackoverflow.com/a/21553926
tagged with: java
answer count: 3
tagged with: oracle11g
has title: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
accepted answer: http://stackoverflow.com/a/21555172
has body: I have problem, when trying to connect to Oracle Database XE via listener: sqlplus system/my_password@XE I get the following error: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor I use Ubuntu 12.10 and Oracle Express Edition 11g. My main goal to connect java + oracle db with jdbc, but there i get the same error. Here are my listener.ora # listener.ora Network Configuration File: SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/xe) (PROGRAM = extproc) ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE)) (ADDRESS = (PROTOCOL = TCP)(HOST = watson)(PORT = 1521)) ) ) DEFAULT_SERVICE_LISTENER = (XE) and tnsnames.ora # tnsnames.ora Network Configuration File: XE = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = watson)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE) ) ) EXTPROC_CONNECTION_DATA = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE)) ) (CONNECT_DATA = (SID = PLSExtProc) (PRESENTATION = RO) ) ) and lsnrctl service LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 04-FEB-2014 17:01:44 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE))) Services Summary... Service "PLSExtProc" has 1 instance(s). Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 LOCAL SERVER The command completed successfully
has comment: http://stackoverflow.com/comment/32551469
score: 6
type: AnsweredQuestion
downvote count: 0
possible better answer: http://stackoverflow.com/a/57507645
favorite count: 0
has answer: http://stackoverflow.com/a/57507645
type: Question
has answer: http://stackoverflow.com/a/21555172

pdfbox
tag name: pdfbox
tags question: http://stackoverflow.com/q/21577850
tags question: http://stackoverflow.com/q/21659463
tags question: http://stackoverflow.com/q/21612400
tags question: http://stackoverflow.com/q/21627937
type: Tag
tags question: http://stackoverflow.com/q/21561298

http://stackoverflow.com/a/32845575
score: 14
upvote count: 14
answers question: http://stackoverflow.com/q/21585892
has comment: http://stackoverflow.com/comment/66923969
has body: Although the answer by @Shrikanth solves it, this issue also arises with normal Date objects. Two possible solutions are given here: Make use of DateUtils.truncate (or even DateUtils.truncatedEquals) to compare the dates. This is something you could use in your equals method, or for normal Date objects directly in you assertEquals/assertTrue. assertEquals(DateUtils.truncate(date1,Calendar.SECOND), DateUtils.truncate(date2,Calendar.SECOND)); Don't check whether the dates are the same, but whether they are close enough to eachother (for JUnit test sake): assertTrue("Dates aren't close enough to each other!", Math.abs(date2.getTime() - date1.getTime()) &lt; 1000);
has comment: http://stackoverflow.com/comment/67350944
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/71989623

right-align
tags question: http://stackoverflow.com/q/21566712
tag name: right-align
type: Tag

http://stackoverflow.com/a/21600731
type: Answer
score: 5
has body: The selectPages() method is explained in chapter 6 of my book (see page 164). In the context of code snippet 6.3 and 6.11, it is used to reduce the number of pages being read by PdfReader for consumption by PdfStamper or PdfCopy. However, it can also be used to reorder pages. First allow me to explain the syntax. There are different flavors of the selectPages() method: You can pass a List&lt;Integer&gt; containing all the page numbers you want to keep. This list can consist of increasing page numbers, 1, 2, 3, 4,... If you change the order, for instance: 1, 3, 2, 4,... PdfReader will serve the pages in that changed order. You can also pass a String (which is what is done in your snippet) using the following syntax: [!][o][odd][e][even]start[-end] You can have multiple ranges separated by commas, and the ! modifier removes pages from what is already selected. The range changes are incremental; numbers are added or deleted as the range appears. The start or the end can be omitted; if you omit both, you need at least o (odd; selects all odd pages) or e (even; selects all even pages). In your case, we have: String.format("%d, 1-%d", n, n-1) Suppose we have a document with 10 pages, then n equals 10 and the result of the formatting operation is: "10, 1-9". In this case, PdfReader will present the last page as the first one, followed by pages 1 to 9. Now suppose that you have a TOC that starts on page 8, and you want to move this TOC to the first pages, then you need something like this: 8-10, 1-7, or if toc equals 8 and n equals 10: String.format("%d-%d, 1-%d", toc, n, toc -1) For more info about the format() method, see the API docs for String and the Format String syntax.
upvote count: 5
has comment: http://stackoverflow.com/comment/32639938
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21600040
has comment: http://stackoverflow.com/comment/32640037
answers question: http://stackoverflow.com/q/21600040
has comment: http://stackoverflow.com/comment/32634648
has comment: http://stackoverflow.com/comment/32634509

embedded-tomcat-7
type: Tag
tag name: embedded-tomcat-7
tags question: http://stackoverflow.com/q/21673480
tags question: http://stackoverflow.com/q/21550369
tags question: http://stackoverflow.com/q/21552913

http://stackoverflow.com/a/21567744
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21567468
score: 1
accepted answer of: http://stackoverflow.com/q/21567468
upvote count: 1
has body: The error is that you are checking if int i is divisible by 5 (i % 5), not numbers[i] (numbers[i] % 5). This way, your code prints: number 1 when i = 0, number 2 when i = 1, number 3 when i = 2, number 4 when i = 3, number 5 when i = 4, number 6 when i = 5 and finally prints line break. The correct code is: int[] numbers = new int[25]; for (int i = 0; i &lt; numbers.length; i++) { numbers[i]=i+1; System.out.print(numbers[i]); if (numbers[i] % 5 == 0 &amp;&amp; i &gt; 0) { System.out.println(); } else { System.out.print(","); } } The above code will print (as intended): 1,2,3,4,5 6,7,8,9,10 11,12,13,14,15 16,17,18,19,20 21,22,23,24,25

http://stackoverflow.com/comment/32491685
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21519634
has text: What is `insert` method, why are iterating for `size()` times? By the way you can do something like: `List<Integer> list = new ArrayList<Integer>(new TreeSet<Integer>(unsortedList));` cause `TreeSet` is an `SortedSet`.

http://stackoverflow.com/q/21583170
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32604194
has comment: http://stackoverflow.com/comment/32603688
upvote count: 1
accepted answer: http://stackoverflow.com/a/21591945
type: Question
score: 1
tagged with: java
tagged with: signal-processing
tagged with: casting
tagged with: arrays
downvote count: 0
has answer: http://stackoverflow.com/a/21583322
has comment: http://stackoverflow.com/comment/32608343
has body: I have a sound file that I am practicing phase vocoding on. I have converted the bytes of the file into a double[] and manipulated the wave form of that file through a Fast Fourier Transform and inverse Fast Fourier Transform. The issue is now I need to convert the byte[] back into a double. Here are some useful code fragments: How I converted the data in the first place: /** * Converts bytes from a TargetDataLine into a double[] allowing the information to be read. * NOTE: One byte is lost in the conversion so don't expect the arrays to be the same length! * @param bufferData The buffer read in from the target Data Line * @return the double[] that the buffer has been converted into. */ private static double[] bytesToDoubleArray(byte[] bufferData){ final int bytesRecorded = bufferData.length; final int bytesPerSample = getAudioFormat().getSampleSizeInBits()/8; final double amplification = 100.0; // choose a number as you like double[] micBufferData = new double[bytesRecorded - bytesPerSample + 1]; for (int index = 0, floatIndex = 0; index &lt; bytesRecorded - bytesPerSample + 1; index += bytesPerSample, floatIndex++) { double sample = 0; for (int b = 0; b &lt; bytesPerSample; b++) { int v = bufferData[index + b]; if (b &lt; bytesPerSample - 1 || bytesPerSample == 1) { v &amp;= 0xFF; } sample += v &lt;&lt; (b * 8); } double sample32 = amplification * (sample / 32768.0); micBufferData[floatIndex] = sample32; } return micBufferData; } and what I am doing to the data: public static byte[] shift(byte[] data, int factor){ double[] audioData = bytesToDoubleArray(data); audioData = Arrays.copyOf(audioData, roundToPowerOf2(audioData.length)); Complex[] transformed = FFT.fft(doubleToComplex(audioData)); transformed = shiftArray(transformed, 3); Complex[] reverted = FFT.ifft(transformed); for(int i = 0; i&lt;reverted.length; i++){ audioData[i] = reverted[i].re(); } return null;//How do I convert audioData[] back into a byte[]???? } Any ideas on how to remedy this problem? Any …
possible better answer: http://stackoverflow.com/a/21592159
favorite count: 0
has answer: http://stackoverflow.com/a/21592159
tagged with: fft
answer count: 3
has title: Java how do I convert a byte[] containing multiple doubles into a double[]
has comment: http://stackoverflow.com/comment/32604398
has answer: http://stackoverflow.com/a/21591945
has comment: http://stackoverflow.com/comment/32608277

http://stackoverflow.com/comment/32768187
has text: Do you basically want to get the file as a string, remove newlines, then output with a newline after every 12 chars?
comment on: http://stackoverflow.com/q/21672927
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21645572
tagged with: file
linked to: http://stackoverflow.com/q/7405173
type: Question
upvote count: 2
has answer: http://stackoverflow.com/a/21646578
accepted answer: http://stackoverflow.com/a/21646578
answer count: 1
tagged with: android-sdcard
tagged with: android
has comment: http://stackoverflow.com/comment/32712880
favorite count: 0
linked to: http://stackoverflow.com/q/21245196
tagged with: android-asynctask
downvote count: 0
has comment: http://stackoverflow.com/comment/32714678
has comment: http://stackoverflow.com/comment/32712994
score: 2
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32713268
has title: WipeOut All SdCard Files Programmatically
has body: I am trying to do a Task of Wipe Out all the files present in the external SdCard. I am not getting where my code is not working. These are my Files ... activity-main.xml <?xml version="1.0" encoding="utf-8"?> <TextView android:id="@+id/path" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <TextView android:id="@+id/file" android:layout_width="fill_parent" android:layout_height="wrap_content" /> WipeSdActivity.java package com.example.wipe_sd; import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.os.AsyncTask; import android.os.Bundle; import android.os.Environment; import android.util.Log; import android.view.Menu; import android.view.View; import android.widget.Button; import android.widget.TextView; public class WipeSDActivity extends Activity { private int mDeletedFiles = 0; private int mDeletedFolders = 0; private TextView mDirectoryTextView; private TextView mFileTextView; private List<String> mUndeleteableFiles; MyAsyncTask test; public Button btnwipe_sd; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_wipe_sd); btnwipe_sd = (Button)findViewById(R.id.wipe_button); test = new MyAsyncTask(); File[] arrayOfFile = new File[1]; arrayOfFile[0] = new File(Environment.getExternalStorageDirectory().getPath()); test.execute(arrayOfFile); btnwipe_sd.setOnClickListener(new View.OnClickListener() { public void onClick(View paramAnonymousView) { new AlertDialog.Builder(WipeSDActivity.this).setCancelable(true) .setMessage("This will attempt to wipe all directories and files on your SD card.") .setPositiveButton("WIPE", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).setNegativeButton("NO!", new DialogInterface.OnClickListener() { public void onClick(Dial…
linked to: http://stackoverflow.com/q/21694231
tagged with: java

http://stackoverflow.com/a/21618954
type: Answer
has body: Update: Timo has invalidated my original response by showing me how to do what I want WITHOUT having to replace the SQLQuery class. Here is his comment: query.getSQL(field1, field2, ... fieldN), getSQL is consistent with the other methods which also take the projection arguments at last I have removed my unnecessary class. Here is an example of using SQLQuery directly to get the SQL string WITHOUT executing the query (e.g., without using the list method): SQLQuery rquery = new SQLQuery(connection , dialect); // Use getSQL with projections rquery.from(qtable) .where(qtable.qfield1.eq("somevalue")); SQLBindings bindings = rquery.getSQL(qtable.qfield1, qtable.qfield2); // Get the SQL string from the SQLBindings System.out.println(bindings.getSql()); // Get the SQL parameters from the SQLBindings for the parameterized query System.out.println(bindings.getBindings()); This response answers how to use QueryDSL to build out a complete SQL query without actually executing the query. It does not address your additional requirements about "dynamic schemas" and "without domain objects"...
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/32696293
answers question: http://stackoverflow.com/q/21615956
has comment: http://stackoverflow.com/comment/32689656
has comment: http://stackoverflow.com/comment/32696694
has comment: http://stackoverflow.com/comment/32696063
upvote count: 1
has comment: http://stackoverflow.com/comment/32696661

http://stackoverflow.com/q/21552417
tagged with: java
linked to: http://stackoverflow.com/q/14371972
has answer: http://stackoverflow.com/a/21553012
type: Question
accepted answer: http://stackoverflow.com/a/21553012
answer count: 1
tagged with: user-interface
has body: I want to update my Swing Gui every 30 seconds, where some labels shall get new values from a DB connection. So far, I tried to create a new Gui everytime and dispose the old one, but this is no ellegant solution and did not work anyway. public class Gui extends JFrame { private boolean open; //setter, getter public Gui() { JPanel pane = new JPanel(new BorderLayout()); int numberOfRows = 9; int numberOfColumns = 2; pane.setLayout(new GridLayout(numberOfRows, numberOfColumns)); String wState; if(open){wState="Window open";} else{wState="Window closed";} JLabel windowState= new JLabel(wState); pane.add(windowState); new Timer(5000, new WindowState()).start(); } private class WindowState implements ActionListener { public void actionPerformed(ActionEvent e) { Gui g = new Gui(); g.setOpen(true); } I know it does not work like this but I hope it becomes clear what I want to do. The problem is that I cannot access the Gui elements in the actionPerformed() method. I simply want to update the windowState Label with the new Value retrieved in the actionPerformed() method.
has title: Access Gui in ActionListener Class to update it every x seconds with Timer
score: 0
has comment: http://stackoverflow.com/comment/32548793
tagged with: swing
type: AnsweredQuestion

http://stackoverflow.com/comment/32619094
has text: sorry i t was a typo. Of course, it doesn't work besides I put startActivity(intent); !
score: 0
comment on: http://stackoverflow.com/a/21591475
type: AnswerComment
type: Comment

http://stackoverflow.com/a/21585954
type: Answer
answers question: http://stackoverflow.com/q/21585728
has body: productCharge * .15 is not a statement, which is what switch expects there, so the compiler gives you a message saying as much. A good next step would be to check the syntax for the switch statement. Anyway, evaluating that expression does not achieve anything yet.
score: 0

http://stackoverflow.com/q/21658908
downvote count: 0
has comment: http://stackoverflow.com/comment/32736212
favorite count: 0
has body: I have lists of times that I take with a timer, if I rotate the screen they are deleted. I tried following code, but it crashes. I think there is a problem in the saving/restoring format. ArrayList&lt;Long&gt; timesList = new ArrayList&lt;Long&gt;(); // List of partial times in milliseconds /** Save state while screen orientation changes */ @Override public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); // Save UI state changes to the savedInstanceState. // This bundle will be passed to onCreate if the process is // killed and restarted. savedInstanceState.putSerializable("PartialTimes", timesList); } /** Restore state while screen orientation changes */ @Override public void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); // Restore UI state from the savedInstanceState. // This bundle has also been passed to onCreate. timesList = (ArrayList&lt;Long&gt;) savedInstanceState.getSerializable("PartialTimes"); }
has answer: http://stackoverflow.com/a/29430214
has answer: http://stackoverflow.com/a/21705842
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/3611843
tagged with: android
score: 2
upvote count: 2
tagged with: java
has comment: http://stackoverflow.com/comment/32736772
tagged with: screen
type: Question
has title: Android save and restore ArrayList <Long> while screen changes
tagged with: rotation
has comment: http://stackoverflow.com/comment/32736355
has comment: http://stackoverflow.com/comment/32737800
answer count: 2

http://stackoverflow.com/q/21539712
has answer: http://stackoverflow.com/a/76162892
tagged with: applet
tagged with: security
has comment: http://stackoverflow.com/comment/134336002
score: 0
tagged with: linux
has comment: http://stackoverflow.com/comment/32527775
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32527297
has body: I have an applet I am trying to run from localhost. However, I just updated the java client and now java blocks the applet from running because it is self-signed. This is apparently a new security update to Java 7 Update 51. I have found the following article talking about how to reduce security levels. However, the article only mentions how to change security levels in Windows/OS X. Does anyone know how I can change the security levels in Linux so that I can run my applet on my linux box?
tagged with: java
has title: Reducing java security settings
type: Question
answer count: 1

http://stackoverflow.com/comment/32625070
score: 0
has text: Thank you Biraj to respond my question. Is there any way to play videos with jw palyer in android
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21594611

http://stackoverflow.com/comment/32650638
comment on: http://stackoverflow.com/q/21609803
type: Comment
type: QuestionComment
score: 0
has text: Yes, sorry I didn't specify. I want to save the results to a file.

http://stackoverflow.com/comment/32702895
type: Comment
comment on: http://stackoverflow.com/a/21639109
has text: where and how did you change the settings?
score: 0
type: AnswerComment

http://stackoverflow.com/q/21645332
tagged with: java
type: Question
score: 0
has answer: http://stackoverflow.com/a/21645368
accepted answer: http://stackoverflow.com/a/21645368
answer count: 1
has comment: http://stackoverflow.com/comment/32712470
has comment: http://stackoverflow.com/comment/32712612
tagged with: mysql
has body: I'm new to MySQL, I have only worked with NoSQL databases before. I have to test MySQL performance, by querying a table, every time increasing complexity of the query. For instance, table is comprised of these columns: Timestamp, A922, A923, A924, ... , A933 Timestamp is a DATETIME type, the others are INT. How can I do in Java to make a query like this without writing every query but using instead a loop? SELECT Timestamp, A922 FROM Table SELECT Timestamp, A922, A923 FROM Table SELECT Timestamp, A922, A923, A924 FROM Table
has title: Doing MySQL queries increasing each time number of columns retrieved
type: AnsweredQuestion

http://stackoverflow.com/q/21633555
has answer: http://stackoverflow.com/a/21639553
linked to: http://stackoverflow.com/q/71281032
favorite count: 0
has comment: http://stackoverflow.com/comment/42767209
upvote count: 92
downvote count: 0
tagged with: spring
has answer: http://stackoverflow.com/a/70953671
has comment: http://stackoverflow.com/comment/49096937
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/61752277
tagged with: java
tagged with: spring-java-config
type: Question
score: 92
linked to: http://stackoverflow.com/q/30502589
has title: How To Inject AuthenticationManager using Java Configuration in a Custom Filter
accepted answer: http://stackoverflow.com/a/21639553
tagged with: spring-security
has body: I'm using Spring Security 3.2 and Spring 4.0.1 I'm working on converting an xml config into a Java config. When I annotate AuthenticationManager with @Autowired in my Filter, I'm getting an exception Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.security.authentication.AuthenticationManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {} I've tried injecting AuthenticationManagerFactoryBean but that also fails with a similar exception. Here is the XML configuration I'm working from &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans ...&gt; &lt;security:authentication-manager id="authenticationManager"&gt; &lt;security:authentication-provider user-service-ref="userDao"&gt; &lt;security:password-encoder ref="passwordEncoder"/&gt; &lt;/security:authentication-provider&gt; &lt;/security:authentication-manager&gt; &lt;security:http realm="Protected API" use-expressions="true" auto-config="false" create-session="stateless" entry-point-ref="unauthorizedEntryPoint" authentication-manager-ref="authenticationManager"&gt; &lt;security:access-denied-handler ref="accessDeniedHandler"/&gt; &lt;security:custom-filter ref="tokenAuthenticationProcessingFilter" position="FORM_LOGIN_FILTER"/&gt; &lt;security:custom-filter ref="tokenFilter" position="REMEMBER_ME_FILTER"/&gt; &lt;security:intercept-url method="GET" pattern="/rest/news/**" access="hasRole('user')"/&gt; &lt;security:intercept-url method="PUT" pattern="/rest/news/**" access="hasRole('admin')"/&gt; &lt;security:intercept-url method="POST" pattern="/rest/news/**" access="hasRole('admin')"/&gt; &lt;security:intercept-url method="DELETE" pattern="/rest/news/**" access="hasRole('admin')"/&gt; &lt;/security:http&gt; &lt;bean class="com.unsubcentral.security.TokenAuthenticationProcessingFilter" id="tokenAuthenticationProcessingFilter"&gt; &lt;constructor-arg value=…
answer count: 3
possible better answer: http://stackoverflow.com/a/61752277

http://stackoverflow.com/q/21636459
answer count: 1
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/32697193
has comment: http://stackoverflow.com/comment/32697027
has comment: http://stackoverflow.com/comment/32697522
has comment: http://stackoverflow.com/comment/32697240
tagged with: spring
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21638140
tagged with: java
score: 7
has comment: http://stackoverflow.com/comment/32697329
upvote count: 7
has comment: http://stackoverflow.com/comment/32697148
has comment: http://stackoverflow.com/comment/32697119
type: Question
has body: As you know @RequestMapping get used to intercept a HttpServletRequest. I want to know how @Controller @RequestMapping together can bind a request coming from a client to a specific method inside a java class ? I want to write a similar java application to do the same functionality, Imagine We have a class like this: @Actor public class JavaForever { @Department(value="IT") public void departmentIT(){...} @Department(value="Physic") public void departmentPhysic(){...} } And a StudentBean class : public class StudentBean { private String department; private Integer age; //Other class variable //Getters &amp; Setters } and finally we have a Test class like this: public class TestApplication { //getStudentFromDatabaseMethod() implementation here public static void main(String[] agrs){ List&lt;StudentBean&gt; allStudents = new TestApplication().getStudentFromDatabaseMethod(); //other codes } } As you see getStudentFromDatabaseMethod() returns List&lt; StudentBean&gt;, now the question is how we can force this method to get intercept with our @Department annotation which resides in JavaForever class before it returns any value ... how we can do this ???
has comment: http://stackoverflow.com/comment/32697587
tagged with: aop
accepted answer: http://stackoverflow.com/a/21638140
has title: How does Spring's @RequestMapping work?
has comment: http://stackoverflow.com/comment/32700797

http://stackoverflow.com/q/21547290
possible better answer: http://stackoverflow.com/a/21547662
downvote count: 0
has title: put tabs in the bottom of screen
tagged with: android-tabs
type: AnsweredQuestion
tagged with: android-fragments
tagged with: java
has answer: http://stackoverflow.com/a/22347973
score: 15
has answer: http://stackoverflow.com/a/21547662
type: Question
accepted answer: http://stackoverflow.com/a/23333615
linked to: http://stackoverflow.com/q/2677698
has body: I want to put tabs at the bottom part of my screen . For this purpose I have the following code : package info.androidhive.tabsswipe; import info.androidhive.tabsswipe.adapter.TabsPagerAdapter; import android.app.ActionBar; import android.app.ActionBar.Tab; import android.app.FragmentTransaction; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.view.ViewPager; public class MainActivity extends FragmentActivity implements ActionBar.TabListener { private ViewPager viewPager; private TabsPagerAdapter mAdapter; private ActionBar actionBar; // Tab titles private String[] tabs = { "Top Rated", "Games", "Movies" }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Initilization viewPager = (ViewPager) findViewById(R.id.pager); actionBar = getActionBar(); mAdapter = new TabsPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(mAdapter) ; actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowTitleEnabled(false); // Adding Tabs for (String tab_name : tabs) { actionBar.addTab(actionBar.newTab().setText(tab_name) .setTabListener(this)); } /** * on swiping the viewpager make respective tab selected * */ viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { // on changing the page // make respected tab selected actionBar.setSelectedNavigationItem(position); } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }); } @Override public void onTabReselected(Tab tab, FragmentTransaction ft) { } @Override public void onTabSelected(Tab tab, FragmentTransaction ft) { // on tab selected // show respected fragment view viewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(Tab tab, Fr…
favorite count: 0
has answer: http://stackoverflow.com/a/23150606
has answer: http://stackoverflow.com/a/23333615
has answer: http://stackoverflow.com/a/21547635
answer count: 5
tagged with: android
linked to: http://stackoverflow.com/q/23133881
upvote count: 15

http://stackoverflow.com/comment/32647985
has text: Thanks for the reply. I made an update to my post, including your answer. Please have a look.
type: AnswerComment
type: Comment
score: 0
comment on: http://stackoverflow.com/a/21580022

http://stackoverflow.com/comment/32568624
type: Comment
comment on: http://stackoverflow.com/a/21563085
score: 0
type: AnswerComment
has text: But I want it to trigger the if statement if the number is not found. My if statement is if (inList(in,numbersArray))

http://stackoverflow.com/a/21634770
accepted answer of: http://stackoverflow.com/q/21634469
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/32768018
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21634469
has body: I use object wrappers for both variables and getters/setters and it handles null correctly for me. If your DB columns allow nulls, I recommend using object wrappers all the way.
type: Answer
has comment: http://stackoverflow.com/comment/32765406

http://stackoverflow.com/tag/xml
tags question: http://stackoverflow.com/q/21612210
tags question: http://stackoverflow.com/q/21552592
tags question: http://stackoverflow.com/q/21637997
tags question: http://stackoverflow.com/q/21532656
tags question: http://stackoverflow.com/q/21675512
tags question: http://stackoverflow.com/q/21515291
tags question: http://stackoverflow.com/q/21611496
tags question: http://stackoverflow.com/q/21532631
tags question: http://stackoverflow.com/q/21602069
tags question: http://stackoverflow.com/q/21525135
tags question: http://stackoverflow.com/q/21620007
tags question: http://stackoverflow.com/q/21518607
tags question: http://stackoverflow.com/q/21600781
tags question: http://stackoverflow.com/q/21634315
tags question: http://stackoverflow.com/q/21523192
tags question: http://stackoverflow.com/q/21665009
tags question: http://stackoverflow.com/q/21537458
tags question: http://stackoverflow.com/q/21562135
tags question: http://stackoverflow.com/q/21622138
tags question: http://stackoverflow.com/q/21638818
type: Tag
tags question: http://stackoverflow.com/q/21553731
tags question: http://stackoverflow.com/q/21570992
tags question: http://stackoverflow.com/q/21661304
tags question: http://stackoverflow.com/q/21544576
tags question: http://stackoverflow.com/q/21614684
tags question: http://stackoverflow.com/q/21576233
tags question: http://stackoverflow.com/q/21535648
tags question: http://stackoverflow.com/q/21596080
tags question: http://stackoverflow.com/q/21597883
tags question: http://stackoverflow.com/q/21556883
tags question: http://stackoverflow.com/q/21589983
tags question: http://stackoverflow.com/q/21623914
tags question: http://stackoverflow.com/q/21617326
tags question: http://stackoverflow.com/q/21528464
tags question: http://stackoverflow.com/q/21552322
tags question: http://stackoverflow.com/q/21672499
tags question: http://stackoverflow.com/q/21538998
tags question: http://stackoverflow.com/q/21632403
tags question: http://stackoverflow.com/q/21647336
tags question: http://stackoverflow.com/q/21579503
tags question: http://stackoverflow.com/q/21608250
tags question: http://stackoverflow.com/q/21574154
tags question: http://stackoverflow.com/q/21533702
tags question: http://stackoverflow.com/q/21573636
tags question: http://stackoverflow.com/q/21553798
tags question: http://stackoverflow.com/q/21656440
tags question: http://stackoverflow.com/q/21633797
tags question: http://stackoverflow.com/q/21550546
tags question: http://stackoverflow.com/q/21588619
tags question: http://stackoverflow.com/q/21622917
tags question: http://stackoverflow.com/q/21527335
tags question: http://stackoverflow.com/q/21611458
tags question: http://stackoverflow.com/q/21561129
tags question: http://stackoverflow.com/q/21599594
tags question: http://stackoverflow.com/q/21525606
tags question: http://stackoverflow.com/q/21528261
tags question: http://stackoverflow.com/q/21562502
tags question: http://stackoverflow.com/q/21610701
tags question: http://stackoverflow.com/q/21526958
tags question: http://stackoverflow.com/q/21629089
tags question: http://stackoverflow.com/q/21571227
tags question: http://stackoverflow.com/q/21592731
tags question: http://stackoverflow.com/q/21595021
tags question: http://stackoverflow.com/q/21538405
tags question: http://stackoverflow.com/q/21648994
tags question: http://stackoverflow.com/q/21569127
tag name: xml
tags question: http://stackoverflow.com/q/21577035
tags question: http://stackoverflow.com/q/21586396
tags question: http://stackoverflow.com/q/21676957
tags question: http://stackoverflow.com/q/21583875
tags question: http://stackoverflow.com/q/21647834
tags question: http://stackoverflow.com/q/21580269
tags question: http://stackoverflow.com/q/21640935
tags question: http://stackoverflow.com/q/21520519
tags question: http://stackoverflow.com/q/21673668
tags question: http://stackoverflow.com/q/21625744
tags question: http://stackoverflow.com/q/21525260
tags question: http://stackoverflow.com/q/21630363

http://stackoverflow.com/a/21667309
downvote count: 0
score: 4
upvote count: 4
has body: Your code does not respect the layout managers that it is using -- BorderLayout. When you add a component to a BorderLayout using container without specifying position, it is placed by default BorderLayout.CENTER and covers anything added previously. Solution: read up on the layout managers including BorderLayout to see how to use them. Also, you're probably better off not adding two DragMyIcon objects, but rather changing DragMyIcon so that it allows for multiple JLabels.
answers question: http://stackoverflow.com/q/21667291
type: Answer

http://stackoverflow.com/comment/32484138
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21515544
type: AnswerComment
has text: Its is a sampled code made for simplicity reasons and u have not seen how my private fields are called. No query generated, hibernates breaks off, when I generate a delete query myself using id everything is fine. I actually want to prohibit any automated cascasion, which settings should i use then parent = persist, child = nothing?

http://stackoverflow.com/comment/32625380
type: QuestionComment
comment on: http://stackoverflow.com/q/21595297
has text: movie_borr is not selected in the query, is just part of the condition. add it to the select clause, if you need it (though you already send it as a param...)
score: 4
type: Comment

http://stackoverflow.com/comment/32484646
comment on: http://stackoverflow.com/q/21515631
type: Comment
type: QuestionComment
has text: Fallow up question. Why not?
score: 0

http://stackoverflow.com/q/21663120
answer count: 1
upvote count: 9
has title: deserialize two different date formats with GSON
favorite count: 0
downvote count: 0
type: AnsweredQuestion
has body: Im consuming a clients JSON API using googles GSON lib to handle serialisation/deserialization. This is proving to be problematic as within the API's json entities there are a number of date formats scattered about the API. Some examples of this are as follows... "2014-02-09" "15/10/1976" "2014-02-09T07:32:41+00:00" I have no control over the API as it developerd by the client and is already being consumed by other parties. It seems that I can setup GSON to work with a single date format but I cant get it parse the dates on a per field basis. I would have expected GOSN to provide an annotation for this but I cant seem to find one. Any ideas on ho to set this up anyone?
accepted answer: http://stackoverflow.com/a/21663438
tagged with: java
tagged with: http://stackoverflow.com/tag/json
tagged with: gson
has comment: http://stackoverflow.com/comment/32746151
type: Question
score: 9
has answer: http://stackoverflow.com/a/21663438

http://stackoverflow.com/q/21577949
has comment: http://stackoverflow.com/comment/32594342
type: UnansweredQuestion
tagged with: classpath
has answer: http://stackoverflow.com/a/69409997
tagged with: resources
has answer: http://stackoverflow.com/a/21578168
has body: I have a jar containing the main class of a project. This depends on several other jars that reside in a lib directory. One class of such a dependend jar loads a ressource "/Data/foo/bar/file.txt". But loading this file as ressource leads to null. Here is the directory structure: ./main.jar ./lib/lib1.jar ./lib/lib2.jar ./lib/lib3.jar ./lib/runtimedata/Data/foo/bar/file.txt This is the classpath of the manifest.mf of the main.jar: lib/lib1.jar lib/lib2.jar lib/lib3.jar lib/runtimedata I start the application via java -jar main.jar The lib2.jar contains a class that tries to load the file with ThatClass.class.getResource("/Data/foo/bar/file.txt"); But that happens to be null. Why? lib/runtimedata is in the classpath. I even tried to put the Data directory into lib/lib/runtimedata, in case the path is relative to the jar file containing the loading class. But that doesn't help. What am I doing wrong here? EDIT: Running the application with java -cp main.jar:lib/*.jar:lib/runtimedata my.package.Main works correctly. EDIT 2: I cannot change that lib that does the resource loading. I am only using that lib. The only things I can change is the main.jar the classpath and the command line.
tagged with: java
has title: class.getResource() is null though it is in classpath
has comment: http://stackoverflow.com/comment/32594457
type: Question
score: 0
answer count: 2
tagged with: null
tagged with: jar

http://stackoverflow.com/comment/32535987
comment on: http://stackoverflow.com/q/21545096
score: 0
type: Comment
type: QuestionComment
has text: I will not have "insert" queries in the property file. Only the one time activity like creating table or database. I will run this in different environment when it is needed.

http://stackoverflow.com/q/21672833
has body: public class PtpReceiver { public static void main(String[] args) { // TODO Auto-generated method stub try { MQEnvironment.hostname = "192.168.120.28:1415"; MQEnvironment.channel = "SFMS.TO.CBS"; MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES); System.out.println("Q manager"); MQQueueManager qMgr = new MQQueueManager("GSCBBRQM"); System.out.println("Q manager11"); } catch (MQException ex) { System.out.println(ex.completionCode+ ex.reasonCode); } } } I got the error following: MQJE001: Completion Code '2', Reason '2538'. Can any one help me for solve this error
type: Question
score: 4
has answer: http://stackoverflow.com/a/75866360
has title: MQJE001: Completion Code '2', Reason '2538'
favorite count: 0
tagged with: ibm-mq
has answer: http://stackoverflow.com/a/69378042
possible better answer: http://stackoverflow.com/a/21685317
upvote count: 4
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21685317
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/21688247
accepted answer: http://stackoverflow.com/a/21688247

http://stackoverflow.com/comment/32498230
score: 0
type: Comment
type: QuestionComment
has text: @christopher if arraylist is empty no iteration which happen
comment on: http://stackoverflow.com/q/21523853

http://stackoverflow.com/comment/32523140
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/21536544
has text: I started going the sort direction if for no other reason than to have a list that **I** could read. There's a couple hundred courses total, but about a dozen or so for any single room. Right now I'm using a sorted ArrayList that only contains the courses I care about. My issue is that a course will run 11-12, then another from 12:15-2, etc. I'm having trouble coming up with the logic that picks up on the gaps: having to compare an end time to the next start time, and then store that gap somehow.

http://stackoverflow.com/q/21603291
tagged with: rmi
tagged with: java
has comment: http://stackoverflow.com/comment/32672724
type: Question
tagged with: legacy
score: 0
has comment: http://stackoverflow.com/comment/32639952
upvote count: 1
answer count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/32640171
favorite count: 0
has title: Killing a Thread doesn't work on WindowsXP using JRE 1.6_45
has comment: http://stackoverflow.com/comment/32640630
has body: I Have a Thread which should be run synchronously to the SWT GUI Thread, but with a timeout that kills the thread if it isn't done after 10 seconds. EDIT: I am required to remain compatible with Java 1.4. Thread: private boolean isFinished; (...) isFinished = false; Thread t = new Thread ("getShellsThread") { public void run() { try { logger.debug("aquirerootcont SWT entered - " + Thread.currentThread().toString()); (...) } finally { isFinished = true; logger.debug ("hasShells is Finished!"); } } } Timeout code: long startTime = System.currentTimeMillis(); long timeWaited; ((Display)displays.get(i)).asyncExec (t); while(!isFinished){ timeWaited = System.currentTimeMillis() - startTime; logger.debug("aquireRootContainer: timeWaited: " + timeWaited); if (timeWaited &gt; 1000) { logger.debug(t +" Name: " + t.getName()+" took to long and will be destroyed!"); t.interrupt (); shell = null; break; } } This code is working for Windows 7 and Windows 8 with JRE 1.6 and 1.7 as well as IBM JREs. However, for Windows XP, while IBM JRE works just fine, JRE 1.6_45 will not. The Logs on XP 1.6_45 are showing that the Thread does nothing and after 10 seconds says: Thread[getShellsThread,10,RMI Runtime] Name: getShellsThread took to long and will be destroyed! Windows Taskmgr says that the rmiregistry.exe has been killed. Why does this code kill the RMI on one particular system? Any clues would be great! Due to required backward compatibility, most of the Methods that are used nowadays for timeout threads are unfortunately not available.
tagged with: multithreading
has answer: http://stackoverflow.com/a/21604495
accepted answer: http://stackoverflow.com/a/21604495
type: AnsweredQuestion

http://stackoverflow.com/comment/32725192
comment on: http://stackoverflow.com/q/21652551
type: Comment
type: QuestionComment
score: 1
has text: _But I didn´t found any thing about this._ Read _all_ of [this](http://docs.oracle.com/javase/tutorial/essential/io/) and _all_ of [this](http://docs.oracle.com/javase/tutorial/collections/implementations/list.html).

http://stackoverflow.com/comment/35288537
comment on: http://stackoverflow.com/q/21618953
has text: I am having the exact same issue with sonar
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32753558
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21664282
has text: I mean xstream dependency jars.
type: AnswerComment

http://stackoverflow.com/a/21677063
type: Answer
has comment: http://stackoverflow.com/comment/32770737
has comment: http://stackoverflow.com/comment/32768057
has comment: http://stackoverflow.com/comment/32768108
answers question: http://stackoverflow.com/q/21676460
has comment: http://stackoverflow.com/comment/32768231
score: 0
has comment: http://stackoverflow.com/comment/32768286
has body: Use this below code in your onPostExecute method. if (pDialog!= null) { pDialog.dismiss(); pDialog= null; } So your method will look something like this. protected void onPostExecute(String file_url) { // dismiss the dialog after getting all products Utils.dismissProgressDialog(); if (pDialog!= null) { pDialog.dismiss(); pDialog= null; } // updating UI from Background Thread runOnUiThread(new Runnable() { public void run() { /** * Updating parsed JSON data into ListView * */ ListAdapter adapter = new SimpleAdapter( AllVenuesActivity.this, venuesList, R.layout.list_item, new String[] { TAG_VENUE_ID, TAG_VENUE_NAME}, new int[] { R.id.Venue_ID, R.id.Venue_Name }); // updating listview setListAdapter(adapter); } }); }

http://stackoverflow.com/a/21516877
downvote count: 0
has comment: http://stackoverflow.com/comment/32505423
has comment: http://stackoverflow.com/comment/32486647
has body: 7/100/12 is approximately 0.00583333333, not 0.005833. When you use %f you see only 6 digits after the decimal point by default.
has comment: http://stackoverflow.com/comment/32486701
has comment: http://stackoverflow.com/comment/32486885
score: 6
type: Answer
upvote count: 6
has comment: http://stackoverflow.com/comment/32486932
answers question: http://stackoverflow.com/q/21516811
has comment: http://stackoverflow.com/comment/32486816
has comment: http://stackoverflow.com/comment/32486741

http://stackoverflow.com/comment/32737564
type: Comment
type: QuestionComment
has text: @Jugadu I just put the right image path but it's still not appearing.
comment on: http://stackoverflow.com/q/21650420
score: 0

http://stackoverflow.com/a/21647006
type: Answer
answers question: http://stackoverflow.com/q/21645838
score: 0
has body: make emaili var a static so you can call it by the name of the class static String emaili=null; String email =db.emaili;

http://stackoverflow.com/q/21566449
tagged with: prepared-statement
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21566481
type: Question
tagged with: jdbc
possible better answer: http://stackoverflow.com/a/21566480
has body: Well, my question concisely is "When I wrote the ? in place of the table name it gave no action " like here, suppose I have.. String full = "update ? set name = ? where id = ?"; but when I remove the first ? and type the table name "Everything goes perfect" ... Any suggestions ?
has answer: http://stackoverflow.com/a/21566480
has title: Issue with Prepared Statement when using "?"
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/21566481
tagged with: java
tagged with: mysql

http://stackoverflow.com/a/42025623
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21625059
has body: add a cascade for update. will solve the issue if foreign keys are involved.

http://stackoverflow.com/comment/111820701
comment on: http://stackoverflow.com/a/63230697
type: AnswerComment
has text: Welcome to Stack Overflow. Code-only answers are discouraged on Stack Overflow because they don't explain how it solves the problem. Please edit your answer to explain what this code does, how it answers the question and how it improves on the accepted answer, so that it is useful to the OP as well as other users also with similar issues.
type: Comment
score: 2

http://stackoverflow.com/a/25191932
has comment: http://stackoverflow.com/comment/78477839
type: Answer
has body: You might have found the answer already, but in case you didn't... You should be able to use the scope parameter of the @JsonIdentityInfo for that, i.e., @JsonIdentityInfo(scope=Foo.class, property="id", generator=ObjectIdGenerators.PropertyGenerator.class) public class Foo { ... } and @JsonIdentityInfo(scope=Bar.class, property="id", generator=ObjectIdGenerators.PropertyGenerator.class) public class Bar { ... }
accepted answer of: http://stackoverflow.com/q/21550546
upvote count: 10
answers question: http://stackoverflow.com/q/21550546
type: AcceptedAnswer
downvote count: 0
score: 10

http://stackoverflow.com/comment/32605956
score: 0
comment on: http://stackoverflow.com/q/21584266
has text: This is not a code issue as it runs fine on another developers machine
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32638716
type: Comment
type: QuestionComment
has text: @Reimeus please check i edited above
comment on: http://stackoverflow.com/q/21603085
score: 0

http://stackoverflow.com/q/21576455
has answer: http://stackoverflow.com/a/21653810
answer count: 2
has title: How do you add text to JTextArea? (console simulation)
upvote count: 0
score: -6
tagged with: console
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21576523
has body: How does one add text/commands (like in console) into JTextArea? Or, more specifically, how can I add a JTextArea as console in my FTP program and add commands like C:\tmp\ -list with non-editable text added earlier?
downvote count: 6
tagged with: java
tagged with: swing
type: Question
tagged with: jtextarea

http://stackoverflow.com/a/21546141
downvote count: 3
type: Answer
has body: As far as efficiency is concerned you may use StringBuilder where you have multiple operations on one string such as substring then, finding index, then substring etc etc. Where cleanliness/efficiency is concerned, StringUtils (Apache Commons Lang) can be used. Hope it helps.
upvote count: 2
score: -1
answers question: http://stackoverflow.com/q/21545933

http://stackoverflow.com/a/21547700
has comment: http://stackoverflow.com/comment/32540327
downvote count: 0
answers question: http://stackoverflow.com/q/21547537
type: Answer
has body: You need a way to remember which characters you encountered so far. You can store them in a Set, like so: public static int diff(String str) { Set&lt;Character&gt; chars = new HashSet&lt;Character&gt;(); for (int i = 0; i &lt; str.length() - 1; i++) { char ch = str.charAt(i); if (!chars.contains(ch)) { chars.add(ch); } } return chars.size(); }
score: 1
upvote count: 1

http://stackoverflow.com/comment/32644126
has text: String s = Arrays.toString(byteArray); then convert 's' to date... I recommend jodatime libraries. Or you can use Calendar class
score: 0
comment on: http://stackoverflow.com/q/21606180
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21581247
has comment: http://stackoverflow.com/comment/32623525
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32631264
answer count: 0
tagged with: screenshot
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/32600313
tagged with: jpanel
tagged with: eclipse
type: Question
has comment: http://stackoverflow.com/comment/32625717
has body: How do I print the screenshot I took from the application using some codes and have it printed? I know there's a method to print jTable but I want to print the whole JPanel, excluding the JFrame around it if possible :D
tagged with: printing
has title: How to print out JPanel of Java Swing in Eclipse?

http://stackoverflow.com/a/21607216
has comment: http://stackoverflow.com/comment/32680083
answers question: http://stackoverflow.com/q/21603046
has comment: http://stackoverflow.com/comment/32685128
has comment: http://stackoverflow.com/comment/32681319
score: 0
has comment: http://stackoverflow.com/comment/32669054
type: Answer
has body: I believe the syntax you're looking for is: war { from 'src/main/webapp/files' into 'files' } This will copy everything from src/main/webapp/files into a subdirectory called files at the root of your WAR file (eg. my-app.war/files) I had a lot of interesting issues with Gradle's war task and copying, so if this doesn't work, I can look up what other methods I've used.

http://stackoverflow.com/comment/32582905
type: QuestionComment
score: 0
has text: Redis has no search feature. can I say like "select * from photos where ownerid=1000" to get specific photo set with all needed fields ?
type: Comment
comment on: http://stackoverflow.com/q/21556898

http://stackoverflow.com/q/21596262
has title: What is dereferencing possible null pointer?
tagged with: dereference
tagged with: java
answer count: 3
accepted answer: http://stackoverflow.com/a/21596303
downvote count: 0
favorite count: 0
tagged with: nullpointerexception
has body: I am making a program for SFTP in NetBeans. Some part of My code: com.jcraft.jsch.Session sessionTarget = null; com.jcraft.jsch.ChannelSftp channelTarget = null; try { sessionTarget = jsch.getSession(backupUser, backupHost, backupPort); sessionTarget.setPassword(backupPassword); sessionTarget.setConfig("StrictHostKeyChecking", "no"); sessionTarget.connect(); channelTarget = (ChannelSftp) sessionTarget.openChannel("sftp"); channelTarget.connect(); System.out.println("Target Channel Connected"); } catch (JSchException e) { System.out.println("Error Occured ======== Connection not estabilished"); log.error("Error Occured ======== Connection not estabilished", e); } finally { channelTarget.exit(); // Warning : dereferencing possible null pointer channelTarget.disconnect(); // Warning : dereferencing possible null pointer sessionTarget.disconnect(); // Warning : dereferencing possible null pointer } I'm getting warning dereferencing possible null pointer, how can I resolve these warnings??? Where I can disconnect my Session and Channel???
possible better answer: http://stackoverflow.com/a/21596293
has answer: http://stackoverflow.com/a/21596318
upvote count: 16
has answer: http://stackoverflow.com/a/21596293
type: AnsweredQuestion
tagged with: netbeans
has answer: http://stackoverflow.com/a/21596303
score: 16
type: Question

http://stackoverflow.com/comment/32686128
comment on: http://stackoverflow.com/q/21629926
score: 0
has text: Did you declare a `ContextLoaderListener`?
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/32502955
has text: @Rokas here's answer from blackbelt http://stackoverflow.com/questions/16752073/how-do-i-return-a-boolean-from-asynctask
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21526538

http://stackoverflow.com/comment/32584371
type: Comment
score: 1
comment on: http://stackoverflow.com/q/21572202
type: QuestionComment
has text: Ask the right questions and show us, what you have done so far!

http://stackoverflow.com/q/21676957
favorite count: 0
tagged with: http://stackoverflow.com/tag/xml
has answer: http://stackoverflow.com/a/21677243
upvote count: 1
has comment: http://stackoverflow.com/comment/32767326
possible better answer: http://stackoverflow.com/a/21677243
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21677501
score: 1
tagged with: java
tagged with: eclipse
has body: Okay, sorry for asking this question. I have no idea how to solve this problem. I am creating a new project in eclipse, put some XML files in res/layout folder, and then drag an drop existing java files to src folder. I tried to generate R.java by cleaning the project and then these error messages appear: [2014-02-10 18:28:01 - EventPlanner] W/ResourceType( 7228): ResXMLTree_node size 0xffffffff or headerSize 0xffff is not on an integer boundary. [2014-02-10 18:28:01 - EventPlanner] E:\Andika\workspaces\EventPlanner\res\layout\activities_list.xml:6: error: Error: No resource found that matches the given name (at 'id' with value '@id/activity_id'). [2014-02-10 18:28:01 - EventPlanner] E:\Andika\workspaces\EventPlanner\res\layout\activities_list.xml:7: error: Error: No resource found that matches the given name (at 'id' with value '@id/chk_box'). [2014-02-10 18:28:01 - EventPlanner] E:\Andika\workspaces\EventPlanner\res\layout\activities_list.xml:10: error: Error: No resource found that matches the given name (at 'id' with value '@id/res_text'). ..... And R.java file wasn't generated. I have tried to close the eclipse and then re open again but it doesn't solve my problem. Did I miss something? Thank you Edit: this is one of my XML layout <?xml version="1.0" encoding="utf-8"?> <ImageView android:layout_gravity="center" android:id="@id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_action_person" /> <ImageView android:layout_gravity="center" android:id="@id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_action_secure" /> <requestFocus /> <TextView android:textColor="@color/BlueDefault" android:id="@id/TextView01" android:paddingLeft="10.0dip" android:paddingRight="10.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Login as" /> <Spinner android:entries="@array/account_type" android:id="@id/spinner1" …
type: Question
tagged with: r.java-file
downvote count: 0
has comment: http://stackoverflow.com/comment/32767650
has answer: http://stackoverflow.com/a/23355031
has title: Error When Adding XML Files to Android Project in Eclipse
has comment: http://stackoverflow.com/comment/32767412
accepted answer: http://stackoverflow.com/a/21677501
answer count: 3
tagged with: android

http://stackoverflow.com/q/21568473
upvote count: 1
has body: so what I am trying to do is : using an OnTouchListener I have to snap an ImageView into place in android when its dragged accross a certain location (another ImageView). The dragging is working, getting the location of the second imageview is fine, just when im trying to set its location, it always gets aligned under the location. How do I align it above the second imageview without using mImageView - 5, because then it wont work on every android screen that has more or less pixels. here is the code int[] locXY = new int[2]; mImageView5.getLocationOnScreen(locXY); int x1 = locXY[0]; int y1 = locXY[1]; int[] img3 = new int[2]; mImageView2.getLocationOnScreen(locXY); int x2 = locXY[0]; int y2 = locXY[1]; //if you reach the locating of imageview2 then snap into place if (x1 &lt;= x2 + 15 &amp;&amp; y1 &lt;= y2 + 20 &amp;&amp; y1 &gt;= y2 - 20 &amp;&amp; x1 &gt;= x2 - 15) { //do this tts.speak("You dont go there", TextToSpeech.QUEUE_FLUSH, null); mImageView5.setX(x2); mImageView3.setTop(y2 + 5); //this should be -5 because it will make it go up, but i dont want to use a - or a + mImageView5.setBottom(mImageView3.getTop()); } // end if
answer count: 1
downvote count: 0
has answer: http://stackoverflow.com/a/21581019
favorite count: 0
type: UnansweredQuestion
tagged with: android
tagged with: android-imageview
score: 1
tagged with: java
type: Question
has title: How to snap an android ImageView into a certain place on the screen?
tagged with: android-layout

http://stackoverflow.com/comment/32633773
type: Comment
type: QuestionComment
has text: Can you show us your `equals()` and `hashCode()` method? And also some more code surrounding that part.
comment on: http://stackoverflow.com/q/21600344
score: 0

http://stackoverflow.com/a/21573865
score: 0
type: AcceptedAnswer
type: Answer
answers question: http://stackoverflow.com/q/21573758
accepted answer of: http://stackoverflow.com/q/21573758
has body: You can declare your JLabel variable globally like your button and panel. and then instantiate it in createGUI and add it to your panel at a specific position to display it. Hope this helps

http://stackoverflow.com/comment/32581551
has text: Also, it's not obvious that you've shown us `getDescription` at all - which line is throwing the exception? (The stack trace talks about descriptions - all the code you've shown us is about "system functions" and we've no idea what the relationship between those two is.)
comment on: http://stackoverflow.com/q/21570417
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21582868
has answer: http://stackoverflow.com/a/21582953
has title: Printing out the number of lines a file contains
favorite count: 0
type: UnansweredQuestion
answer count: 4
has body: At the moment my code does nothing when i input a valid .txt file. I would like to print the number of lines the file contains. Could anyone tell me why nothing is currently happening? public class Task3 { public static void main(String[] args) throws FileNotFoundException { // instance variables int characterCount = 0; int wordCount = 0; int lineCount = 0; // create a Scanner object to read in file name from console input Scanner in = new Scanner(System.in); System.out.print("Please enter the file name: "); String filename = in.next(); File inputFile = new File(filename); // create a Scanner object to read the actual text file Scanner inFile = new Scanner(inputFile); int lines = 0; while (inFile.hasNextLine()) { // enter while loop if there is a complete line available in.nextLine(); lines++; // increase line counter variable } System.out.println(lines);
has answer: http://stackoverflow.com/a/21582967
tagged with: java
upvote count: 1
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/21583003
has answer: http://stackoverflow.com/a/21582958
score: 0

http://stackoverflow.com/q/21586660
type: Question
has body: Trying to setup a simple RMI server with SSL encryption. It's for a simple chat application that has a java server app and a java client app, however, I can't even get it working with a simple RMI example at the moment! The only way I can get it to work is if both the client &amp; server have both the same truststore &amp; keystore. To me though, this sounds incorrect as it means each client has the server's private key too.. I followed this guide to create the trust/keystores. I first tried generating a keystore &amp; truststore and just running the server with the keystore &amp; the client with the truststore. That didn't work so I then generated a pair for each and loaded as shown in the code below. It think I might be missing something obvious somewhere just can't for the life of my figure out what I'm doing wrong. I currently have the following, but when running the server I get the errors below: Error: Server exception: java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is: 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 java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is: 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 at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source) at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source) at sun.rmi.server.UnicastRef.newCall(Unknown Source) at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source) at Server.main(Server.java:38) Hello.java import java.rmi.Remote; import java.rmi.RemoteException; public interface Hello extends Remote { String sayHello() throws RemoteE…
has answer: http://stackoverflow.com/a/21588835
answer count: 1
favorite count: 0
upvote count: 8
tagged with: keystore
has title: Simple RMI Server with SSL
tagged with: public-key-encryption
accepted answer: http://stackoverflow.com/a/21588835
downvote count: 1
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/54284021
tagged with: rmi
score: 7
tagged with: java
tagged with: ssl

http://stackoverflow.com/q/21586690
has answer: http://stackoverflow.com/a/21586790
tagged with: data-structures
has answer: http://stackoverflow.com/a/21587059
has title: duplicate key value pairs
has comment: http://stackoverflow.com/comment/32612288
type: Question
upvote count: 4
has answer: http://stackoverflow.com/a/21586818
has answer: http://stackoverflow.com/a/21586801
has comment: http://stackoverflow.com/comment/32612211
duplicate of: http://stackoverflow.com/q/1062960
has comment: http://stackoverflow.com/comment/32611065
downvote count: 0
has body: Is there a native data structure in java that accepts key value pairs and allows duplicates? I am creating a checklist of characters in a string but some characters occur more than once. ex j -&gt; false a -&gt; false v -&gt; false a -&gt; false
linked to: http://stackoverflow.com/q/5830575
possible better answer: http://stackoverflow.com/a/21586801
favorite count: 0
has comment: http://stackoverflow.com/comment/32610599
accepted answer: http://stackoverflow.com/a/21586750
answer count: 5
has comment: http://stackoverflow.com/comment/32610923
score: 4
has comment: http://stackoverflow.com/comment/32610894
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/4956844
has answer: http://stackoverflow.com/a/21586750
tagged with: java
linked to: http://stackoverflow.com/q/1062960

event-handling
tag name: event-handling
tags question: http://stackoverflow.com/q/21540761
tags question: http://stackoverflow.com/q/21647723
type: Tag
tags question: http://stackoverflow.com/q/21523883
tags question: http://stackoverflow.com/q/21631641

http://stackoverflow.com/comment/32508002
type: Comment
comment on: http://stackoverflow.com/a/21529074
has text: Purely out of interest, would escaping the "=" character to "\=" work?
type: AnswerComment
score: 0

http://stackoverflow.com/comment/32654468
comment on: http://stackoverflow.com/q/21612196
score: 1
has text: What do you thing remove() does, if it doesn't modify the collection?
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21599344
type: Question
has comment: http://stackoverflow.com/comment/32632052
answer count: 1
has title: Email validation using Regular expression
score: 0
tagged with: java
linked to: http://stackoverflow.com/q/2762977
duplicate of: http://stackoverflow.com/q/2762977
type: UnansweredQuestion
has body: I didnot find any kind of help for this type of email id so can you please tell me how to validate the below email using regular expression Email Id - xyzabc@co.xyz-gordo.in.zs I am using below Pattern ^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$
has comment: http://stackoverflow.com/comment/32632074
has answer: http://stackoverflow.com/a/21599446

http://stackoverflow.com/comment/32589067
has text: Maybe this bug report is relevant for you https://issues.jboss.org/browse/JBAS-2389?_sscc=t
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21571579
score: 1

http://stackoverflow.com/comment/32633297
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21599754
has text: Default behavior of loading properties in java overrides the old values if same property is loaded again. So it should also do the same. try reversing the order of property files to get desired behavior.

http://stackoverflow.com/a/21533312
has comment: http://stackoverflow.com/comment/32543009
score: 1
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/21533072
answers question: http://stackoverflow.com/q/21533072
has body: Here is a potential cause for a null pointer exception: public Double getLgd(... stuff) { Double lgd = null; if (result != null) { ... blah } return lgd; } double ILikeNullPointerExceptionsWhenResultIsNull = getLgd(); Explaination Autobox conversion from a Double value to a double value includes an implicit dereference of the Double value. For example: Double blam = null; double hoot; hoot = blam; The statement hoot = blam is no different from hoot = blam.doubleValue(). The dereference of the blam variable above will cause a NullPointerException.
upvote count: 1

http://stackoverflow.com/a/21563287
score: 2
answers question: http://stackoverflow.com/q/21559607
has comment: http://stackoverflow.com/comment/32578684
downvote count: 0
has body: The comments to your question have already pointed out that you are somehow trying to reinvent the wheel by implementing functionality that the standard Java class library already provides to some extent (see LinkedList/Queue and Arraylist). But since you say you want to keep yourself practiced in Java I guess it is perfectly fine if you try to implement your own command history from scratch. Here are some of my observations/suggestions: 1) It is not necessary and very counter-intuitive to declare a final first index of 1. It would be easy to start with a default index of 0 and add corresponding checks where necessary. 2) Forget about your private size() method - it is just returning the length of the internal array anyway (i.e. the initial capacity+1). Instead consider adding a public size() method that returns the actual number of added commands and internally update the actual size when adding new commands (see e.g. java.util.ArrayList for reference). 3) At the moment every call to add(String command) will set history[0] = "", which is not necessary. If you want the first index to be "", set it in the constructor. This is also a clear sign, that it would perhaps be better to start with an initial index of 0 instead of 1. 4) A minor issue: "if (!command.equals(""))" during your add method is perhaps OK for such a specialized class but it should definitely be commented in the documentation of the method. Personally I would always let the calling class decide if an empty "" command is considered valid or not. Also this method will throw an undocumented NullPointerException, when null is used as an argument. Consider changing this to "if (!"".equals(command))" or throw an IllegalArgumentException if null is added. 5) "if (history[i] == null)" during the add method is completely unnecessary, if you internally keep a pointer to the actual size of the commands - this is actually a special case that will only be true, when the very first command is added to the command h…
upvote count: 2
type: Answer

twilio
tag name: twilio
tags question: http://stackoverflow.com/q/21582157
tags question: http://stackoverflow.com/q/21588186
type: Tag

http://stackoverflow.com/comment/32518131
comment on: http://stackoverflow.com/a/21534813
type: AnswerComment
has text: yeah i also thought that. So, i tried adding region using Region REGION = Region.getRegion(Regions.US_WEST_2); sesClient.setRegion(REGION); my console region is oregon viz us west 2. But, it said that region does not has any email service available.
type: Comment
score: 0

http://stackoverflow.com/comment/39645778
score: 0
type: Comment
type: QuestionComment
has text: If you don't know what ThreadLocals are, you probably aren't using them. :) But the classloader is definitely not getting unloaded.
comment on: http://stackoverflow.com/q/21579845

http://stackoverflow.com/q/21627564
accepted answer: http://stackoverflow.com/a/21627745
tagged with: java
type: Question
has body: Recently I've started working in a computer engineering group, our goal is to make a new social networking for students. Few days ago a telecommunication engineer joined us and he has convinced our boss (who doesn't have any knowledge of computing) to make the whole project in Java, when we had already discussed and decided to use an architecture based on Symfony. We would like to hear all the possible opinions to convince the boss that his decision is wrong (or for us to realize that we were wrong). (Our project is not a small one, we are thinking in using a good server, having a big database. This is why this decision is very important to us). Thanks beforehand and sorry for my bad english.
has title: Web programming totally in Java or based on Symfony
answer count: 2
upvote count: 1
has comment: http://stackoverflow.com/comment/32681120
tagged with: web
favorite count: 0
possible better answer: http://stackoverflow.com/a/21627649
tagged with: symfony
has answer: http://stackoverflow.com/a/21627649
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32681053
downvote count: 0
has answer: http://stackoverflow.com/a/21627745
score: 1

http://stackoverflow.com/comment/32859172
type: QuestionComment
has text: Yea i know it is not a real clean solution... Just an idea. Does the mousPressed event gets fired? If so you could look for the mouse coordinates and if they are outside the window (if it is possible to get coordinates from outside) you could pause the game. Just another idea.
comment on: http://stackoverflow.com/q/21553414
score: 0
type: Comment

http://stackoverflow.com/a/21545079
type: Answer
answers question: http://stackoverflow.com/q/21545046
has body: If you look carefully you can see this line mymethod(--counter); This is decreasing the value of counter and then passing it as a parameter to mymethod This will be called for as long as counter > 0, then the method will return all the way up. After each method returns System.out.println("" +counter); will be executed. The value of counter is being remembered in each call of mymethod
score: 0

http://stackoverflow.com/q/21559325
has comment: http://stackoverflow.com/comment/32560870
tagged with: java
possible better answer: http://stackoverflow.com/a/21561678
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/32561888
has title: Spring resttemplate
accepted answer: http://stackoverflow.com/a/21661912
has comment: http://stackoverflow.com/comment/32561309
score: 0
tagged with: rest
has answer: http://stackoverflow.com/a/21561678
has answer: http://stackoverflow.com/a/21661912
has comment: http://stackoverflow.com/comment/32561674
has body: How to send POST request where must be query parameters in message body? I tried: MultiValueMap&lt;String, String&gt; map = new LinkedMultiValueMap&lt;String, String&gt;(); map.add("name", "xx"); map.add("password", "xx"); restTemplate.postForObject("URL", map, Response.class); But it doesn't work. I want to send data into bitstamp api. EDIT: My spring bean seems: &lt;bean id="restTemplate" class="org.springframework.web.client.RestTemplate"&gt; &lt;property name="messageConverters"&gt; &lt;list&gt; &lt;bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" /&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; EDIT 2: My code seems List&lt;MediaType&gt; acceptableMediaTypes = new ArrayList&lt;MediaType&gt;(); acceptableMediaTypes.add(MediaType.APPLICATION_JSON);// or any other HttpHeaders headers = new HttpHeaders(); headers.setAccept(acceptableMediaTypes); HttpEntity&lt;String&gt; requestEntity = new HttpEntity&lt;String&gt;("key=XX&amp;nonce=XX&amp;signature=XX", headers); ResponseEntity&lt;AccountBalance&gt; responseEntity = restTemplate.exchange( "https://www.bitstamp.net/api/balance/", HttpMethod.POST, requestEntity, AccountBalance.class); Response is now: Missing key, signature and nonce parameters But it should be: API key not found
tagged with: spring
type: AnsweredQuestion

http://stackoverflow.com/a/21674856
type: Answer
has comment: http://stackoverflow.com/comment/32764018
has body: Extend HashSet: import java.util.HashSet; public class MyHashSet&lt;Key&gt; extends HashSet&lt;Key&gt; { private int limit; public MyHashSet(int limit) { super(); this.limit = limit; } public boolean add(Key key) { if (!contains(key) &amp;&amp; size() == limit) { throw new IndexOutOfBoundsException("Limit exceeded."); } else { return super.add(key); } } public static void main(String[] args) { HashSet&lt;Integer&gt; set = new MyHashSet&lt;Integer&gt;(1); set.add(0); set.add(1); // IndexOutOfBoundsException } }
upvote count: 1
answers question: http://stackoverflow.com/q/21674457
downvote count: 1
accepted answer of: http://stackoverflow.com/q/21674457
score: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32763947
has comment: http://stackoverflow.com/comment/32764162

http://stackoverflow.com/comment/32504738
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21527523
has text: @MarkoTopolnik IT's the default `toString()` of `Object`.
type: Comment

http://stackoverflow.com/q/21601441
type: Question
upvote count: 2
has answer: http://stackoverflow.com/a/21601493
downvote count: 0
answer count: 1
accepted answer: http://stackoverflow.com/a/21601493
favorite count: 0
tagged with: android
linked to: http://stackoverflow.com/q/21588821
score: 2
type: AnsweredQuestion
has title: LinkedHashSet<ItemCategory> and a Spinner in Android
tagged with: java
has body: For my android app I have spinners that provide list of product categories for the users to choose from following this discussion: Corelating items from two arraylists in Java I created a category object in the following fashion: public class ItemCategory { private int id; private String name; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } I am storing all the ItemCategories in a LinkedHashSet and Im passing this LinkedHashSet to all the activities that need to display a spinner with categories. Now, the question is, how do I populate the spinner with the names of those ItemCategory objects, and then, when a selection is made, I need to set the int newItemCategoryID to the corresponding ID from the same ItemCategory object? this is how Im populating the spinner: public class LoadSpinnerData { public static void loadSpinnerData(Context context, ArrayList&lt;String&gt; array, Spinner spinner) { // Creating adapter for spinner ArrayAdapter&lt;String&gt; dataAdapter = new ArrayAdapter&lt;String&gt;(context, R.drawable.simple_spinner_item, array); // Drop down layout style - list view with radio button dataAdapter .setDropDownViewResource(R.drawable.simple_spinner_dropdown_item); // Attaching data adapter to spinner spinner.setAdapter(dataAdapter); } } And this is how I pass that ArrayList to this spinner: categoriesInfo = new GetCategoriesFromDB(dbTools).execute().get(4000, TimeUnit.MILLISECONDS); ArrayList&lt;String&gt; categoryNamesArray = new ArrayList&lt;String&gt;(); for(ItemCategory itemCategory : categoriesInfo) { categoryNamesArray.add(itemCategory.getName()); } LoadSpinnerData.loadSpinnerData(this, categoryNamesArray, sAddAnItemCategory); The question is what do I do here: sAddAnItemCategory.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int arg2, lon…

http://stackoverflow.com/comment/32691271
type: Comment
comment on: http://stackoverflow.com/a/21632985
score: 0
type: AnswerComment
has text: i did in this program more than one string methods

http://stackoverflow.com/a/21536570
type: Answer
answers question: http://stackoverflow.com/q/21536302
has body: I wonder what is your use case. If you don't change this names often, and/or don't have many objects with name, but you need to find by key often, you could create your own implementation of Map (inheriting from HashMap). There you could store everything as usually, and when get is called, try to do super.get, if it returns null, check all the objects in map, if found, update the map and return the object. So the algorithm looks like this: Try standard implementation get If not found, check all super.values() for desired name If found, put(name, foundObject) and return foundObject Be careful however, as this might break something if you sometimes assign a name to an object, which was in the past assigned to another object. In such case you could return old object from the map.
score: 0

http://stackoverflow.com/a/21589351
has body: 'Socket closed' means that you closed the socket and then continued to use it. It's a bug in your code. Note that it does not mean that the peer closed the connection. There are numerous problems with your code, too many to review here. It is very poor quality. I suggest you get hold of the Custom Networking trail of the Java Tutorial and study it, and also look around for best practices in exception handling. At present you just catch certain exceptions, log them, and continue as though they hadn't happened. Code after a 'catch' block should not rely on things that happened in the 'try' block.
upvote count: 4
score: 2
answers question: http://stackoverflow.com/q/21578953
downvote count: 2
has comment: http://stackoverflow.com/comment/68726764
type: Answer

http://stackoverflow.com/q/21549865
has answer: http://stackoverflow.com/a/21549984
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/32544791
tagged with: jpa
has comment: http://stackoverflow.com/comment/32544959
score: 0
has answer: http://stackoverflow.com/a/21554366
accepted answer: http://stackoverflow.com/a/21554366
has comment: http://stackoverflow.com/comment/32544126
has comment: http://stackoverflow.com/comment/32544510
tagged with: maven
has title: javax.persistence.EntityManager missing a method
has comment: http://stackoverflow.com/comment/32544211
type: AnsweredQuestion
has body: I have recently tired to fix the problem with maven dependencies in my java web project and I deleted all things from the repository folder, after that I did "maven update project" in eclipse and the problem was fixed, however other error appeared. The method I was using createNamedQuery(String, Class<T>) no longer exists in the javax.persistence.EntityManager interface. I did some research and I suspect that maven has changed the JPA implementation version to JPA 1.0 which is very annoying and also I don't really know how to fix this. I didn't change anything in pom.xml, the only change that I noticed is that javax.persistence package now comes from ejb3 jar from jboss-as-connector maven artifact. How can I fix this? SORRY: I just found out that the ejb3-persistence comes from hibernate package. EDIT: pom.xml file: ... <jboss.provided.jar>compile</jboss.provided.jar> JBoss repository http://repository.jboss.org/nexus/content/groups/public/ junit junit org.mockito mockito-all 1.9.5 test pl.pragmatists JUnitParams 1.0.2 test org.springframework spring-test ${org.springframework.version} test org.kubek2k springockito-annotations 1.0.8 test org.hsqldb hsqldb 2.3.1 test org.seleniumhq.selenium selenium-java 2.33.0 test xml-apis xml-apis 1.4.01 test THIS IS PROBABLY THE ROOT OF ALL EVIL org.jboss.jbossas jboss-as-connector 6.1.0.Final javax.servlet servlet-api 2.5 provided org.aspectj aspectjrt 1.7.3 org.aspectj aspectjweaver 1.7.3 cglib cglib-nodep 2.1_3 org.springframework spring-core ${org.springframework.version} org.springframework spring-web ${org.springframework.version} jar org.springframework spring-tx ${org.springframework.version} org.springframework spring-webmvc ${org.springframework.version} org.springframework spring-aop ${org.springframework.version} org.springframework spring-orm ${org.springframework.version} org.hibernate hibernate-entitymanager ${org.hibernate.version} ${jboss.provided.jar} org.hibernate hibernate-validator 5.0.1.Final ${jboss.provide…
tagged with: java
has comment: http://stackoverflow.com/comment/32545187
has comment: http://stackoverflow.com/comment/32550409
possible better answer: http://stackoverflow.com/a/21549984
has comment: http://stackoverflow.com/comment/32543788
has comment: http://stackoverflow.com/comment/32551691
has comment: http://stackoverflow.com/comment/32543831

http://stackoverflow.com/q/21578063
possible better answer: http://stackoverflow.com/a/21578203
tagged with: android
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32594483
tagged with: java
has answer: http://stackoverflow.com/a/21578393
accepted answer: http://stackoverflow.com/a/21578393
type: Question
has comment: http://stackoverflow.com/comment/32594445
has answer: http://stackoverflow.com/a/21578203
has comment: http://stackoverflow.com/comment/32594465
has title: new to java - understanding an HTTP POST request
score: 0
tagged with: rest
answer count: 3
has comment: http://stackoverflow.com/comment/32594359
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/32595232
has answer: http://stackoverflow.com/a/21578700
favorite count: 0
has body: I have been trying to understand the postData() method in the following tutorial. My understanding of the code is: an nameValuePairs object, which contains some data is being sent over the internet to some web service located at this address: http://www.yoursite.com/script.php which will receive this nameValuePairs object

http://stackoverflow.com/comment/32663921
type: QuestionComment
comment on: http://stackoverflow.com/q/21617090
has text: The question is to implement that inspector method to that class.
score: 1
type: Comment

http://stackoverflow.com/a/21572008
score: 1
answers question: http://stackoverflow.com/q/21571759
has body: i think you should use SharedPreferences to save a boolean flag that your first activity "the guideline" activity have been displayed . and on your button click set the value to true like the following : SharedPreferences pref = getApplicationContext().getSharedPreferences("MyApplicationPref", Context.MODE_PRIVATE); Editor editor = pref.edit(); editor.putBoolean("firstTime" , Boolean.TRUE); editor.commit(); and in your "guideline" in your onResume method do the following : SharedPreferences pref = getApplicationContext().getSharedPreferences("MyApplicationPref", Context.MODE_PRIVATE); boolean firstTime = pref.getBoolean("firstTime", false); if(firstTime == true){ Intent myIntent = new Intent(getApplicationContext() , MainActivity.class); startActivity(myIntent); } Please give me some feedback . Hope That Helps .
downvote count: 0
has comment: http://stackoverflow.com/comment/32585053
type: Answer
upvote count: 1

http://stackoverflow.com/comment/32761953
type: QuestionComment
comment on: http://stackoverflow.com/q/21673774
score: 1
has text: Usually music is played with a background Service which are not affected by closing activities.
type: Comment

http://stackoverflow.com/a/21585766
type: Answer
downvote count: 0
score: 1
has body: Solution algorithm which check after each generated number exist is or no: int[] nodeArray = new int[100]; int currentIndex = 0; while(currentIndex &lt; 100) { int currentValue = (int) (Math.random() * 199); int i = 0; while(i &lt; currentIndex) { if(currentValue == nodeArray[i]) { break; } i++; } if(i == currentIndex) { nodeArray[currentIndex++] = currentValue; } } Then you can sort ant print random numbers Arrays.sort(nodeArray); // Sort to be easy find duplicates for (Integer i : nodeArray) { System.out.print(i + ", "); }
upvote count: 1
answers question: http://stackoverflow.com/q/21584849

http://stackoverflow.com/a/21616676
type: Answer
answers question: http://stackoverflow.com/q/21616614
upvote count: 5
downvote count: 0
has body: In a regex you need 4 \ to match one (the regex only needs two but it's a Java string so you need to escape each of them as well): String[] result = s.split("\\\\",-1); Now if you want to parse a date you should use DateFormat#parse...
score: 5

http://stackoverflow.com/comment/32540765
has text: you are supposed to import the onclick listener for a dialog and not a view. Please refer to proper java documents or sites that teach how java works and what importing means.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21547984

http://stackoverflow.com/a/21567193
answers question: http://stackoverflow.com/q/21567177
has body: You've named all your radiobuttons rb1 so the other components are never initialized rb1 = new JRadioButton(a, true); rb2 = new JRadioButton(b); rb3 = new JRadioButton(c); rb4 = new JRadioButton(d);
downvote count: 0
type: Answer
upvote count: 2
score: 2

http://stackoverflow.com/comment/32763484
type: Comment
comment on: http://stackoverflow.com/a/21671620
type: AnswerComment
score: 0
has text: We'll try to fix this ASAP

http://stackoverflow.com/q/21561157
has answer: http://stackoverflow.com/a/21561891
accepted answer: http://stackoverflow.com/a/21561891
type: Question
tagged with: intellij-idea
has title: jsf:The requested resource is not available
score: 0
has comment: http://stackoverflow.com/comment/32565341
upvote count: 1
answer count: 1
tagged with: tomcat
favorite count: 0
has comment: http://stackoverflow.com/comment/32565173
has comment: http://stackoverflow.com/comment/32564935
has comment: http://stackoverflow.com/comment/32565597
type: AnsweredQuestion
has body: i tried to create a new jsf project, after creating the project i tried to see that the base is correct or not , so i made a test.xhtml to check it , test.xhtml: <?xml version="1.0" encoding="UTF-8"?> <h:outputLabel value="yes that's work "/> and my web.xml is: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> Faces Servlet javax.faces.webapp.FacesServlet 1 Faces Servlet *.xhtml Faces Servlet *.jsf but after running , it shows me : what can i do to make it to work ? thank's in advance, i am using intellij idea with tomcat 7.0.50 java version "1.7.0_25" os: ubuntu
has comment: http://stackoverflow.com/comment/32564742
tagged with: jsf
tagged with: java
downvote count: 1

http://stackoverflow.com/q/21569138
has comment: http://stackoverflow.com/comment/32579422
has answer: http://stackoverflow.com/a/21570258
score: 4
accepted answer: http://stackoverflow.com/a/21569779
has title: Removing italic and bold html tags from string?
answer count: 3
has body: What is a safer way to remove bold and italics than the following? String text = "Remove bold and italics"; System.out.println(text); text = text.replaceAll("\\<.*?\\>", ""); //remove all but only want to remove b and i? System.out.println(text); Also, and more extensible (if I want to include other tags such as "strong" or "em" and allow for case sensitivity "b" vs "B" etc,.)?
tagged with: http://stackoverflow.com/tag/html
tagged with: regex
upvote count: 4
has answer: http://stackoverflow.com/a/21569524
favorite count: 0
has answer: http://stackoverflow.com/a/21569779
possible better answer: http://stackoverflow.com/a/21570258
has comment: http://stackoverflow.com/comment/32580495
type: AnsweredQuestion
downvote count: 0
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32580780

http://stackoverflow.com/comment/32723951
type: Comment
score: 0
has text: Thank you for your solution. It helped a lot to understand.
type: AnswerComment
comment on: http://stackoverflow.com/a/21647685

http://stackoverflow.com/comment/32768141
comment on: http://stackoverflow.com/q/21677306
has text: what is the code you are using to populate the segment map?
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32537345
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21545696
has text: @user3261660: I have changed my answer. This should hopefully answer your question.

http://stackoverflow.com/comment/32526636
type: Comment
comment on: http://stackoverflow.com/q/21538468
score: 0
type: QuestionComment
has text: Well, if I do that then 15+ errors show. I need to have JRE 1.5 (or 1.4) because apparently somethings changed in the compiler about transient modifiers.

http://stackoverflow.com/comment/32614157
comment on: http://stackoverflow.com/q/21576525
score: 0
type: Comment
type: QuestionComment
has text: I would suggest to use Oracle for unit testing if target server is oracle because you will have more issues and will waste more time with mock DB than for oracle setup. H2 might be a better choice but I did try it and decided not to use mock databases for testing anymore with or without hibernate.

http://stackoverflow.com/a/21598616
upvote count: 2
has comment: http://stackoverflow.com/comment/32631059
score: 2
has body: Why not encapsulate Config subclasses OneType and TwoType that set these values in their constructor. Then change the factory to the following: public Config getConfig (String objType) { if (objType.equals("one-type")) { return new OneType (); } else if (objType.equals("two-type")) { return new TwoType (); } Alternatively, I use this pattern with enums for this kind of situation: enum ConfigType { one-type ("one_type_table", "one_type_parent", 1, 10), two-type ("two-type_table", "two_type_parent", 2, 20) ; ConfigType (String table, String parent, int unit, int delay) { ... } String getTable () { return this.table; } .... } Now you can generalize the factory code and work in terms of static enum types instead of runtime evaluated strings. public Config getConfig (ConfigType type) { return new Config (type.getTable (),...
downvote count: 0
answers question: http://stackoverflow.com/q/21598414
has comment: http://stackoverflow.com/comment/32647566
type: Answer

http://stackoverflow.com/tag/json
tags question: http://stackoverflow.com/q/21523982
tags question: http://stackoverflow.com/q/21614119
tags question: http://stackoverflow.com/q/21544973
tags question: http://stackoverflow.com/q/21597271
tags question: http://stackoverflow.com/q/21543089
tags question: http://stackoverflow.com/q/21599614
tags question: http://stackoverflow.com/q/21585454
tags question: http://stackoverflow.com/q/21556849
tags question: http://stackoverflow.com/q/21610734
tags question: http://stackoverflow.com/q/21586075
tags question: http://stackoverflow.com/q/21633661
tags question: http://stackoverflow.com/q/21561920
tags question: http://stackoverflow.com/q/21536987
tags question: http://stackoverflow.com/q/21525248
tags question: http://stackoverflow.com/q/21641022
tags question: http://stackoverflow.com/q/21608038
tags question: http://stackoverflow.com/q/21621698
tags question: http://stackoverflow.com/q/21527866
tags question: http://stackoverflow.com/q/21663120
tags question: http://stackoverflow.com/q/21545170
tags question: http://stackoverflow.com/q/21552038
tags question: http://stackoverflow.com/q/21571768
tags question: http://stackoverflow.com/q/21672245
tags question: http://stackoverflow.com/q/21628361
tags question: http://stackoverflow.com/q/21546780
tags question: http://stackoverflow.com/q/21596465
tags question: http://stackoverflow.com/q/21649566
tags question: http://stackoverflow.com/q/21558334
type: Tag
tags question: http://stackoverflow.com/q/21578334
tags question: http://stackoverflow.com/q/21634387
tags question: http://stackoverflow.com/q/21639283
tags question: http://stackoverflow.com/q/21672721
tags question: http://stackoverflow.com/q/21544576
tags question: http://stackoverflow.com/q/21556332
tags question: http://stackoverflow.com/q/21636719
tags question: http://stackoverflow.com/q/21577447
tags question: http://stackoverflow.com/q/21560164
tags question: http://stackoverflow.com/q/21556883
tags question: http://stackoverflow.com/q/21555646
tags question: http://stackoverflow.com/q/21547498
tags question: http://stackoverflow.com/q/21675326
tags question: http://stackoverflow.com/q/21577848
tags question: http://stackoverflow.com/q/21571367
tags question: http://stackoverflow.com/q/21602313
tags question: http://stackoverflow.com/q/21529853
tags question: http://stackoverflow.com/q/21678179
tags question: http://stackoverflow.com/q/21522223
tags question: http://stackoverflow.com/q/21622574
tags question: http://stackoverflow.com/q/21665546
tags question: http://stackoverflow.com/q/21631720
tags question: http://stackoverflow.com/q/21671103
tags question: http://stackoverflow.com/q/21553285
tags question: http://stackoverflow.com/q/21579756
tags question: http://stackoverflow.com/q/21674326
tags question: http://stackoverflow.com/q/21576931
tags question: http://stackoverflow.com/q/21676256
tag name: json
tags question: http://stackoverflow.com/q/21527335
tags question: http://stackoverflow.com/q/21520184
tags question: http://stackoverflow.com/q/21559185
tags question: http://stackoverflow.com/q/21576475
tags question: http://stackoverflow.com/q/21577782
tags question: http://stackoverflow.com/q/21591148
tags question: http://stackoverflow.com/q/21547731
tags question: http://stackoverflow.com/q/21575959
tags question: http://stackoverflow.com/q/21646212
tags question: http://stackoverflow.com/q/21540451
tags question: http://stackoverflow.com/q/21633677
tags question: http://stackoverflow.com/q/21537699
tags question: http://stackoverflow.com/q/21581977
tags question: http://stackoverflow.com/q/21671794
tags question: http://stackoverflow.com/q/21515195
tags question: http://stackoverflow.com/q/21650249
tags question: http://stackoverflow.com/q/21524841
tags question: http://stackoverflow.com/q/21588727
tags question: http://stackoverflow.com/q/21640318
tags question: http://stackoverflow.com/q/21523935
tags question: http://stackoverflow.com/q/21659230
tags question: http://stackoverflow.com/q/21632560

http://stackoverflow.com/comment/32655191
score: 0
comment on: http://stackoverflow.com/q/21612503
has text: But you cannot have a 2d array with a String and an int in java, without using an object which you cannot sort.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32629988
comment on: http://stackoverflow.com/a/21581501
score: 0
type: AnswerComment
has text: Thanks. Now I understand. i18n properties files are equivalent to .class file and are located by the classloader. As long as loader sees it (in my case my jar in WEB-INF/lib folder) there won't be a problem.
type: Comment

http://stackoverflow.com/a/21542330
has body: Your close. You will need to pass in satisfactionNumber into getBillTotal by adding another parameter. Otherwise it don't know what you are taking about when you say satisfactionNumber. It can't directly see the variables in other functions. public static double getBillTotal(double tipPercentage, double subtotal, int satisfactionNumber) { double totalWithTip = (subtotal + (getPercentage(satisfactionNumber) * subtotal)); return totalWithTip; } Then in your main method call pass it in. public static void main(String[] args) { .... System.out.println("The bill total is: " + getBillTotal(tipPercentage, subtotal, satisfactionNumber)); } And actually you don't need tipPercentage, in fact it's not even defined in main. Since it can be found by satisfactionNumber you could do this. public static void main(String[] args) { .... System.out.println("The bill total is: " + getBillTotal(subtotal, satisfactionNumber)); } ... public static double getBillTotal(double subtotal, int satisfactionNumber) { double totalWithTip = (subtotal + (getPercentage(satisfactionNumber) * subtotal)); return totalWithTip; } OR you could pass in the tipPercentage by calculating it first. public static void main(String[] args) { .... double tipPercentage = getPercentage(satisfactionNumber); System.out.println("The bill total is: " + getBillTotal(tipPercentage, subtotal)); } ... public static double getBillTotal(double tipPercentage, double subtotal) { double totalWithTip = (subtotal + (tipPercentage * subtotal)); return totalWithTip; } Any of these last two would be okay.
answers question: http://stackoverflow.com/q/21542234
accepted answer of: http://stackoverflow.com/q/21542234
upvote count: 1
type: AcceptedAnswer
type: Answer
downvote count: 0
score: 1

http://stackoverflow.com/a/36001361
score: 3
answers question: http://stackoverflow.com/q/21574236
upvote count: 3
has body: There are several good answers here that handle this error in a broad scope. I ran into a specific situation with Spring Security which had a quick, although probably not optimal, fix. During user authorization (immediately after logging in and passing authentication) I was testing a user entity for a specific authority in a custom class that extends SimpleUrlAuthenticationSuccessHandler. My user entity implements UserDetails and has a Set of lazy loaded Roles which threw the "org.hibernate.LazyInitializationException - could not initialize proxy - no Session" exception. Changing that Set from "fetch=FetchType.LAZY" to "fetch=FetchType.EAGER" fixed this for me.
downvote count: 0
type: Answer

http://stackoverflow.com/q/21618285
has answer: http://stackoverflow.com/a/21618819
type: Question
score: 0
answer count: 1
tagged with: awtrobot
tagged with: linux
tagged with: screenshot
has comment: http://stackoverflow.com/comment/32666428
type: UnansweredQuestion
has title: Taking screenshots in headless Linux environment possible?
tagged with: java
tagged with: headless
has body: I am working on a project on the comparatively slow Raspberry Pi system. I run the rpix86 DOS emulator in basic console mode (without X!) to maximize its speed. I need to take screenshots (640x480) from it. My java implementation throws "AWTException: headless environment". BufferedImage image = null; try { image = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); ImageIO.write(image, "png", new File("/screenshot + i" + ".png")); } catch Or, if I try static { System.setProperty("java.awt.headless", "false"); } then I get java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable Is it even possible to take screenshots with Java in the headless environment, or am I trying the impossible? Thanks in advance! Theo

http://stackoverflow.com/comment/32624812
type: QuestionComment
has text: Static field values located in the heap only once, static fields or methods do not depend on class objects. They are unique in the application.
score: 0
comment on: http://stackoverflow.com/q/21594812
type: Comment

http://stackoverflow.com/a/21626609
answers question: http://stackoverflow.com/q/21626465
has body: you should use method connect(host,port)
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/32679551
score: 16
accepted answer of: http://stackoverflow.com/q/21626465
has comment: http://stackoverflow.com/comment/32679678
upvote count: 16

http://stackoverflow.com/comment/32621551
has text: Ok thanks. I updated the code. How would I go about dealing with the bottom part of the Matcher class?
comment on: http://stackoverflow.com/a/21592945
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/21577901
downvote count: 1
upvote count: 0
has body: You must use Layout manager. Use this code.. public static void main(String[] args) { JFrame jfrm = new JFrame("Frame1"); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); jfrm.setSize(screenSize.width, screenSize.height); jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel jlab = new JLabel("Hello"); jfrm.add(jlab); JButton button = new JButton("Button"); button.setSize(new Dimension(50, 50)); button.setLocation(500, 350); jfrm.add(button); jfrm.setVisible(true); jfrm.setLayout(new FlowLayout()); jfrm.pack(); you forgot to add pack(). so use this code to get Jlabel and JButtion side by side. Thanks...
score: -1
answers question: http://stackoverflow.com/q/21577712
type: Answer

http://stackoverflow.com/comment/32606609
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21584194
has text: ya, in original file split regex is | not , sorry about that,
score: 0

http://stackoverflow.com/q/21571888
tagged with: java
linked to: http://stackoverflow.com/q/15105462
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/21806062
score: 2
has comment: http://stackoverflow.com/comment/32584537
has comment: http://stackoverflow.com/comment/32584044
downvote count: 0
favorite count: 0
linked to: http://stackoverflow.com/q/5392695
type: Question
has title: subtracting a Bitamap image from another java android
tagged with: android
has answer: http://stackoverflow.com/a/53730079
tagged with: subtraction
linked to: http://stackoverflow.com/q/16804404
upvote count: 2
tagged with: bitmap
linked to: http://stackoverflow.com/q/649154
answer count: 1
has comment: http://stackoverflow.com/comment/32585895
has body: How do I subtract one bitmap image from another in Android. Please help with the code for the same

http://stackoverflow.com/a/21623086
has comment: http://stackoverflow.com/comment/32749022
upvote count: 3
has body: SpringLayout.NORTH specifies the top edge of a component's bounding rectangle. SpringLayout.SOUTH specifies the bottom edge of a component's bounding rectangle. SpringLayout.EAST specifies the right edge of a component's bounding rectangle. SpringLayout.WEST specifies the left edge of a component's bounding rectangle. SpringLayout.BASELINE specifies the baseline of a component. SpringLayout.HORIZONTAL_CENTER specifies the horizontal center of a component's bounding rectangle. SpringLayout.VERTICAL_CENTER specifies the vertical center of a component's bounding rectangle. (How to Use SpringLayout) Use the same springLayout.putConstraint() for placing at center, as you do in the corner.
score: 3
answers question: http://stackoverflow.com/q/21622148
downvote count: 0
type: Answer

http://stackoverflow.com/q/21665160
type: Question
has body: For some reason, this is not working and I cannot figure out why. It will return ONLY true even if it is false, Everything else seems to work, except it will not return false. Please Help! I am new to Java programming and would really appreciate someone catching my error! import javax.swing.JOptionPane; public class A2Q1 { public static void main(String[] args) { int number, input1, min, max; String input; boolean trueFalse; //constants min = 0; max = 1000000; input = JOptionPane.showInputDialog(null, "Input number -1 to quit"); input1 = Integer.parseInt(input); while (input1 != -1) { number = getNumber(min, max); // gets the number the user wants to test trueFalse = isHappy(number); //tests if the number is happy or unhappy //getting the returned value and telling the user if it is happy or unhappy if (false) { System.out.println(number + " is unhappy"); } else { System.out.println(number + " is happy"); } //getting input from the user to continue to quit input = JOptionPane.showInputDialog(null, input number - 1 to quit"); input1 = Integer.parseInt(input); } System.out.println("End of Processing"); } public static int getNumber(int min, int max) //get the number from the user { //declaring variables String input; int number; //getting input from the user for the value they want to test input = JOptionPane.showInputDialog(null, "What is the value you number = Integer.parseInt(input); if (number &gt; 0 &amp;&amp; number &lt; 100000) { return number; } else { System.out.println("You have entered an invalid number"); return number; } } //closing getNumber public static boolean isHappy(int number) { //declaring variables int digit1, digit2, digit3, sum; while (number != 0 &amp;&amp; number != 1 &amp;&amp; number != 4 &amp;&amp; number != 16 &amp;&amp; number != 20 &amp;&amp; number != 37 &amp;&amp; number != 42 &amp;&amp; number != 58 &amp;&amp; number != 89 &amp;&amp; number != 145) { digit1 = number % 1000; digit1 = digit1 / 100; digit2 = number % 100; digit2 = digit…
answer count: 1
has comment: http://stackoverflow.com/comment/32747651
favorite count: 0
score: -1
has title: Happy or unhappy numbers in Java, not working properly
type: UnansweredQuestion
downvote count: 2
upvote count: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32747611
has answer: http://stackoverflow.com/a/21665228

http://stackoverflow.com/a/21873775
downvote count: 1
type: Answer
score: 1
upvote count: 2
answers question: http://stackoverflow.com/q/21670451
has body: Looking at the problem, you need to integrate your application with 10+ different webservices.While making all the calls asynchronous. This can be done easily with Apache Camel. It is a prominent framework for enterprise integration and also supports async processing. You can use its CXF component for calling webservices and its routing engine for invocation and processing results. Look at the following page regarding camel's async routing capability. They have also provided a complete example invoking webservices async using CXF, it available at its maven repo. Also see the following page for more details.

mysql
tags question: http://stackoverflow.com/q/21645371
tags question: http://stackoverflow.com/q/21545096
tags question: http://stackoverflow.com/q/21570810
tags question: http://stackoverflow.com/q/21638734
tags question: http://stackoverflow.com/q/21654091
tags question: http://stackoverflow.com/q/21542774
tags question: http://stackoverflow.com/q/21527335
tags question: http://stackoverflow.com/q/21530112
tags question: http://stackoverflow.com/q/21560164
tags question: http://stackoverflow.com/q/21645164
tags question: http://stackoverflow.com/q/21644324
tags question: http://stackoverflow.com/q/21517595
tags question: http://stackoverflow.com/q/21606034
tags question: http://stackoverflow.com/q/21563011
tags question: http://stackoverflow.com/q/21605173
tag name: mysql
tags question: http://stackoverflow.com/q/21570972
tags question: http://stackoverflow.com/q/21536113
tags question: http://stackoverflow.com/q/21523538
tags question: http://stackoverflow.com/q/21579326
tags question: http://stackoverflow.com/q/21522875
tags question: http://stackoverflow.com/q/21634411
tags question: http://stackoverflow.com/q/21659278
tags question: http://stackoverflow.com/q/21648038
tags question: http://stackoverflow.com/q/21547998
tags question: http://stackoverflow.com/q/21566449
tags question: http://stackoverflow.com/q/21596500
tags question: http://stackoverflow.com/q/21569717
tags question: http://stackoverflow.com/q/21542479
tags question: http://stackoverflow.com/q/21518917
tags question: http://stackoverflow.com/q/21595635
tags question: http://stackoverflow.com/q/21566612
tags question: http://stackoverflow.com/q/21594981
tags question: http://stackoverflow.com/q/21651671
tags question: http://stackoverflow.com/q/21609400
tags question: http://stackoverflow.com/q/21634703
tags question: http://stackoverflow.com/q/21671681
tags question: http://stackoverflow.com/q/21579971
tags question: http://stackoverflow.com/q/21645332
tags question: http://stackoverflow.com/q/21529448
tags question: http://stackoverflow.com/q/21549712
tags question: http://stackoverflow.com/q/21656311
tags question: http://stackoverflow.com/q/21676119
tags question: http://stackoverflow.com/q/21672837
tags question: http://stackoverflow.com/q/21516727
tags question: http://stackoverflow.com/q/21622076
tags question: http://stackoverflow.com/q/21601049
tags question: http://stackoverflow.com/q/21596834
tags question: http://stackoverflow.com/q/21566550
tags question: http://stackoverflow.com/q/21565795
type: Tag
tags question: http://stackoverflow.com/q/21551396
tags question: http://stackoverflow.com/q/21569636
tags question: http://stackoverflow.com/q/21663558
tags question: http://stackoverflow.com/q/21621698
tags question: http://stackoverflow.com/q/21624257
tags question: http://stackoverflow.com/q/21606180
tags question: http://stackoverflow.com/q/21544657
tags question: http://stackoverflow.com/q/21644248
tags question: http://stackoverflow.com/q/21563567
tags question: http://stackoverflow.com/q/21658537
tags question: http://stackoverflow.com/q/21576645
tags question: http://stackoverflow.com/q/21544851
tags question: http://stackoverflow.com/q/21556387
tags question: http://stackoverflow.com/q/21580598
tags question: http://stackoverflow.com/q/21582954
tags question: http://stackoverflow.com/q/21563974
tags question: http://stackoverflow.com/q/21532028
tags question: http://stackoverflow.com/q/21564377
tags question: http://stackoverflow.com/q/21556594
tags question: http://stackoverflow.com/q/21521238
tags question: http://stackoverflow.com/q/21625994
tags question: http://stackoverflow.com/q/21664925
tags question: http://stackoverflow.com/q/21575873
tags question: http://stackoverflow.com/q/21625732
tags question: http://stackoverflow.com/q/21552997
tags question: http://stackoverflow.com/q/21519541
tags question: http://stackoverflow.com/q/21646996
tags question: http://stackoverflow.com/q/21614894
tags question: http://stackoverflow.com/q/21651573

http://stackoverflow.com/comment/32744749
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21663627
has text: n-th Fibonacci number of course.

http://stackoverflow.com/q/21651536
tagged with: random
has title: Android - Random not working
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32723270
has body: I'm new here so please go easy on me. I've just started fiddling with android development and for a first app I'm trying to do a press a button->get a random sentence. My idea is to have 2 activities: The main one where you press the button, it choses a random number and apends it to an intent to be sent to the other activity (like shown below). public void activity2(View view){ Intent intent = new Intent(this, RandomThought.class); Random rand = new Random(); String x = Integer.toString(rand.nextInt(3)); intent.putExtra(EXTRA_RANDOM, x); startActivity(intent); } The other activity then receives it and chooses a sentence from the XML strings file in the following way: Intent intent = getIntent(); String x = intent.getStringExtra(MainActivity.EXTRA_RANDOM); int a = Integer.parseInt(x); switch (a){ case 0: send = getString(R.string.random0); case 1: send = getString(R.string.random1); case 2: send = getString(R.string.random2); } TextView textView = new TextView(this); textView.setTextSize(40); textView.setText(send); setContentView(textView); Now, for some reason what is actually happening is that it is chosing always the higher amount possible (in this case 2). Also, considering the life-cicle of an activity, if I go back into the main activity and I press the button again will it generate the new number and sentence or do I need to define a similar situation on the onResume()/onRestart() methods?
type: Question
has comment: http://stackoverflow.com/comment/32723255
answer count: 2
tagged with: android
has answer: http://stackoverflow.com/a/21651581
has comment: http://stackoverflow.com/comment/32723394
has comment: http://stackoverflow.com/comment/32723506
has comment: http://stackoverflow.com/comment/32723418
possible better answer: http://stackoverflow.com/a/21651581
has answer: http://stackoverflow.com/a/21651582
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/32723535
accepted answer: http://stackoverflow.com/a/21651582
has comment: http://stackoverflow.com/comment/32723485

http://stackoverflow.com/q/21532091
has answer: http://stackoverflow.com/a/21532171
accepted answer: http://stackoverflow.com/a/21532171
has title: Java: Copy attributes from one object instance to another?
tagged with: java
has comment: http://stackoverflow.com/comment/32513776
upvote count: 3
has comment: http://stackoverflow.com/comment/32513687
favorite count: 0
tagged with: deep-copy
tagged with: shallow-copy
answer count: 5
has comment: http://stackoverflow.com/comment/32513062
tagged with: reference
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21532114
possible better answer: http://stackoverflow.com/a/21532148
downvote count: 0
has answer: http://stackoverflow.com/a/21532406
has comment: http://stackoverflow.com/comment/32513104
has answer: http://stackoverflow.com/a/21532148
has answer: http://stackoverflow.com/a/21532146
has comment: http://stackoverflow.com/comment/32513041
type: Question
has body: Say you have public class Car{ private Engine m_eng; public Car(){ } public Engine getEngine(){ return m_eng; } public void setEngine(Engine engine){ m_eng = engine; } } public class Engine{ private String m_name; public Engine(){}; public Engine(String name){ m_name = name;} public String getName(){ return m_name; } public void setName(String name){ m_name = name; } } public static void main(String[] args){ Engine eng1 = new Engine("abc"); Car car1 = new Car(); car1.setEngine(eng1); Car car2 = new Car(); car2.setEngine(car1.getEngine()); } Question: are the engine of car1 and car2 referring to the same instance of Engine, or when I do car2.setEngine(car1.getEngine()), it automatically make a deep copy of car1.getEnginer() and set to car2 ?
tagged with: object
linked to: http://stackoverflow.com/q/2156120
score: 3
has comment: http://stackoverflow.com/comment/32513100

http://stackoverflow.com/comment/34271805
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21626406
has text: Yes i solved. It was because i was using mobile data connection. I connected to wifi. now its working fine.
score: 0

http://stackoverflow.com/a/21547006
type: Answer
has comment: http://stackoverflow.com/comment/32545717
has comment: http://stackoverflow.com/comment/32545524
has comment: http://stackoverflow.com/comment/32545106
has comment: http://stackoverflow.com/comment/32539480
has comment: http://stackoverflow.com/comment/32541607
has comment: http://stackoverflow.com/comment/32545603
accepted answer of: http://stackoverflow.com/q/21546909
has comment: http://stackoverflow.com/comment/32546112
score: 0
answers question: http://stackoverflow.com/q/21546909
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32545151
has comment: http://stackoverflow.com/comment/32539411
has body: Total code is fine, but just create initialize the alertdialog at last through create().. if (isInternetPresent) { // Internet Connection is Present // make HTTP requests AlertDialog.Builder builder = new AlertDialog.Builder(AndroidDetectInternetConnectionActivity.this); builder.setMessage("You have network connection.") .setTitle("Internet Connection") .setCancelable(false); alert.setPositiveButton("Continue", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which){ // Do call some activity. Do what you wish to; startActivity(new Intent(AndroidDetectInternetConnectionActivity.this,MainActivity2.class)); } }); AlertDialog alert = builder.create(); alert.show(); EDIT Here is your total Activity Class. package com.example.detectinternetconnection; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class AndroidDetectInternetConnectionActivity extends Activity implements OnClickListener { Boolean isInternetPresent = false; ConnectionDetector cd; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); Button btnStatus = (Button) findViewById(R.id.btnStatus); cd = new ConnectionDetector(getApplicationContext()); btnStatus.setOnClickListener(this); } @Override public void onClick(View v) { isInternetPresent = cd.isConnectingToInternet(); if (isInternetPresent) { AlertDialog alert; AlertDialog.Builder builder = new AlertDialog.Builder( AndroidDetectInternetConnectionActivity .this); builder.setTitle("Internet Connection"); builder.setCancelable(false); builder.setPositiveButton("Continue", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub startActivi…
has comment: http://stackoverflow.com/comment/32541092

http://stackoverflow.com/comment/32552173
type: AnswerComment
type: Comment
has text: Hi, when included the default JAX-RS, I've got the conflict with the JPA persistence (Eclipse-link). So I only included the Jackson libraries that that was missing in the Glassfish.
comment on: http://stackoverflow.com/a/21527739
score: 0

http://stackoverflow.com/q/21616900
tagged with: draggable
has title: ImageIcon click and drag around the window
type: AnsweredQuestion
tagged with: java
type: Question
score: 0
answer count: 1
has body: I'm trying to make it so I can click and drag an ImageIcon (in this case a card image but I'd like to learn how to do it generally) around the window but I don't really know how. I would like to be able to click and hold the mouse botton, drag the ImageIcon, and have stay where it is whn I release the mouse botton. This is the code I have so far: import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; public class MyFirstClass { public static void main(String[] args) { //load the card image from the gif file. final ImageIcon cardIcon = new ImageIcon("cardImages/tenClubs.gif"); JLabel lbl = new JLabel(cardIcon); //create a panel displaying the card image JPanel panel = new JPanel() { //paintComponent is called automatically by the JRE whenever //the panel needs to be drawn or redrawn public void paintComponent(Graphics g) { super.paintComponent(g); cardIcon.paintIcon(this, g, 20, 20); } }; lbl.setTransferHandler(null); MouseListener listener = new MouseAdapter() { public void mousePressed(MouseEvent me) { JComponent comp = (JComponent) me.getSource(); TransferHandler handler = comp.getTransferHandler(); handler.exportAsDrag(comp, me, TransferHandler.COPY); } }; lbl.addMouseListener(listener); //create &amp; make visible a JFrame to contain the panel JFrame window = new JFrame("Cards"); window.add(panel); window.setPreferredSize(new Dimension(200,200)); window.pack(); window.setVisible(true); } } Thank you.
tagged with: drag-and-drop
tagged with: imageicon
has answer: http://stackoverflow.com/a/21617375
accepted answer: http://stackoverflow.com/a/21617375

http://stackoverflow.com/a/21666363
has body: JPA does not offer any globally applicable strategies for templating table/column names. Unfortunately, due to your code conventions, you are going to have to specify table names and column names manually using JPA annotations like @Table(name=...) and @Column(name=...). It seems appropriate to avoid these code conventions here. Code conventions are generally put in place to improve the readability of source code and make software maintenance easier. In this particular case, the conventions are not improving either case.
accepted answer of: http://stackoverflow.com/q/21666016
upvote count: 2
has comment: http://stackoverflow.com/comment/32750299
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33542230
type: Answer
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/21666016

http://stackoverflow.com/q/21579756
has answer: http://stackoverflow.com/a/21581246
has body: I have List &lt; ViewHolder > data : private List&lt;ViewHolder&gt; pizza = new ArrayList&lt;ViewHolder&gt;(); pizza.add(new ViewHolder("7", "Наполеон" ,"bu salad3","25300")); pizza.add(new ViewHolder("7", "Дьяволо" ,"bu salad3","25300")); pizza.add(new ViewHolder("7", "Карбонара" ,"bu salad3","25300")); pizza.add(new ViewHolder("7", "Кольцоне прошуто" ,"bu salad3","25300")); pizza.add(new ViewHolder("7", "Питта" ,"bu salad3","25300")); pizza.add(new ViewHolder("7", "Гавайская" ,"bu salad3","25300")); pizza.add(new ViewHolder("7", "С ветчиной" ,"bu salad3","25300"); pizza.add(new ViewHolder("7", "Пепперони" ,"bu salad3","25300")); How can I send this list data with JSON to server by POST request. Sorry, If I wrote with mistakes, because my english is not good.
has answer: http://stackoverflow.com/a/21579843
type: AnsweredQuestion
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has title: How can I convert List<ViewHolder> to JSON and send to server by POST request
tagged with: post
type: Question
accepted answer: http://stackoverflow.com/a/21579843
score: 0
answer count: 3
tagged with: android
possible better answer: http://stackoverflow.com/a/21579860
has answer: http://stackoverflow.com/a/21579860

http://stackoverflow.com/comment/32682529
comment on: http://stackoverflow.com/q/21628461
has text: - Start by replacing '@#' in your code by '$%'.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21556025
type: Answer
has body: A guess of what you might be looking for: import javax.measure.Measure; import javax.measure.quantity.Angle; import javax.measure.quantity.Length; import javax.measure.quantity.Quantity; import javax.measure.unit.NonSI; import javax.measure.unit.SI; import javax.measure.unit.Unit; public class JScienceUnits { public static void main(String[] args) { final Unit&lt;Angle&gt; rev = NonSI.REVOLUTION.times(Math.PI * 2); final Unit&lt;Length&gt; cm = SI.CENTI(SI.METER); final Unit&lt;? extends Quantity&gt; cm3rev = cm.pow(3).divide(rev); final Unit&lt;Length&gt; mm = SI.MILLI(SI.METER); //double d1 = 4.44 cm3rev; Measure&lt;Double, ? extends Quantity&gt; d1 = Measure.valueOf(4.44, cm3rev); //double d2 = 2.22 mm; Measure&lt;Double, Length&gt; d2 = Measure.valueOf(2.22, mm); //double d = d1/d2; Unit&lt;? extends Quantity&gt; resultUnit = cm3rev.divide(mm); Measure&lt;?, ?&gt; result = Measure.valueOf(d1.getValue() / d2.getValue(), resultUnit); System.out.println("resultUnit "+resultUnit); System.out.println("result "+result); } }
accepted answer of: http://stackoverflow.com/q/21542287
answers question: http://stackoverflow.com/q/21542287
score: 0
type: AcceptedAnswer

http://stackoverflow.com/q/21641003
has answer: http://stackoverflow.com/a/21641103
type: AnsweredQuestion
tagged with: newline
tagged with: java
has title: Forcing newline to print correctly again
type: Question
possible better answer: http://stackoverflow.com/a/21641031
accepted answer: http://stackoverflow.com/a/21641103
has answer: http://stackoverflow.com/a/21641037
has answer: http://stackoverflow.com/a/21641031
answer count: 3
has comment: http://stackoverflow.com/comment/32705636
tagged with: regex
score: 0
has comment: http://stackoverflow.com/comment/32705524
has body: I had to export a bunch of strings to a CSV that I opened in excel. The strings contained '\n' and '\t' which I needed included in the CSV so I did the following before exporting the data: public static String unEscapString(String s) { StringBuilder sb = new StringBuilder(); for (int i = 0; i &lt; s.length(); i++) { switch (s.charAt(i)) { case '\n': sb.append("\\n"); break; case '\t': sb.append("\\t"); break; default: sb.append(s.charAt(i)); } } return sb.toString(); } The problem is that I am now reimporting the data into Java but I can't figure out how to get the newline and tab to print correctly again. I've tried: s.replaceAll("\\n", "\n"); but it still ignores the newlines. Help? EDIT: Example of what i'm trying to do: Say one string in the CSV is "foo \n bar". When I import it using Java and i'm trying to print the same string to the console but have the newline behave correctly

http://stackoverflow.com/a/21616095
has comment: http://stackoverflow.com/comment/32685907
answers question: http://stackoverflow.com/q/21615307
has comment: http://stackoverflow.com/comment/32664362
downvote count: 0
has body: The problem is with: if(!t.isAlive()) t.start(); A thread can only be started once. From the JavaDoc: It is never legal to start a thread more than once. In particular, a thread may not be restarted once it has completed execution. This is why it works the first time, but not on subsequent attempts.
type: Answer
score: 2
upvote count: 2

http://stackoverflow.com/a/21629213
score: 2
answers question: http://stackoverflow.com/q/21629128
accepted answer of: http://stackoverflow.com/q/21629128
has comment: http://stackoverflow.com/comment/32694465
has body: You can use equations for a point on a circle using polar coordinates: circle_x = rot_center_x + radius * cos(angle) circle_y = rot_center_y + radius * sin(angle) Using this you'll get a center point for your new circle. Then you just need to increase (counter clock wise) or decrease (clockwise) your angle, blank screen and draw the circle again. The angle for trigonometric function is in radians, you have 2*pi radians in a full circle. So if you want angle zero degrees, put in 0. For 90 degrees, put in pi/2.0. For any other angle use this conversion formula: angle_rad = pi/180.0 * angle_degrees If you want to time your rotation you have to choose the angular speed of rotation omega. omega = 2*pi*f where f is frequency of rotation, for example f=1Hz means your object will rotate in full circle after one seecond. Omega is in radians per second, so if you have omega 10 radians, then your object will rotate 10 radians during one second, or 100 radians during 10 seconds. Now you have to determine how much angle you need to add each frame of animation: ang_inc = omega / fps_avg; ang += ang_inc; where fps_avg is measured average of frames per second.
type: AcceptedAnswer
downvote count: 0
upvote count: 2
type: Answer

http://stackoverflow.com/comment/32492319
type: Comment
has text: @KugathasanAbimaran - Welcome to stackOverflow mate.. You'll love it... :)
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21520267

http://stackoverflow.com/comment/32541588
type: AnswerComment
comment on: http://stackoverflow.com/a/21547550
type: Comment
has text: actually here's what I have I have a class calls IntegrationFileObject which have a field called id ( path of file) and I need to parse it to Json(as String) and put it in request. request would be like this {ifs:[{text:"sample1a",id:"\/sequel\/repository\/sample1\/sample1a",cls:"folder"‌​}, {text:"sample1b",id:"\/sequel\/repository\/sample1\/sample1b",cls:"folder"}, {text:"custlist.vpt",id:"\/sequel\/repository\/sample1\/custlist.vpt",cls:"file"‌​, leaf:true}]}
score: 0

http://stackoverflow.com/a/21644357
has comment: http://stackoverflow.com/comment/32711050
type: Answer
has comment: http://stackoverflow.com/comment/32711172
downvote count: 0
score: 1
has body: The IEEE 754 float representation of 0.98123453 is 32 bits of (sign, exp, mantissa): 0 01111110 11110110011001000110000 which is: 0.9812345504760742 in double precision, and cast back to float decimal representation: 0.98123455 The number of bits allocated to a single precision (float) is 32, and 64 bits for double precision. Further note that BigDecimal that is frequently suggested will store your number as a string, and not in IEEE754 format. It will do a conversion when it needs to act on the number, and while it has a better precision, it is awfully slow. EDIT. To clarify why it prints 0.98123455, we need to observe that it is the closest single precision representation of the number 0.98123453: 00111111011110110011001000101111 = 0.9812345 (sp) = 0.9812344908714294 (dp) 00111111011110110011001000110000 = 0.98123455 (sp) = 0.9812345504760742 (dp) 00111111011110110011001000110001 = 0.9812346 (sp) = 0.981234610080719 (dp) sp = single precision, dp = double precision The listing is for the [-1,+1] binary range around the number, and you can see that 0.98123453 is closest to the 10000 suffix of the mantissa, while 0.98123452 is closest to the 01111 suffix.
accepted answer of: http://stackoverflow.com/q/21644277
answers question: http://stackoverflow.com/q/21644277
upvote count: 1
type: AcceptedAnswer

http://stackoverflow.com/comment/32537824
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21546379
has text: The `finnally` code block will always be executed
score: 0

http://stackoverflow.com/a/21658711
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/21658541
has body: You can use String.format() function to generate hexadecimal codes of colors and then output them to a file, console, or whatever you like. public static void generateGrayscale() { StringBuilder s = new StringBuilder(); for (int i = 0; i &lt; 256; i++) { String color = String.format("%02X%02X%02X", i, i, i); s.append(String.format("&lt;tr&gt;&lt;td style='background-color:%s'&gt;&lt;/td&gt;", color)); } System.out.println(s); }
upvote count: 1
type: Answer

http://stackoverflow.com/q/21624741
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32676421
has comment: http://stackoverflow.com/comment/32677700
has comment: http://stackoverflow.com/comment/32676108
tagged with: batch-file
downvote count: 0
has body: I am running the batch file for compressing pdf through GhostScript. I am able to pass parameters and run the batch file from java. But, i get the following error, GPL Ghostscript 9.10: ** Could not open temporary file '' ** Unable to open the initial device, quitting. But this doesn't occur when i separately the batch file. gswin32c -dNOPAUSE -sDEVICE=tiff24nc -r300 -sCompression=lzw -sOutputFile=%1 "C:/source.pdf" Thanks, Pavithra M
tagged with: ghostscript
favorite count: 0
has comment: http://stackoverflow.com/comment/32676290
type: UnansweredQuestion
has title: GPL Ghostscript 9.10: **** Could not open temporary file '' **** Unable to open the initial device, quitting
upvote count: 1
answer count: 0
score: 1

http://stackoverflow.com/comment/32582232
type: Comment
score: 0
has text: so i think runtime is higher version. am i right..?
type: AnswerComment
comment on: http://stackoverflow.com/a/21570792

http://stackoverflow.com/comment/77508631
type: QuestionComment
has text: Make sure your mobile and localhost are connected to same internet. That means your both devices should have `same IP address`.
comment on: http://stackoverflow.com/q/21626406
score: 0
type: Comment

http://stackoverflow.com/q/21653048
has comment: http://stackoverflow.com/comment/32726177
upvote count: 27
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/40480
type: Question
has comment: http://stackoverflow.com/comment/32726143
tagged with: java
has comment: http://stackoverflow.com/comment/32726241
possible better answer: http://stackoverflow.com/a/21653111
has body: I have trouble with scope of variable. public static void main(String[] args){ int[] test={1,2,3}; test(test); System.out.println(test[0]+" "+test[1]+" "+test[2]); } static void test(int[] test){ test[0]=5; } I expected the output to 1 2 3, but the result was 5 2 3. Why I changed the value in the array in the method, but the original array changed?
score: 27
has title: Changing array in method changes array outside
has comment: http://stackoverflow.com/comment/32726215
has comment: http://stackoverflow.com/comment/32726226
accepted answer: http://stackoverflow.com/a/21653202
duplicate of: http://stackoverflow.com/q/12757841
answer count: 2
has comment: http://stackoverflow.com/comment/32726192
has comment: http://stackoverflow.com/comment/32726156
has comment: http://stackoverflow.com/comment/32726135
downvote count: 0
tagged with: variables
has comment: http://stackoverflow.com/comment/32726172
has comment: http://stackoverflow.com/comment/32726646
favorite count: 0
has answer: http://stackoverflow.com/a/21653202
duplicate of: http://stackoverflow.com/q/40480
has comment: http://stackoverflow.com/comment/32726131
tagged with: scope
linked to: http://stackoverflow.com/q/12757841
has answer: http://stackoverflow.com/a/21653111

http://stackoverflow.com/comment/32638115
type: QuestionComment
comment on: http://stackoverflow.com/q/21588423
type: Comment
has text: I am saying I do not believe it's possible to customize the JFileChooser without doing some code. How much depends on if you can simply extend the existing class and modify how it's drawing.
score: 0

http://stackoverflow.com/comment/32723218
comment on: http://stackoverflow.com/a/21651285
score: 0
has text: @KnowledgeGeek: no. When you pass in your SecondClass object into the method, you're passing in a reference to the original SecondClass object in main, and so the parameter points to the exact same object. Now you're filling in the fields of the original object. Now make sure that these changes conform to your homework instructions. It might make better sense for the parseNameInformation method to return a SecondClass object, in which case you would not give it a SecondClass parameter, and you *would* create a new object in the method and then return it.
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32487190
type: Comment
type: QuestionComment
has text: No it's not. You've not tried anything with instanceof yet.
score: 0
comment on: http://stackoverflow.com/q/21517210

http://stackoverflow.com/comment/32643980
score: 0
type: Comment
type: QuestionComment
has text: Registering with the GCM server for the newer API is all covered here : http://developer.android.com/google/gcm/client.html. Saving the regId on your own website is up to you depending on what web server you have implemented
comment on: http://stackoverflow.com/q/21606060

http://stackoverflow.com/comment/32586664
has text: You might want to reconsider your logic..
type: Comment
comment on: http://stackoverflow.com/q/21573540
score: 0
type: QuestionComment

http://stackoverflow.com/a/21562667
score: 0
accepted answer of: http://stackoverflow.com/q/21559081
has body: As mentioned in the comments above, "Order statistic trees" solved the problem I asked for elegantly, and in addition, were relatively easy to implement, and ultimately gave me an accepted submission for the challenge. Thanks!
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21559081
type: Answer

http://stackoverflow.com/comment/32561223
has text: http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21523272
score: 0

http://stackoverflow.com/a/21567602
has comment: http://stackoverflow.com/comment/32576699
type: Answer
answers question: http://stackoverflow.com/q/21567497
score: 0
has body: You can override the file but that would only work in IDE, if it would be executed as part of jar it would fail because it is not a file any more( its file inside file) Better to externalize file and read/overwrite from that location If you still would like to read this file and overwrite it then you can do something like Thread.getclassloader().get resource("/"); This will give you path up to your target/classes directory you can navigate to resources from here using double dots

http://stackoverflow.com/q/21669652
has comment: http://stackoverflow.com/comment/32772559
tagged with: java
has comment: http://stackoverflow.com/comment/32772495
type: Question
has comment: http://stackoverflow.com/comment/32780741
has comment: http://stackoverflow.com/comment/32792423
has answer: http://stackoverflow.com/a/22211827
accepted answer: http://stackoverflow.com/a/22211827
upvote count: 6
has comment: http://stackoverflow.com/comment/35542735
has answer: http://stackoverflow.com/a/34121984
possible better answer: http://stackoverflow.com/a/21710583
linked to: http://stackoverflow.com/q/17625345
has answer: http://stackoverflow.com/a/21710583
favorite count: 0
tagged with: android-studio
tagged with: android
score: 6
has body: I just switched to Android-Studio from Eclipse. I am trying to run my application after setting up the gradle files. The project builds with no errors, however I can not run my app because there are no android facets found. When I go to project structure there are no facets and I do not see any way to add a facet. How can I run my application?
has title: No Android Facet Found in Module
answer count: 4
has answer: http://stackoverflow.com/a/58986016
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/36081796
tagged with: android-gradle-plugin
downvote count: 0

http://stackoverflow.com/q/21637636
score: 16
type: Question
type: AnsweredQuestion
tagged with: java
answer count: 2
upvote count: 16
favorite count: 0
has body: Let's say I have a data model like this (pseudocode): @Entity Person { @OneToMany List&lt;PersonAttribute&gt; attributes; } @Entity PersonAttribute { @ManyToOne AttributeName attributeName; String attributeValue; } @Entity AttributeName { String name; } I have a Spring-Data-JPA repository defined such as: public interface PersonRepository extends PagingAndSortingRepository&lt;Person, Long&gt;, QueryDslPredicateExecutor&lt;Person&gt;{} I see in the QueryDSL documentation that there is a mechanism to Join from the Person to the PersonAttribute, but it looks like you need access to the QueryDsl Query object, which the client of the repository wouldn't have. What I would like to do with my Predicate is to find all those Persons that have an AttributeValue (there's one join) with a value of "blue" and an AttributeName (there's another join) with a name of "eyecolor". I'm not sure how I would do that with an any() and enforce that I only get those with eye_color=blue and not those with shoe_color=blue. I was hoping I could do something like this: QPerson person = QPerson.person; QPersonAttribute attribute = person.attributes.any(); Predicate predicate = person.name.toLowerCase().startsWith("jo") .and(attribute.attributeName().name.toLowerCase().eq("eye color") .and(attribute.attributeValue.toLowerCase().eq("blue"))); but with the any() in there it just matches anything with an attribute value of "blue" and anything with an "eye color" attribute regardless of color. How I can make those conditions apply to the same attribute within the set?
has answer: http://stackoverflow.com/a/61320460
tagged with: spring-data-jpa
tagged with: querydsl
possible better answer: http://stackoverflow.com/a/61320460
has answer: http://stackoverflow.com/a/21638881
downvote count: 0
accepted answer: http://stackoverflow.com/a/21638881
has title: Spring-Data-JPA with QueryDslPredicateExecutor and Joining into a collection
tagged with: spring-data

http://stackoverflow.com/q/21583218
has answer: http://stackoverflow.com/a/21599517
has body: Here is some code that is successfully being called about twice a second. The sound file is about 100ms long. It only plays once, but I expected this to keep playing it: the subsequent calls step over the play call without an exception thrown, but also without a sound. Is there an efficient way of making it work? InputStream knockAudio = fetchResourceFile().getData("mysound.wav"); try { final Media m = MediaManager.createMedia(knockAudio, "audio/wav"); onClickTask = new TimerTask() { @Override public void run() { m.cleanup(); // Here's something I tried, but had no effect m.prepare(); // I also tried this without cleanup m.play(); // But to start with just had this (no cleanup or prepare) } }; } catch (IOException ex) { Log.e(ex); }
has answer: http://stackoverflow.com/a/21583464
upvote count: 1
tagged with: audio
type: AnsweredQuestion
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/21599517
has title: How can I play a sound at regular intervals?
type: Question
possible better answer: http://stackoverflow.com/a/21595063
has answer: http://stackoverflow.com/a/21595063
answer count: 3
tagged with: codenameone
downvote count: 0
favorite count: 0

http://stackoverflow.com/comment/32710910
has text: Then the stack trace you have provided is not from your current code. See the last part of that line? That's exactly where the exception was thrown, which is impossible for an empty line. Run your app again, then without changing anything, edit your question with the stack trace and the code.
comment on: http://stackoverflow.com/q/21644248
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21613783
upvote count: 8
type: Answer
has body: The problem is that you are using &lt;property name="port" value="2023" /&gt; in your bean configuration, but the corresponding method in the ExampleClass is called setCarbonPort(int port). Solution: update either the xml to &lt;property name="carbonPort" value="2023" /&gt; or the method to setPort(int port).
score: 8
answers question: http://stackoverflow.com/q/21613703
downvote count: 0

http://stackoverflow.com/comment/32541478
score: 0
type: Comment
has text: please check this Issue and reply me Dileep please
type: QuestionComment
comment on: http://stackoverflow.com/q/21548270

http://stackoverflow.com/q/21677781
accepted answer: http://stackoverflow.com/a/21677822
tagged with: reflection
score: 0
tagged with: java
tagged with: methods
type: Question
answer count: 2
has title: Invoking Integer.parseInt method using reflection
possible better answer: http://stackoverflow.com/a/21678337
has answer: http://stackoverflow.com/a/21678337
has body: how can I call a parseInt function on some variable ? I want to do something like parseInt.invoke("23"); Note : I have an array of methods where parseInt is stored Method[] methods contains the parseInt method so... it's like methods[0].invoke("23"); but when i do this i get java.lang.IllegalArgumentException: wrong number of arguments at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at myproject.MyProject.main(MyProject.java:114)
has answer: http://stackoverflow.com/a/21677822
type: AnsweredQuestion

http://stackoverflow.com/a/21558476
has comment: http://stackoverflow.com/comment/32559601
type: Answer
answers question: http://stackoverflow.com/q/21556883
has body: What about use simple json library for delphi like this: JSON delphi library Delphi Web Utils superobject
score: 0

http://stackoverflow.com/comment/139108293
has text: from the page you have shared "A key limitation of the JDBC driver is that it cannot receive asynchronous notifications and must poll the backend to check if any notifications were issued. A timeout can be given to the poll function, but then the execution of statements from other threads will block."
score: 2
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/78521042

http://stackoverflow.com/q/21676518
has body: This is how my code looks: double test = (21757952*100)/63290718; Log.i("TAH", "test = " +test); It shows "test = -33" Why is the value wrong? Is it overflow ?
upvote count: 1
downvote count: 1
has answer: http://stackoverflow.com/a/21676564
type: Question
tagged with: java
score: 0
answer count: 3
accepted answer: http://stackoverflow.com/a/21676564
has answer: http://stackoverflow.com/a/21676577
favorite count: 0
has title: Why does the value of a simple computation give a wrong result in java? Does it overflow?
possible better answer: http://stackoverflow.com/a/21676577
has comment: http://stackoverflow.com/comment/32766510
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21676873

http://stackoverflow.com/comment/32553430
type: Comment
comment on: http://stackoverflow.com/a/21555281
type: AnswerComment
has text: Since all of the mentioned overloads of `of` call the exact same `create` method, I don't see how they could possibly do anything differently (like fixing the size).
score: 0

http://stackoverflow.com/q/21538993
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32526042
tagged with: java
has comment: http://stackoverflow.com/comment/32525875
has comment: http://stackoverflow.com/comment/32525910
type: Question
has title: Java and Batch doesn't want to load main class
has comment: http://stackoverflow.com/comment/32525833
has answer: http://stackoverflow.com/a/21539179
score: 0
tagged with: batch-file
answer count: 1
has body: @echo off title Windows color a set mainclass="Interface" :start if exist "%HOMEDRIVE%/Program Files (x86)/Java/jre7/bin/" goto x64(J7) if exist "%HOMEDRIVE%/Program Files/Java/jre7/bin/" goto x86(J7) if exist "%HOMEDRIVE%/Program Files (x86)/Java/jre6/bin/" goto x64(J6) if exist "%HOMEDRIVE%/Program Files/Java/jre6/bin/" goto x86(J6) if defined java goto :x121 :x121 CLS java -Xmx1024m %mainclass% pause exit :x64(J6) CLS "%HOMEDRIVE%/Program Files (x86)/Java/jre6/bin/java.exe" -Xmx1024m %mainclass% pause exit :x86(J6) CLS "%HOMEDRIVE%/Program Files/Java/jre6/bin/java.exe" -Xmx1024m %mainclass% pause exit :x64(J7) CLS "%HOMEDRIVE%/Program Files (x86)/Java/jre7/bin/java.exe" -Xmx1024m %mainclass% pause exit :x86(J7) CLS "%HOMEDRIVE%/Program Files/Java/jre7/bin/java.exe" -Xmx1024m %mainclass% pause exit This problem has been occurring with ONLY this program. Every time I try to load my java program via this batch script, which has worked every since its inception, it gives me a "could not find or load main class" error. Some one please inform me what I'm doing wrong since I just tested this code out with a different java file not 5 minutes ago and it worked.
has comment: http://stackoverflow.com/comment/32525849

http://stackoverflow.com/comment/32574701
comment on: http://stackoverflow.com/q/21566561
has text: John... do you want it to iterate over every row in the first column then move to the second, or do you want to handle the entire array of rows for the first column?
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/32622470
score: 0
type: AnswerComment
has text: @peeskillet Too true! I'm not entirely sure how you meant that, but given the number of down-votes I've made (thousands) and [bounties I've offered](http://stackoverflow.com/users/418556/andrew-thompson?tab=bounties) (totaling 2150 rep.points) I figure I *could* have made 100K rep. a month ago.
type: Comment
comment on: http://stackoverflow.com/a/21593127

http://stackoverflow.com/q/21528455
possible better answer: http://stackoverflow.com/a/70834009
has comment: http://stackoverflow.com/comment/32507834
has body: i'm experiencing problem on a BasicQuery with Sping Here is my query : public List&lt;Voyage&gt; getVoyages(String destination, Date datedebut, int duree) throws MongoException { Query query = new Query(); Calendar c = Calendar.getInstance(); c.setTime(datedebut); c.add(Calendar.DATE,duree); BasicQuery q= new BasicQuery("{$or : [{paysDestination : {$elemMatch : {nom : '"+destination+"'}}},{paysPrincipal : {nom : '"+destination+"'}}], debut : {$lte : {$date : "+datedebut+"}}, fin : {$gte : {$date : "+c.getTime()+"}}}"); return mongoTemplate.find(q, Voyage.class); } I have documents on my database, but i don't receive anyone, my list is empty. In addition, i don't catch any MongoException ... Have you got an solution ?
tagged with: spring
tagged with: mongotemplate
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32552659
has answer: http://stackoverflow.com/a/70834009
tagged with: java
has comment: http://stackoverflow.com/comment/32554756
type: Question
has comment: http://stackoverflow.com/comment/32506658
tagged with: mongodb
has comment: http://stackoverflow.com/comment/32507454
accepted answer: http://stackoverflow.com/a/21555356
answer count: 2
has comment: http://stackoverflow.com/comment/32507699
has answer: http://stackoverflow.com/a/21555356
score: 0
has title: MongoDb Date error Java

http://stackoverflow.com/comment/32565920
type: AnswerComment
comment on: http://stackoverflow.com/a/21549061
score: 0
type: Comment
has text: This does seem right, but after this I'd have to cast my Object statically which would contradict the whole purpose of dynamic, wouldn't it? ;)

http://stackoverflow.com/comment/32661801
type: AnswerComment
type: Comment
has text: @keshlam yep, then it would have been just one pass.
comment on: http://stackoverflow.com/a/21615110
score: 1

http://stackoverflow.com/a/21676848
answers question: http://stackoverflow.com/q/21676713
has body: You could use a PriorityBlockingQueue and use timestamps to define priorities - something like: class Task { AtomicLong lastRun; Runnable r; void run() { r.run(); lastRun.set(System.currentMillis); } } Your ScheduledExecutorService (one thread) can then add the task N to a PriorityQueue every Interval(N). And you can have a separate consumer running in your FixedThreadPool that takes from the Queue (using a reverse comparator so that the tasks run more recently will have a lower priority). That is a little sketchy but it should work.
has comment: http://stackoverflow.com/comment/32768258
type: Answer
has comment: http://stackoverflow.com/comment/32768014
has comment: http://stackoverflow.com/comment/32797707
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/32768321
has comment: http://stackoverflow.com/comment/32767925
downvote count: 0
has comment: http://stackoverflow.com/comment/32845122

http://stackoverflow.com/comment/32632803
comment on: http://stackoverflow.com/a/21599683
score: 0
type: AnswerComment
has text: Try to do this for this last problem: http://stackoverflow.com/questions/7870265/unable-to-execute-dex-multiple-dex-files-define-lcom-myapp-rarray
type: Comment

http://stackoverflow.com/a/21602293
score: 0
has body: Just sketchy, but you could use (1) a desired Class, (2) reflection public static &lt;T&gt; T getValue(Class&lt;T&gt; klazz, Object value) { try { // Try whether value has correct type: return klazz.cast(value); } catch (ClassCastException e) { // Try whether klazz has static .valueOf(String) // Then value not null: String s = value.toString(); Method valueOf = klazz.getDeclaredMethod("valueOf", String.class); int modifiers = valueOf.getModifiers(); if (Modifiers.isStatic(modifiers)) { valueOf.setAccessible(true); return valueOf.invoke(null, s); } } throw new IllegalArgumentException(value); } double x = getValue(Double.class, "12.34");
type: Answer
answers question: http://stackoverflow.com/q/21601854
has comment: http://stackoverflow.com/comment/32641867

http://stackoverflow.com/comment/32724336
has text: initialize the subtotal variable outside before the if block, whatever initialize inside the block remains in the scope of the block and cannot be accessed outside the block
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21651924
score: 0

http://stackoverflow.com/comment/32505016
type: Comment
has text: @MarkoTopolnik correct. I found the actual issue and posted an answer.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21526893

http://stackoverflow.com/q/21522075
has answer: http://stackoverflow.com/a/21524200
tagged with: text
score: 3
tagged with: java
has comment: http://stackoverflow.com/comment/32502641
tagged with: selenium
downvote count: 1
type: Question
upvote count: 4
has body: Suppose i have one document then how can i select text from that document using Selenium WebDriver. I have entered below code: d1.findElementByClassName("odd").click(); Thread.sleep(5000); d1.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS); WebElement el = d1.findElement(By.id("doc-content")); Actions act = new Actions(d1); act.clickAndHold(el).build().perform(); act.release().perform(); act.doubleClick(el).build().perform(); act.clickAndHold(el).build().perform(); WebElement el1 = d1.findElement(By.id("doc-data")); act.moveToElement(el1, 50, 50).build().perform(); act.dragAndDropBy(el, 100, 150).build().perform(); act.release().build().perform();
answer count: 1
tagged with: highlight
favorite count: 0
has comment: http://stackoverflow.com/comment/32503673
type: UnansweredQuestion
has title: How can i select text from one document using selenium webdriver

http://stackoverflow.com/q/21602980
type: Question
type: AnsweredQuestion
tagged with: weblogic
has body: In my App (Fusion Web) exist a ViewObject from Oracle DB. I created the java classes and build a specific method (makeUniqueSearchByDate(String)) to process the data. This method appears in "Data controls" that I can drag to the "view" and use as any other function. When I try to use it in a "bean" (instead of dragging directly): public void setDate(ActionEvent actionEvent) { ApplicationModule appMod = Configuration.createRootApplicationModule("com.svr.model.AppModule", "AppModuleLocal"); ViewModelosByDataImpl fo = (ViewModelosByDataImpl) appMod.findViewObject("ViewModelosByData1"); String dateV = "07-01-2013"; fo.makeUniqueSearchByDate(dateV); } This code has no effect on the table. Can anyone see why? Btw, the program does not throw any exception. Just does not work. The table remains the same. But if I use the button, automatically generated by "drag and drop" the function runs normally. I know I should study ADF, but unfortunately I have no time.
tagged with: java
has answer: http://stackoverflow.com/a/21628571
accepted answer: http://stackoverflow.com/a/21628571
score: 0
answer count: 1
tagged with: web
has title: Execute function from model in viewcontroller
tagged with: oracle-adf

http://stackoverflow.com/q/21563891
type: Question
downvote count: 4
upvote count: 0
favorite count: 0
answer count: 5
has answer: http://stackoverflow.com/a/21564004
tagged with: regex
has comment: http://stackoverflow.com/comment/32569351
has answer: http://stackoverflow.com/a/21563967
has body: I have a string 1,11,cda74944-1c61-4325-8137-83a4ab50cb81-A00123,Bs000000216,20140204185143.811 Can you provide me regular expression or java string function to get the sub string: cda74944-1c61-4325-8137-83a4ab50cb81-A00123 ?
has comment: http://stackoverflow.com/comment/32569348
type: UnansweredQuestion
score: -4
has answer: http://stackoverflow.com/a/21563957
tagged with: java
has title: Regular expression to find a middle of a String in Java
has answer: http://stackoverflow.com/a/21564017
has answer: http://stackoverflow.com/a/21563962

http://stackoverflow.com/a/21641076
has comment: http://stackoverflow.com/comment/32714816
has body: Does the user need to see the data placed on the model for the /first or /second page? If not, how about try changing: return "/second"; to return "redirect:/second"; and return "/third"; to return "redirect:/third"; If the user needs to see the data on /first or /second page for X time, how about doing the redirect from javascript? Edited: How about flash attributes, see this post: reading flash attributes @RequestMapping("/first") String first(ModelMap model, final RedirectAttributes redirectAttributes) { model.put("list", new ArrayList&lt;String&gt;()); redirectAttributes.addFlashAttribute("list", new ArrayList&lt;String&gt;()); return "redirect:/second"; } @RequestMapping("/second") String second(ModelMap model, final RedirectAttributes redirectAttributes) { List list = (List) model.get("list"); list.add("A"); redirectAttributes.addFlashAttribute("list", list); return "redirect:/third"; } @RequestMapping("/third") String third(ModelMap model, final RedirectAttributes redirectAttributes) { List list = (List) model.get("list"); list.add("B"); redirectAttributes.addFlashAttribute("list", list); return "end"; }
score: 0
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21637838
type: Answer
accepted answer of: http://stackoverflow.com/q/21637838

http://stackoverflow.com/comment/32613041
score: 3
comment on: http://stackoverflow.com/a/21587979
type: AnswerComment
has text: No, the result will still be incorrect because it doesn't have the same distribution as summing N independent rolls of the dice.
type: Comment

collections
tags question: http://stackoverflow.com/q/21659204
tags question: http://stackoverflow.com/q/21527859
tags question: http://stackoverflow.com/q/21626644
tags question: http://stackoverflow.com/q/21525697
tags question: http://stackoverflow.com/q/21659695
tags question: http://stackoverflow.com/q/21598320
tags question: http://stackoverflow.com/q/21599450
tags question: http://stackoverflow.com/q/21667362
tags question: http://stackoverflow.com/q/21648038
tags question: http://stackoverflow.com/q/21590510
tags question: http://stackoverflow.com/q/21645825
tags question: http://stackoverflow.com/q/21557972
tags question: http://stackoverflow.com/q/21544103
tags question: http://stackoverflow.com/q/21626979
tags question: http://stackoverflow.com/q/21656769
tags question: http://stackoverflow.com/q/21611881
tags question: http://stackoverflow.com/q/21676140
tags question: http://stackoverflow.com/q/21584581
tags question: http://stackoverflow.com/q/21534224
tags question: http://stackoverflow.com/q/21604298
tags question: http://stackoverflow.com/q/21592485
tags question: http://stackoverflow.com/q/21619420
tags question: http://stackoverflow.com/q/21629719
type: Tag
tags question: http://stackoverflow.com/q/21665538
tags question: http://stackoverflow.com/q/21612621
tags question: http://stackoverflow.com/q/21600289
tags question: http://stackoverflow.com/q/21596847
tags question: http://stackoverflow.com/q/21552288
tags question: http://stackoverflow.com/q/21614675
tag name: collections
tags question: http://stackoverflow.com/q/21560566
tags question: http://stackoverflow.com/q/21653245
tags question: http://stackoverflow.com/q/21644368
tags question: http://stackoverflow.com/q/21576082
tags question: http://stackoverflow.com/q/21658335
tags question: http://stackoverflow.com/q/21577160
tags question: http://stackoverflow.com/q/21606748
tags question: http://stackoverflow.com/q/21614258
tags question: http://stackoverflow.com/q/21620155
tags question: http://stackoverflow.com/q/21612196
tags question: http://stackoverflow.com/q/21523993

http://stackoverflow.com/comment/32707761
comment on: http://stackoverflow.com/q/21548393
score: 0
has text: There was some different error. As kettleCSV reader takes the default escape sequence.
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21556538
type: Answer
has body: As far as I know! string is immutable object. It means that its state cannot be changed, when ever you append value to string type then what happened is compiler deletes old one create new one with apended value. But this is not the case with StringBuilder. StringBuilder is mutable which means its old value won't be destroyed. Any change/append will be taken place with existing object. I know I am not covering in depth but this might cause major performance difference.
downvote count: 1
score: -1
upvote count: 0
answers question: http://stackoverflow.com/q/21556322

http://stackoverflow.com/comment/32646255
comment on: http://stackoverflow.com/q/21607570
score: 0
type: Comment
type: QuestionComment
has text: Are there really different files for each combination? That seems quite odd.

http://stackoverflow.com/q/21561183
tagged with: java
has answer: http://stackoverflow.com/a/21561241
score: 0
accepted answer: http://stackoverflow.com/a/21565872
answer count: 3
has title: Assigning multiple variables in one string - Java
has answer: http://stackoverflow.com/a/21565872
has answer: http://stackoverflow.com/a/21561592
possible better answer: http://stackoverflow.com/a/21561241
type: AnsweredQuestion
tagged with: java.util.scanner
has body: How do I assign values to multiple varibles from one line of string. For example. String time = sc.next(); // the amount of time to delay from shutdown String timeframe = sc.next(); // time frame : seconds, minutes, ect If this would be for a shutdown code, and the user enters "10 mins", how would I assign the variable 10 to an integer (of course after I parse it), and use the time frame (along with some math) to create the delay to the shutdown. The end goal, for this part of the program, is to give the user the ability to enter one clean command "shutdown 10 mins", and to have windows schedule a shutdown 10 minutes from now. Currently, the user would have to do : "shutdown" [ENTER] "10" [ENTER] "mins" [ENTER]. The rest of the program is fine, only this gives me the problem of irregularity. Complete code for class : public void Start() { Scanner sc = new Scanner(System.in); int xtime = 0; boolean goodTime = false, goodTimeFrame = false; String time = sc.next(); String timeframe = sc.next(); try { xtime = Integer.parseInt(time); if(xtime&lt;0) { System.out.println("time cannot be less than 0..."); } else if(xtime&gt;=0) { goodTime = true; } } catch(Exception e){ System.out.println("invalid input..."); } try { switch(timeframe.toLowerCase()) { case "secs": xtime = xtime*1000; goodTimeFrame = true; break; case "mins": xtime = xtime*60000; goodTimeFrame = true; break; case "hrs": xtime = xtime*3600000; goodTimeFrame = true; break; default: System.out.println("invalid timeframe, use: secs, mins, or hrs..."); break; } } catch(Exception e){ System.out.println("cannot convert to valid time..."); } if(goodTime &amp;&amp; goodTimeFrame) { try { Runtime.getRuntime().exec("Elevate.exe shutdown -s -t "+xtime); } catch(Exception e){ System.out.println("error ordering shutdown command..."); } } else { System.out.println("syntex example : shutdown time timeframe" + "\nshutdown 10 mins"); } }
type: Question

http://stackoverflow.com/comment/32558351
has text: @Filip - Marshal out your object model to see what you should pass in on the unmarshal. You are getting that exception because you are not including an `xsi:type` in your XML. See: http://blog.bdoughan.com/2010/11/jaxb-and-inheritance-using-xsitype.html
comment on: http://stackoverflow.com/a/21554146
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/q/21564738
has answer: http://stackoverflow.com/a/21574546
possible better answer: http://stackoverflow.com/a/21564776
tagged with: constructor
type: Question
accepted answer: http://stackoverflow.com/a/21564797
has answer: http://stackoverflow.com/a/21564776
tagged with: java
answer count: 3
has comment: http://stackoverflow.com/comment/32572220
downvote count: 1
has title: Can you call two different overloaded constructors from in the same instance of a class in java?
has comment: http://stackoverflow.com/comment/32571181
has body: I am working on a simple calculator problem and i am making a class specifically to handle the operations. I am making two constructors within the class one taking one int and one taking two. What i plan to do is that when the user inputs the first number into the program, the first constructor will be called and the first number will be saved. When they enter the second number, the same instance of the class will be called but this time with both the variables in a constructor. Is this possible? Is there an easier way to do this? thanks.
upvote count: 0
has answer: http://stackoverflow.com/a/21564797
has comment: http://stackoverflow.com/comment/32571145
has comment: http://stackoverflow.com/comment/32571446
tagged with: class
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32571152
tagged with: calculator
favorite count: 0
score: -1

http://stackoverflow.com/q/21660060
tagged with: android
has answer: http://stackoverflow.com/a/21660188
has body: I try to create an application in android platform with 3 fragments When I try to input some java code inside the fragment class, i have always this error: java.lang.NullPointerException For example, with a simple button to change view: package com.test; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; public class creation extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.creation, container, false); final Button ok = (Button)getView(). findViewById(R.id.button3); ok.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // Create new fragment and transaction Fragment newFragment = new mesvideos(); // consider using Java coding conventions (upper char class names!!!) FragmentTransaction transaction = getFragmentManager().beginTransaction(); // Replace whatever is in the fragment_container view with this fragment, // and add the transaction to the back stack transaction.replace(R.layout.creation, newFragment); transaction.addToBackStack(null); // Commit the transaction transaction.commit(); } }); return root ; } Or with a VideoView : mVideoView = (VideoView) findViewById(R.id.videoView1); mVideoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.presentation)); mVideoView.setMediaController(new MediaController(this)); mVideoView.requestFocus();
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32738226
tagged with: android-fragments
tagged with: java
tagged with: android-videoview
type: Question
has title: java code doesn't work in fragment activity
answer count: 1
has comment: http://stackoverflow.com/comment/32738337
score: 0

http://stackoverflow.com/comment/32724357
type: AnswerComment
has text: yeah, that's the problem. the example doesn't match the output
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21652078

http://stackoverflow.com/q/21542450
answer count: 2
tagged with: pdf-conversion
downvote count: 0
tagged with: libreoffice
favorite count: 0
type: UnansweredQuestion
score: 6
has body: I have 1000 .docx files that I want to convert to pdf so I have written a program to do this, but I can never get through all 1000 files before an error is thrown. I start a headless version of LibreOffice using soffice --headless --accept="socket,host=127.0.0.1,port=2002;urp;". I am using LibreOffice 4.2.0.4 and JODConverter 2.2.2. This is my conversion code (prior to this I just iterate all the .docx files in a directory): try { File inputFile = new File(sourceFile); if (!inputFile.exists()) { return -1; } File outputFile = new File(destFile); OpenOfficeConnection connection = new SocketOpenOfficeConnection(host_Str, Integer.parseInt(port_Str)); connection.connect(); DocumentConverter converter = new OpenOfficeDocumentConverter(connection); converter.convert(inputFile, outputFile); connection.disconnect(); return 0; } catch (ConnectException e) { System.out.println("Openoffice listener exception!"); return 1; } I can always convert at least 50 files or so before an error is thrown; this is one of the errors I have had: Exception in thread "main" com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException: conversion failed: could not save output document; OOo errorCode: 3088 at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.loadAndExport(OpenOfficeDocumentConverter.java:142) at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.convertInternal(OpenOfficeDocumentConverter.java:120) at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:104) at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:74) at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:70) at previews.ConvertToPdfJOD.office2PDF(ConvertToPdfJOD.java:119) at previews.ConvertToPdfJOD…
has answer: http://stackoverflow.com/a/22666537
tagged with: ms-office
upvote count: 6
tagged with: java
type: Question
tagged with: jodconverter
has title: Converting docx to pdf via JODConverter and LibreOffice causes error
has answer: http://stackoverflow.com/a/35774839

http://stackoverflow.com/a/21613396
has body: I suggest starting with the textbox and button and writing the results to the screen or to the log to see that it's working. http://www.javabeginner.com/java-swing/java-jtextfield-class-example Then work on displaying a list, and refresh the list with the data in the textbox as a last step. Lists (note the "Adding Items to and Removing Items from a List" section): http://docs.oracle.com/javase/tutorial/uiswing/components/list.html
answers question: http://stackoverflow.com/q/21613048
score: 0
type: Answer

http://stackoverflow.com/a/21640335
answers question: http://stackoverflow.com/q/21640318
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32704507
has comment: http://stackoverflow.com/comment/32704411
type: Answer
score: 25
upvote count: 25
has body: Try this, You can't create a new string like your doing. String string = "{\"id\":100,\"firstName\":\"Adam\"}"; Student student = mapper.readValue(string, Student.class);
accepted answer of: http://stackoverflow.com/q/21640318
has comment: http://stackoverflow.com/comment/127707018
has comment: http://stackoverflow.com/comment/32704594

http://stackoverflow.com/comment/32638272
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/21603176
has text: How is this related to servlets?

http://stackoverflow.com/q/21517432
has answer: http://stackoverflow.com/a/21517543
accepted answer: http://stackoverflow.com/a/21517543
tagged with: java
possible better answer: http://stackoverflow.com/a/21518491
type: Question
has answer: http://stackoverflow.com/a/21518491
has body: How often is garbage collected in Java (on a regular PC and on an Android phone)? I tried looking it up, but did not get a number. I know it probably depends on a lot of factors, but I just want a rough idea.
duplicate of: http://stackoverflow.com/q/6909150
score: 0
answer count: 2
has title: How often is garbage collected in Java?
tagged with: android
tagged with: garbage-collection
linked to: http://stackoverflow.com/q/6909150
tagged with: garbage
type: AnsweredQuestion

http://stackoverflow.com/q/21623064
has answer: http://stackoverflow.com/a/21624135
possible better answer: http://stackoverflow.com/a/21623505
has answer: http://stackoverflow.com/a/21623505
linked to: http://stackoverflow.com/q/5936003
has body: I want to create a HTML document in Java code, how can I do that effectively with Java SE 1.7, without relying on third party libs? Goal would be to not have to manually append html strings together and get some help with keeping the html valid.
has comment: http://stackoverflow.com/comment/32673544
answer count: 3
accepted answer: http://stackoverflow.com/a/21623832
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/32673214
upvote count: 1
type: AnsweredQuestion
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/21623832
has title: Create HTML document
type: Question

http://stackoverflow.com/comment/32529990
type: Comment
type: QuestionComment
has text: Conditions are just for example. The point is how do I pass different values into the same function which then changes and returns the same value
comment on: http://stackoverflow.com/q/21541183
score: 0

http://stackoverflow.com/comment/32561319
type: QuestionComment
has text: System.out.println("Which is your favorite fruit?"); System.out.println("1) Apple"); System.out.println("2) Banana"); System.out.println("3) Orange"); System.out.print("Your Selection: "); selectFruit = input.nextInt(); System.out.println("Your favorite fruit is : " + selectFruit);
comment on: http://stackoverflow.com/q/21559535
score: 0
type: Comment

http://stackoverflow.com/a/21547592
answers question: http://stackoverflow.com/q/21546961
has comment: http://stackoverflow.com/comment/32544575
has comment: http://stackoverflow.com/comment/32541325
has comment: http://stackoverflow.com/comment/32540257
has body: replaceFirst creates a new string by using a StringBuffer on my version of the jdk. So, assuming the length of the regex and the replacement strings are small, it is O(n) due to the string copy, with n the length of the initial: public String replaceFirst(String replacement) { if (replacement == null) throw new NullPointerException("replacement"); reset(); if (!find()) return text.toString(); StringBuffer sb = new StringBuffer(); appendReplacement(sb, replacement); appendTail(sb); return sb.toString(); } Notes: The regex matching in itself should be O(1) though. if there is no match, then replaceFirst goes to return text.toString() which returns the string itself: if there is no match, it is an O(1) operation. startsWith + substring used to be O(1) (when substring was a view on the string, i.e. until Java 7u5) but is now O(n) too (since Java 7y6 substring creates a new string by copying the underlying char array). Update I have quickly tested the performance of the operation to confirm the above by matching an empty string and a long string with a regex using a ^ anchor and one without it. The result (in nanosecond per call): p1s1 (empty string, "^x") 47.561 nsec/op p1s2 (long string, "^x") 50.753 nsec/op p2s1 (empty string, "x") 47.526 nsec/op p2s2 (long string, "x") 131.015 nsec/op So you can see that the "^x" regex drops the analyses at the first character because the time is (almost) the same with an empty or long string. Code, using jmh for benhcmarking: private String s1 = ""; private String s2 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "x"; private static final Pattern p1 = Pattern.compile("^x"); private static final Pattern p2 = Pattern.compile("x"); @GenerateMicroBenchmark public boolean p1s1() { return p1.matcher(s1).find(); } @GenerateMicroBenchmark public boolean p1s2() { return p1.matcher(s2).find(); } @GenerateMicroBenchmark public boolean p2s1() { return p2.matcher(s1).fi…
has comment: http://stackoverflow.com/comment/32540024
has comment: http://stackoverflow.com/comment/32541499
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32541066
has comment: http://stackoverflow.com/comment/32541375
type: Answer
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/32539968
accepted answer of: http://stackoverflow.com/q/21546961

http://stackoverflow.com/comment/32662823
type: Comment
score: 3
type: QuestionComment
has text: @TomaszBekas why bother converting to a List... just print with `Arrays.toString()` or `Arrays.deepToString()`
comment on: http://stackoverflow.com/q/21616534

http://stackoverflow.com/comment/32683052
has text: Crimson is no longer bundled with the JRE, but if you download it yourself and add it to your application's classpath (or add a dependency if you're using a dependency manager) then it should still work.
score: 0
type: Comment
comment on: http://stackoverflow.com/q/21628542
type: QuestionComment

http://stackoverflow.com/q/21536572
downvote count: 0
accepted answer: http://stackoverflow.com/a/21541415
has comment: http://stackoverflow.com/comment/32522123
linked to: http://stackoverflow.com/q/192920
favorite count: 0
possible better answer: http://stackoverflow.com/a/21538173
has comment: http://stackoverflow.com/comment/32529403
has answer: http://stackoverflow.com/a/21538173
answer count: 3
has answer: http://stackoverflow.com/a/24189988
linked to: http://stackoverflow.com/q/4818699
has comment: http://stackoverflow.com/comment/32529509
tagged with: datetime
has comment: http://stackoverflow.com/comment/32528638
has comment: http://stackoverflow.com/comment/32521861
has comment: http://stackoverflow.com/comment/32527768
has comment: http://stackoverflow.com/comment/32537219
tagged with: uuid
score: 12
has comment: http://stackoverflow.com/comment/32528401
has comment: http://stackoverflow.com/comment/32522103
linked to: http://stackoverflow.com/q/14532976
has answer: http://stackoverflow.com/a/21541415
tagged with: logging
has comment: http://stackoverflow.com/comment/42799979
linked to: http://stackoverflow.com/q/17970873
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32523081
tagged with: java
has comment: http://stackoverflow.com/comment/32528238
has comment: http://stackoverflow.com/comment/32528808
has body: There are several posts on SO on this topic. Each of those talk about a specific approach so wanted to just get a comparison in one question. Using new Date() as unique identifier Generating a globally unique identifier in Java I am trying to implement a feature where we are able to identify certain events in the log file. These events need to be associated with a unique id. I am trying to come up with a strategy for this unique ID generation. The ID has to have 2 parts : some static information + some dynamic information The logs can be searched for the pattern when debugging of events is needed. I have three ways : static info + Joda Date time("abc"+2014-01-30T12:36:12.703) static info + Atomic Integer static info + UUID For the scope of this question, multiple JVMs is not a consideration. I need to generate unique IDs in an efficient manner on one JVM. Also, I will not be able to use a database dependent solution. Which of the 3 above mentioned strategies works best ? If not one from the above, any other strategy ? Is the Joda time based strategy robust ? The JVM is single but there will be concurrent users so there can be concurrent events. In conjunction with one of the above/other strategies, Do I need to make my method thread-safe / synchronized ?
type: Question
has title: Generate unique ID in Java, to label groups of related entries in a log
has comment: http://stackoverflow.com/comment/32522040
upvote count: 12

algorithm
tags question: http://stackoverflow.com/q/21640337
tags question: http://stackoverflow.com/q/21556993
tags question: http://stackoverflow.com/q/21579099
tags question: http://stackoverflow.com/q/21648397
tags question: http://stackoverflow.com/q/21532588
tags question: http://stackoverflow.com/q/21642862
tag name: algorithm
tags question: http://stackoverflow.com/q/21576148
tags question: http://stackoverflow.com/q/21633997
tags question: http://stackoverflow.com/q/21672954
tags question: http://stackoverflow.com/q/21666986
tags question: http://stackoverflow.com/q/21654017
tags question: http://stackoverflow.com/q/21586083
tags question: http://stackoverflow.com/q/21515552
tags question: http://stackoverflow.com/q/21568501
tags question: http://stackoverflow.com/q/21559779
tags question: http://stackoverflow.com/q/21677400
tags question: http://stackoverflow.com/q/21559951
tags question: http://stackoverflow.com/q/21565552
tags question: http://stackoverflow.com/q/21566972
tags question: http://stackoverflow.com/q/21598937
tags question: http://stackoverflow.com/q/21516642
tags question: http://stackoverflow.com/q/21521807
tags question: http://stackoverflow.com/q/21622660
tags question: http://stackoverflow.com/q/21662322
tags question: http://stackoverflow.com/q/21602836
tags question: http://stackoverflow.com/q/21614168
type: Tag
tags question: http://stackoverflow.com/q/21606063
tags question: http://stackoverflow.com/q/21610045
tags question: http://stackoverflow.com/q/21621735
tags question: http://stackoverflow.com/q/21516069
tags question: http://stackoverflow.com/q/21648170
tags question: http://stackoverflow.com/q/21652237
tags question: http://stackoverflow.com/q/21517486
tags question: http://stackoverflow.com/q/21648704
tags question: http://stackoverflow.com/q/21670732
tags question: http://stackoverflow.com/q/21612287
tags question: http://stackoverflow.com/q/21633384
tags question: http://stackoverflow.com/q/21602753
tags question: http://stackoverflow.com/q/21622911
tags question: http://stackoverflow.com/q/21618050
tags question: http://stackoverflow.com/q/21639900
tags question: http://stackoverflow.com/q/21561914
tags question: http://stackoverflow.com/q/21613204
tags question: http://stackoverflow.com/q/21637241
tags question: http://stackoverflow.com/q/21576292
tags question: http://stackoverflow.com/q/21651837
tags question: http://stackoverflow.com/q/21614108

http://stackoverflow.com/comment/32756739
has text: @ A Paul My main aim is to deploy the data from the servlet web application to the google app engine datastore. And that data is comin to the servlet from the jsp .
type: Comment
comment on: http://stackoverflow.com/a/21598861
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32687530
has text: You should actually never us assertions to catch logic failure because assertions might be turned off. So there for your logic WILL fail. But if, ofc, it is only used for dev purposes it could be placed there. I would throw an IllegalArgumentException, but it's debatable..
comment on: http://stackoverflow.com/a/21631098
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/21587504
score: 2
upvote count: 2
accepted answer of: http://stackoverflow.com/q/21587385
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21587385
has body: The List#add method in Java returns a boolean indication of whether the value ws successfully added to the List or not. You should separate adding a new List to your Map from adding a new element to it: Hashtable&lt;Character, List&lt;Boolean&gt;&gt; charCheck = new Hashtable&lt;Character, List&lt;Boolean&gt;&gt;(); char[] charArray = str.toCharArray(); for (char c : charArray) { List&lt;Boolean&gt; used = charCheck.get(c); // If the char isn't in the map yet, add a new list if (used == null) { used = new ArrayList&lt;Boolean&gt;(); charCheck.put (c, used); } used.add(false); }
type: Answer
downvote count: 0

http://stackoverflow.com/a/21630283
answers question: http://stackoverflow.com/q/21630131
upvote count: 1
type: Answer
has body: Why not implement a fromLong method in the enum public static MyEnum fromLong(long l) { switch (l) { { case 0: return FIRST; case 1: return SECOND; case 2: return THIRD; } throw new IllegalArgumentException(); } and then convert longs to the enum and compare enums. So you would have: MyEnum.fromLong(longValue) == MyEnum.FIRST
downvote count: 0
score: 1

http://stackoverflow.com/comment/32487608
has text: dud just do like this Button retrieveLocationButton = (Button) findViewById(R.id.retrieve_location_button);
comment on: http://stackoverflow.com/a/21517412
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32565732
has text: It is not good practice to close System.in especially if your program intends to use it again. In general, I think that System.in and System.out are things that are "left hanging" because the the JVM sets them up for you when it starts. You should leave it up to the JVM to close these resources on the way out.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21561349

http://stackoverflow.com/comment/32492292
has text: just add your code at last of your question I'll see it and stack trace too.
type: AnswerComment
comment on: http://stackoverflow.com/a/21519636
score: 0
type: Comment

http://stackoverflow.com/comment/32615402
score: 0
type: AnswerComment
has text: @JamesHobson - I guess it boils down to Person class looking suspiciously a lot like a Service would in a typical N-tier application. Consider writing a unit test. If Person were a service without getFirstName()/getLastName() you'd just test marry(Person person1, Person person2). But in this setup you have to test your setters and getters as well.
type: Comment
comment on: http://stackoverflow.com/a/21588852

http://stackoverflow.com/comment/32680486
type: Comment
has text: @AndrewThompson whenever a user clicks on a button i assigned to each column
type: QuestionComment
comment on: http://stackoverflow.com/q/21626699
score: 0

http://stackoverflow.com/comment/32534466
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21527870
type: Comment
has text: Show us the code what you are doing and the stack trace.

http://stackoverflow.com/a/21556063
answers question: http://stackoverflow.com/q/21555921
score: 0
type: Answer
has body: What you need is to create a Source Folder in your Project as the one called src but with a different name. To refer the files from this folder on Windows you just need to indicate the Project's name and the resource name as it: getResource("ProjectName/Default.xml") I hope this helps!

http://stackoverflow.com/comment/32660055
has text: When I use it I disable swipe gestures to open and close. There is a way to disable just to open?
type: Comment
comment on: http://stackoverflow.com/a/21614719
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32719607
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21648602
score: 1
has text: Now that you provided code, and if I understand it correctly, I would say that I stick to my initial answer. The view names apply to a specific type of data. So these constants should probably be in PersonView, and PersonView should probably be an enum. It makes no sense to apply a `byGender` view on a collection containing cars or appointments or whatever. For cars, you would have a CarView class or enum containing BY_COLOR and BY_MODEL.

http://stackoverflow.com/q/21649998
tagged with: java
downvote count: 0
has title: Different messages written to catalina.out
answer count: 1
score: 1
tagged with: tomcat
favorite count: 0
has answer: http://stackoverflow.com/a/21650051
type: UnansweredQuestion
has body: What are the various messages written to catalina.out? I understand tomcat's internal logging messages land here, but I also see some INFO messages. Why are logging messages typically of log4j logging in catalina.out? What other messages are written to this file?
upvote count: 1
type: Question

http://stackoverflow.com/comment/32545072
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21549319
has text: You're right, but singleton could handle the socket internally (create, destroy, open, whatever). Another approaches could be better, but this is perfectly valid. Singleton works as a wrapper that abstracts the rest of the application of the low-level management of the socket.
type: AnswerComment

http://stackoverflow.com/a/21565130
has comment: http://stackoverflow.com/comment/32573860
answers question: http://stackoverflow.com/q/21565104
type: Answer
score: 2
upvote count: 2
accepted answer of: http://stackoverflow.com/q/21565104
has comment: http://stackoverflow.com/comment/32573877
has body: Maybe try someting like: [BCMVZ]+ it find any tags combinations with this chars BCMVZ.
has comment: http://stackoverflow.com/comment/32572010
has comment: http://stackoverflow.com/comment/32572083
has comment: http://stackoverflow.com/comment/32571951
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32572033
has comment: http://stackoverflow.com/comment/32573825

http://stackoverflow.com/comment/32614656
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21587190
has text: Sorry, it was parasitic trace. Fixed.
score: 0

installanywhere
type: Tag
tags question: http://stackoverflow.com/q/21592347
tag name: installanywhere

http://stackoverflow.com/comment/32531847
has text: Do you have a **specific** question, or you just want someone to do your work for you?
score: 2
comment on: http://stackoverflow.com/q/21542287
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32602358
type: Comment
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/21582108
has text: What do you mean by `contributing plug-ins`?

http://stackoverflow.com/comment/32798124
score: 1
comment on: http://stackoverflow.com/q/21673480
type: Comment
type: QuestionComment
has text: It is a param that you should put on web.xml. I don't know the details behind Mojarra, but I suppose it exists a similar parameter but I don't know if it will work, because we had to do some special stuff to make it work long time ago, different to the default algorithm proposed by the spec. What I can tell you is the param was added in MyFaces precisely to fix these situations. Switch to MyFaces is easy and will make your life more easier. Try the 2.2.0 artifacts.

http://stackoverflow.com/a/21621712
downvote count: 0
has body: If you want all the unique members of a data structure, you use a TreeSet, which is wholly intended for that purpose, to wit: A collection that contains no duplicate elements. The elements are ordered using their natural ordering, or by a Comparator provided at set creation time, depending on which constructor is used. Define your Comparator and hashCode method that differentiates on name -- the 3rd column and it will do what you'd like.
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/21620916

http://stackoverflow.com/q/21530334
has body: I am currently working on an app that supports plug ins. The plug ins are located in a root folder called modules as jar files. My main application loads all the jars located in the modules folder using the java service loader Application src modules My modules have the following folder structure: PlugIn src resources Images used by the plug in are stored in the resources folder. My problem is I cannot seem to load these image files no matter what i do. I have tried using getClass().getResource() etc like what the previous posts suggested but with no luck. Can anybody suggest a possible solution to this? EDIT The plug ins are the ones that load the resources. The main app does not touch the plug in's resources
has answer: http://stackoverflow.com/a/21530552
score: 0
has title: Problems using image resources of plug in jars
accepted answer: http://stackoverflow.com/a/21530552
type: AnsweredQuestion
tagged with: java
type: Question
tagged with: serviceloader
answer count: 1

http://stackoverflow.com/a/21533282
has body: Not alot to go on but something like this, and capture group 1 contains data of interest. (?-s)\.START_SEQUENCE.*\n.*\n([\S\s]*?)\.END_SEQUENCE
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/21533078
downvote count: 0
has comment: http://stackoverflow.com/comment/32515552
type: Answer

http://stackoverflow.com/q/21534257
accepted answer: http://stackoverflow.com/a/21534500
type: AnsweredQuestion
has title: How to Control Multiple threads of Same Object?
tagged with: java
type: Question
score: 0
answer count: 1
has body: following is inside my button click in android protected onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState) public void onClick(View arg0) { if(connectThread!=null) { connectThread.kill(); } connectThread=new ConnectThread(device); connectThread.start(); } } I have made a boolean volatile variable running in ConnectThread class which is true by default and kill method will set it value to false. Problem is that still it is not working the reason may be that in my ConnectThread run method im creating another thread but that should not be the problem since that gets called from the run method and since that will be child thread of ConnectThread; on killing connectThread that will automatically get cancelled? kill method of ConnectThread public void kill() { running=false; } run method of ConnectThread public void run() { while(running) { } }
has answer: http://stackoverflow.com/a/21534500
has comment: http://stackoverflow.com/comment/32559507
tagged with: android

http://stackoverflow.com/comment/32705740
has text: well i could make tail point towards node aswell but does it really matter?
comment on: http://stackoverflow.com/q/21641102
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/q/21657220
answer count: 1
has comment: http://stackoverflow.com/comment/32733487
has comment: http://stackoverflow.com/comment/32742017
tagged with: jframe
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32733458
has comment: http://stackoverflow.com/comment/32733462
has comment: http://stackoverflow.com/comment/32733468
has comment: http://stackoverflow.com/comment/32733333
tagged with: java
tagged with: jpanel
has answer: http://stackoverflow.com/a/21657600
type: Question
tagged with: layout
tagged with: arrays
has title: How to display multiple panels from an array in a frame using a loop
has body: I have never been very good at using java graphical interfaces. I am creating a program that will create an array of "contact" and display them to a frame. I can add, delete, and sort the array correctly. I just cannot get it to display to the screen right. I have run into several variations of incorrect displaying. No matter what I do I cannot seem to get the "contact" to display right. I mean that when this program is run a jframe should appear, containing 4 contacts with a picture and text information. then the user can delete one of the contacts and the program should show a new alphabetically sorted list without the deleted contact. The issue im having is getting my contacts to display in a jframe. When i run the program the contacts appear but only if in the main method i call my show function every time a new contact is added. otherwise the jframe only shows the last contact added until the program is told which contact to delete. then the jframe displays too many contacts. Please help me figure out what I'm doing wrong. I apologize for my bad formatting. this is the first time I have used this site. /* blake yacavone advanced programming project 1 */ import java.util.Scanner; public class project1Tester { public static void main(String[] args) { Scanner input = new Scanner(System.in); contactArrayList list = new contactArrayList(); contact beatle1 = new contact("Paul", 1284, "Beverly Hills", "California", 90209, "paul.jpg", "vocals"); list.addContact(beatle1); list.showContacts(); contact beatle2 = new contact("Pete", 1284, "Beverly Hills", "California", 90209, "pete.jpg", "drummer"); list.addContact(beatle2); list.showContacts(); contact beatle3 = new contact("John", 1284, "Beverly Hills", "California", 90209, "john.jpg", "vocals"); list.addContact(beatle3); list.showContacts(); contact beatle4 = new contact("George", 1284, "Beverly Hills", "California", 90209, "george.jpg", "vocals"); list.addContact(beatle4); list.showContacts(); System.out.println("pleas…
score: 0
has comment: http://stackoverflow.com/comment/32733427

http://stackoverflow.com/comment/32757517
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21626527
has text: well the error turned out to be the intent.. if i hide it the emulator has no problem working...
score: 0

http://stackoverflow.com/a/21536458
has body: Wallet wallet = new Wallet(); wallet.put(money);
answers question: http://stackoverflow.com/q/21536423
downvote count: 0
type: Answer
score: 5
has comment: http://stackoverflow.com/comment/32521634
upvote count: 5

http://stackoverflow.com/comment/32597950
has text: @nikmin in `GetLocationFromMap(LatLng arg0)` the `Latitud` and `Longitud` strings have correct coordinate values. In debugger i see, `txtLatitude` and `txtLongitude` are null before doing setText(), but when I arrive to this line, crashes
comment on: http://stackoverflow.com/q/21576942
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21615667
has body: To execute a script, you can use Runtime.exec(..) to launch a shell (sh, bash, etc..). These shells can execute a script that is either provided as a file, or read from standard input. The latter option can be leveraged here. Runtime.exec(..) returns a Process object, and you can obtain its input and output streams. Fetch the resource from your bundle as described here How do I access a file inside an OSGi bundle? and pass that data to your stream.
answers question: http://stackoverflow.com/q/21576670
type: Answer
score: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21576670

http://stackoverflow.com/q/21574873
has body: how to display a dyanamically generated jtree or tree model in ui ?is there any tree structure in jsp or any simple tree model in javascript or jquery please suggest.I searched in web there some jquery tree examples are there but is there any easy way to display jtree in ui?please give your valuable suggestions
favorite count: 0
upvote count: 2
type: UnansweredQuestion
score: 2
answer count: 0
tagged with: java
has comment: http://stackoverflow.com/comment/32588933
has title: how to display a dyanamically generated jtree or tree model in ui
type: Question
downvote count: 0
tagged with: jsp

http://stackoverflow.com/comment/32550104
score: 0
has text: How does it fail? You send the message and the message is not available on the other side? What type of SocketChannel are you using (blocking/nonblocking)?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21553208

http://stackoverflow.com/comment/32595625
score: 3
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21578776
has text: I dont think that is the proper way. either remove the parameter score from constructor or use addQuizScore method. Dont keep both.

http://stackoverflow.com/q/21665697
type: AnsweredQuestion
tagged with: jsf
upvote count: 1
type: Question
tagged with: conditional-statements
has answer: http://stackoverflow.com/a/21905701
score: 1
tagged with: java
tagged with: hibernate
has body: I am developing a website with JSF 2.0, hibernate and primefaces. I'm implementing an admin panel where the website admin can put the whole application on &quot;maintenance mode&quot;. This is done by changing a flag on an application scoped bean (called on purpose AppConfigurationBean). If the flag is active the user is necessarily returned to a page, called maintenance.xhtml, by a conditional navigation rule declared in faces-config.xml. The user can bypass the maintenance page by inserting a special bypass key which can be given seldom by the admin. If he does so, a flag is activated on a special session scoped bean, which holds information about the user and is called CurrentClientSessionBean. The navigation rule works if the value returned from a special method on the CurrentClientSessionBean, which take in counts the maintenance mode flag on the application bean and the &quot;has bypass key&quot; flag on himself. Here is the navigation rule on faces-config.xml: &lt;navigation-rule&gt; &lt;description&gt;System&lt;/description&gt; &lt;from-view-id&gt;*&lt;/from-view-id&gt; &lt;navigation-case&gt; &lt;display-name&gt;Maintenance Mode&lt;/display-name&gt; &lt;from-outcome&gt;*&lt;/from-outcome&gt; &lt;if&gt;#{currentClientSessionBean.toReturnToMaintenance}&lt;/if&gt; &lt;to-view-id&gt;/maintenance.xhtml&lt;/to-view-id&gt; &lt;redirect /&gt; &lt;/navigation-case&gt; &lt;/navigation-rule&gt; Here is the maintenance.xhtml page: &lt;ui:composition id=&quot;maintenance&quot; xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:h=&quot;http://java.sun.com/jsf/html&quot; xmlns:f=&quot;http://java.sun.com/jsf/core&quot; xmlns:ui=&quot;http://java.sun.com/jsf/facelets&quot; xmlns:p=&quot;http://primefaces.org/ui&quot; xmlns:plm=&quot;http://java.sun.com/jsf/composite/plmCustomComponents&quot;&gt; &lt;f:verbatim&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/f:verbatim&gt; &lt;html&gt; &lt;h:head&gt; &lt;title&gt;#{msg.applicationTitle}&lt;/title&gt; &lt;meta charset=&quot;UTF-8&quo…
tagged with: navigation
has title: Conditional navigation not working properly in JSF
answer count: 1
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/21905701

http://stackoverflow.com/a/21579572
answers question: http://stackoverflow.com/q/21574468
has body: You should check by MD5, not file size You can calculate your MD5 while you're reading the stream. See https://stackoverflow.com/a/304350/3230038 Then, after saving the file, you can generate the md5 again and compare UPDATE - here's my more detailed idea for this. I am assuming that you just want to calculate the MD5 without having to bring the whole byte[] into memory. In this case, I think you have 2 options calculate MD5 on the fly, as you're saving, then after saving, check md5 again (if you're on linux you can just use md5sum) calculate MD5 in a first pass, then save the file in a second pass. for example import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.security.DigestInputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.NullOutputStream; public class MD5OnTheFly { /** * @param args * @throws NoSuchAlgorithmException * @throws IOException */ public static void main(String[] args) throws NoSuchAlgorithmException, IOException { long ini = System.currentTimeMillis(); File file = new File("/home/leoks/Downloads/VirtualBox-4.3.0.tar"); System.out.println("size:"+file.length()); InputStream is = new FileInputStream(file); MessageDigest md = MessageDigest.getInstance("MD5"); DigestInputStream dis = new DigestInputStream(is, md); IOUtils.copy(dis, new NullOutputStream()); byte[] digest = md.digest(); StringBuffer hexString = new StringBuffer(); for (int i = 0; i &lt; digest.length; i++) { String hex = Integer.toHexString(0xff &amp; digest[i]); if (hex.length() == 1) hexString.append('0'); hexString.append(hex); } System.out.println(hexString); long end = System.currentTimeMillis(); System.out.println(end-ini+" millis"); } } returns 410859520 dda81aea75a83b1489662c6bcd0677e4 1413 millis and then [leoks@home ~]$ md5sum /home/leoks/Downloads/VirtualBox-4.3.0.tar dda81aea75a83b1489662c6b…
type: Answer
score: 1
upvote count: 1
downvote count: 0

http://stackoverflow.com/comment/32615146
score: 0
has text: The XML is working. 415 error is supposed to be a media type error (ie Content-Type not properly defined).
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21588727

http://stackoverflow.com/a/21589821
answers question: http://stackoverflow.com/q/21589784
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/81953625
has body: You need to place all statements after the declarations in a code block, e.g. method rather than the class block. Logically it probably makes sense to place all statements in the code block but the non-declarative statements need to be enclosed within the new block private void processFile() { data.put("1", new Object[]{"ID","NAME", "LASTNAME"}); // &lt;--Syntax error ...//snip } catch (Exception e) { e.printStackTrace(); } }
has comment: http://stackoverflow.com/comment/106232765
score: 9
has comment: http://stackoverflow.com/comment/82004724
upvote count: 9
has comment: http://stackoverflow.com/comment/81956234

http://stackoverflow.com/a/21559082
has body: You can create a class that implements the MouseListener interface as so: public class CustomMouseListener implements MouseListener{ public void mouseClicked(MouseEvent e) { statusLabel.setText("Mouse Clicked: ("+e.getX()+", "+e.getY() +")"); } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } } You want define each of those methods based on the action the method represents (which are self explanatory). The MouseEvent object will have all the info you need related to the mouse (ex. x and y position of mouse). Now you want to add this new MouseListener to a JPanel (which in this case is your Board class): //JPanel panel = new JPanel(); Board panel = new Board(); panel.addMouseListener(new CustomMouseListener()); Source
accepted answer of: http://stackoverflow.com/q/21558916
answers question: http://stackoverflow.com/q/21558916
upvote count: 1
type: Answer
downvote count: 0
score: 1
type: AcceptedAnswer

http://stackoverflow.com/a/21570276
type: AcceptedAnswer
downvote count: 0
has body: The first problem is that you're trying to use an instance of Class as a type cast. That's not valid - it has to be a type. That aside, if you try to do (I've renamed myObj to MyObj for clarity / proper naming): ImyObj testObj = new MyObj(); MyObj testObj2 testObj.getClass().cast(testObj); It won't work. testObj.getClass() is going to return a Class&lt;? extends ImyObj&gt; which is "Something that extends ImyObject". It can't be used to cast to a specific subclass; that's what the error is saying. If you used: MyObj testObj2 = MyObj.class.cast(testObj); It would work; you're using the specific class. The same would be true if you had: MyObj mo = new MyObj(); MyObj testObj2 mo.getClass().cast(testObj); In this case mo.getClass() returns a Class&lt;? extends MyObj&gt; which can be used to cast to a MyObj because the target is a MyObj rather than some subclass of MyObj And if testObj wasn't an instance of MyObj it would throw a java.lang.ClassCastException
type: Answer
upvote count: 7
score: 7
accepted answer of: http://stackoverflow.com/q/21569868
answers question: http://stackoverflow.com/q/21569868

http://stackoverflow.com/comment/32695342
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21540260
has text: Good hack. But I cannot modify the library
score: 0

http://stackoverflow.com/comment/32548481
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21538798
has text: Hmm, all the other examples talk about reading from a file and writing in an array, which is very different from reading from an Arraylist and writing in a text file.
score: 0

http://stackoverflow.com/comment/32565781
comment on: http://stackoverflow.com/a/21560685
type: AnswerComment
has text: If I was doing a simple xml design; SAX seems fine. For something more complicated check out JAXB. Also, Spring has great JAXB support (and Castor and JiBX as well as others).
score: 0
type: Comment

http://stackoverflow.com/comment/32621546
has text: Rename your class, or explicitly refer to `new java.awt.Polygon`, which is the class you're trying to construct. The issue is that the compiler is looking for the constructor `(int[], int[], int)` in *your* Polygon class rather than the one from the core Java API.
score: 1
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21593014

http://stackoverflow.com/comment/32609132
comment on: http://stackoverflow.com/q/21585829
type: Comment
type: QuestionComment
score: 2
has text: JavaScript is also object oriented and it is as useless as Java if you do not want to learn something new :)

http://stackoverflow.com/q/21566956
linked to: http://stackoverflow.com/q/463155
upvote count: 1
type: Question
downvote count: 4
has answer: http://stackoverflow.com/a/21567073
has comment: http://stackoverflow.com/comment/32575940
has comment: http://stackoverflow.com/comment/32575368
answer count: 1
favorite count: 0
has body: I have come across the following regular expression in a program and struggling to understand what is trying to do. Can anyone help me please? I have only started to learn this l = Z + lo &lt;= lf ? lo : lf - z;
accepted answer: http://stackoverflow.com/a/21567073
score: -3
has comment: http://stackoverflow.com/comment/32575403
tagged with: regex
type: AnsweredQuestion
has title: How to evaluate Regular expression?
tagged with: java

http://stackoverflow.com/q/21581008
tagged with: java
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21582709
accepted answer: http://stackoverflow.com/a/21582709
has title: Single Page Application: page reload
score: 0
answer count: 1
tagged with: client-side
has body: I've simple SPA and I make log out on reloading. As I understand the disadvantage of NOT logging out on reloading is to reinitialization of the whole application. Questions: What are the disadvantages of NOT logging off at Single Page Application? What is the best way to achive NOT loging of on reloading (F5)?
tagged with: single-page-application
tagged with: architecture

http://stackoverflow.com/q/21643499
has body: Java won't stop reading from input. I understand that maybe this while loop might have something to do with it: while(input.hasMoreTokens()); { array1[counter] = input.nextToken(); counter++; } But I don't see why the loop should be a problem because I am already calling .nextToken() which should advance the token. Here's the full source code: import java.io.*; import java.util.*; class HelloWorld { static String ReadLn (int maxLg) // utility function to read from stdin { byte lin[] = new byte [maxLg]; int lg = 0, car = -1; String line = ""; try { while (lg &lt; maxLg) { car = System.in.read(); if ((car &lt; 0) || (car == '\n')) break; lin [lg++] += car; } } catch (IOException e) { return (null); } if ((car &lt; 0) &amp;&amp; (lg == 0)) return (null); // eof return (new String (lin, 0, lg)); } public static void main (String args[]) // entry point from OS { HelloWorld myWork = new HelloWorld(); // create a dinamic instance myWork.Begin(); // the true entry point } void Begin() { String idata; StringTokenizer input; while ((idata = HelloWorld.ReadLn (255)) != null) { input = new StringTokenizer (idata); String[] array1 = {}; int counter = 0; while(input.hasMoreTokens()); { array1[counter] = input.nextToken(); counter++; } int[] array2 = {}; for(int a = 0; a &lt; array1.length; a++) { array2[a] = Integer.parseInt(array1[a]); } int[] array3 = {}; for(int b = 0; b &lt; array2.length; b++) { if ( array2[b] != 42) { array3[b] = array2[b]; } else { break; } } String string = ""; for( int c = 0; c &lt; array3.length; c++) { if( c &lt; array3.length - 1) { string += array3[c] + "\n"; } else { string += array3[c]; } } System.out.println(string); } } }
has title: Java won't stop reading from input
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/21643511
upvote count: 1
type: Question
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21643511
answer count: 1
downvote count: 0
favorite count: 0

http://stackoverflow.com/q/21559814
downvote count: 1
has answer: http://stackoverflow.com/a/21560195
has comment: http://stackoverflow.com/comment/32562099
type: Question
type: AnsweredQuestion
tagged with: java
score: -1
has comment: http://stackoverflow.com/comment/32561867
linked to: http://stackoverflow.com/q/5827679
has title: Locking by synchronization
has comment: http://stackoverflow.com/comment/32562249
answer count: 3
has body: Hi my question is how synchronization works? In simple words we know that if a thread entered in a synchronization block by acquiring lock on any reference, than no other thread acquire that lock until first one exit from synchronized block. But my question is if the thread acquired a lock on a reference and execute methodA() in that method there is a synchronized block, than can other thread acquire a lock on same reference and execute methodB(), there is also a synchronized block in it?
upvote count: 0
accepted answer: http://stackoverflow.com/a/21560195
favorite count: 0
has comment: http://stackoverflow.com/comment/32562419
possible better answer: http://stackoverflow.com/a/21559884
has answer: http://stackoverflow.com/a/21559884
has answer: http://stackoverflow.com/a/21560073
has comment: http://stackoverflow.com/comment/32562295
has comment: http://stackoverflow.com/comment/32561837
tagged with: multithreading
has comment: http://stackoverflow.com/comment/32562376

http://stackoverflow.com/a/21624294
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/21624138
downvote count: 0
has body: Quite simple, you need to get the text nodes out of the element, and then take the first of it, so the solution is something like: element.textNodes().get(0);

http://stackoverflow.com/q/21633623
has comment: http://stackoverflow.com/comment/32696502
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/22303091
tagged with: jscrollpane
has comment: http://stackoverflow.com/comment/32696535
has body: i am a student of Computer Sciences in the Netherlands and i am working on an assignment in which i have to draw a couple of shapes. To make these shapes look better i set the render hints antialiasing on. But now my problem is that when i scroll with my JScrollPanel to where the shapes are not on the screen and then scroll back it seems that the antialiasing and transparacy aren't working correctly. In the image linked below i have scrolled to halfway the shape and then scrolled back. Link to image I really have no good idea about where the problem resides so i have provided the full code off the class below. You can download the full eclipse project folder here. I'd like to thank you in advance, Milan v. Dijck import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.*; import javax.imageio.ImageIO; import javax.swing.*; @SuppressWarnings("serial") public class AgendaPanel extends JPanel{ private final int WIDTH = 24; // width in hours private final Color BUTTON_TOP_GRADIENT = new Color(250, 250, 250); private final Color BUTTON_BOTTOM_GRADIENT = new Color(210, 210, 210); private ArrayList&lt;Line&gt; lines = new ArrayList&lt;Line&gt;(); private ArrayList&lt;Shape&gt; shadowBoxes = new ArrayList&lt;Shape&gt;(); private ArrayList&lt;Shape&gt; itemBoxes = new ArrayList&lt;Shape&gt;(); private ArrayList&lt;Image2D&gt; images = new ArrayList&lt;Image2D&gt;(); private ArrayList&lt;String2D&gt; names = new ArrayList&lt;String2D&gt;(); public AgendaPanel(){ setPreferredSize(new Dimension(WIDTH*100, 300)); drawGrid(); } public void drawGrid(){ for(int i=100; i &lt; WIDTH*100; i+=100){ lines.add(new Line(i,0,i,300,Color.GRAY)); } for(int i=50; i &lt; WIDTH*100; i+=100){ lines.add(new Line(i,0,i,300, Color.LIGHT_GRAY)); } // change to the amount of podia for(int i=75; i &lt; 300; i+=75){ lines.add(new Line(0, i, WIDTH*100, i, Color.black)); } repaint(); } @Overri…
has comment: http://stackoverflow.com/comment/32695715
tagged with: java-2d
has answer: http://stackoverflow.com/a/21674233
has title: Java2D graphics inside JScrollPanel don't come out well
type: UnansweredQuestion
tagged with: swing
tagged with: rendering
tagged with: java
has comment: http://stackoverflow.com/comment/32705752
has comment: http://stackoverflow.com/comment/32692541
type: Question
has comment: http://stackoverflow.com/comment/32694523

http://stackoverflow.com/q/21530752
tagged with: persistence
has comment: http://stackoverflow.com/comment/32513295
has comment: http://stackoverflow.com/comment/33219721
tagged with: postgresql
answer count: 1
favorite count: 0
tagged with: ejb-3.0
type: UnansweredQuestion
has title: Parsing thrown custom exceptions from PostgreSQL to EJB?
has body: We wish to have a system where PostgreSQL throws a custom exceptions detailing the error condition when performing a transaction, for example insufficient funds, item already sold etc. The interim solution is for retrieving the com.postgresql.util.PSQLException that is wrapped in a PersistenceException. However this forces the package to have a build and test dependency on the PostgreSQL library, losing some modularity. Is there some way we can return and parse an exception from PostgreSQL in a more elegant or more standard way?
score: 1
has answer: http://stackoverflow.com/a/21531372
tagged with: java
upvote count: 1
type: Question
downvote count: 0

http://stackoverflow.com/comment/32565319
type: AnswerComment
has text: For some reason its not printing out anything? Could you help? It prints out "The unique numbers were" but thats it, no unique numbers? Not sure where its messing up
type: Comment
comment on: http://stackoverflow.com/a/21559751
score: 0

http://stackoverflow.com/a/21651944
has comment: http://stackoverflow.com/comment/32724350
type: Answer
has body: This is because of scoping. Variables exists inside the block they are declared in (there are also other rules, so you would like to read further on this). Since the first subTotal is declared in the if block (delimited by {}), you can only use it inside that block. To fix this you can try declaring subtotal before those if statements: double subtotal = 0; // declaration and initialization if (gasQuality==87) { subtotal = unleaded * gallonsSold; // don't declare again } else if (gasQuality==89) ... Also, you could use a switch statement instead of those if-else if statements: switch (gasQuality) { case 87: subtotal = ...; break; case 89: subtotal = ...; break; default: break; }
has comment: http://stackoverflow.com/comment/32724155
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/32724107
accepted answer of: http://stackoverflow.com/q/21651924
has comment: http://stackoverflow.com/comment/32724188
answers question: http://stackoverflow.com/q/21651924
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/21669272
tagged with: class
has answer: http://stackoverflow.com/a/21669494
has title: Java referencing a class in the same directory
has comment: http://stackoverflow.com/comment/32754629
has body: I created a Pair class in Java (similar to the c++ pair) and am having trouble referencing it from a different java file. I am working inside a Java file, let's call it fileA in the same directory as Pair.class. Additionally, I have written package current-directory at the top of both files. However, when I try javac fileA all my errors are cannot find symbol and the little arrow points to my custom Pair type. How do I get the java compiler to see Pair.class inside of fileA? Thanks for all the help
favorite count: 0
type: UnansweredQuestion
tagged with: package
answer count: 4
has comment: http://stackoverflow.com/comment/32754670
has answer: http://stackoverflow.com/a/21669487
has comment: http://stackoverflow.com/comment/32754730
tagged with: java
score: 24
upvote count: 24
tagged with: import
type: Question
has answer: http://stackoverflow.com/a/64486812
downvote count: 0
has answer: http://stackoverflow.com/a/21669457

http://stackoverflow.com/comment/32666337
score: 0
type: Comment
has text: Are you trying to produce something you can double-click to run?
comment on: http://stackoverflow.com/q/21618594
type: QuestionComment

http://stackoverflow.com/a/21574718
has body: Javadoc for setSoTimeout(int) says this: Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds. With this option set to a non-zero timeout, a call to accept() for this ServerSocket will block for only this amount of time. If the timeout expires, a java.net.SocketTimeoutException is raised, though the ServerSocket is still valid. The option must be enabled prior to entering the blocking operation to have effect. The timeout must be > 0. A timeout of zero is interpreted as an infinite timeout. Try this: welcomeSocket.setSoTimeout(0); Add this statement before you block the server for accepting request from the client. Note: Make sure that both the machines are accessible to each other to ensure proper connection.
has comment: http://stackoverflow.com/comment/32589035
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21574610

hashmap
tags question: http://stackoverflow.com/q/21667362
tags question: http://stackoverflow.com/q/21672909
tags question: http://stackoverflow.com/q/21577365
tags question: http://stackoverflow.com/q/21607570
tags question: http://stackoverflow.com/q/21637752
tags question: http://stackoverflow.com/q/21620155
tags question: http://stackoverflow.com/q/21570517
tags question: http://stackoverflow.com/q/21563996
tags question: http://stackoverflow.com/q/21635919
tags question: http://stackoverflow.com/q/21676884
tags question: http://stackoverflow.com/q/21581026
tags question: http://stackoverflow.com/q/21611458
tags question: http://stackoverflow.com/q/21559811
tags question: http://stackoverflow.com/q/21616234
type: Tag
tags question: http://stackoverflow.com/q/21672954
tags question: http://stackoverflow.com/q/21665538
tags question: http://stackoverflow.com/q/21649727
tags question: http://stackoverflow.com/q/21568418
tags question: http://stackoverflow.com/q/21672382
tags question: http://stackoverflow.com/q/21638080
tags question: http://stackoverflow.com/q/21528929
tags question: http://stackoverflow.com/q/21536302
tags question: http://stackoverflow.com/q/21656023
tags question: http://stackoverflow.com/q/21600344
tags question: http://stackoverflow.com/q/21519149
tags question: http://stackoverflow.com/q/21579560
tags question: http://stackoverflow.com/q/21661983
tags question: http://stackoverflow.com/q/21621803
tags question: http://stackoverflow.com/q/21535029
tags question: http://stackoverflow.com/q/21612693
tag name: hashmap
tags question: http://stackoverflow.com/q/21656030
tags question: http://stackoverflow.com/q/21587345
tags question: http://stackoverflow.com/q/21613261
tags question: http://stackoverflow.com/q/21566605
tags question: http://stackoverflow.com/q/21660010

http://stackoverflow.com/q/21570992
upvote count: 2
answer count: 2
favorite count: 0
has comment: http://stackoverflow.com/comment/32582404
possible better answer: http://stackoverflow.com/a/21571103
tagged with: android
has comment: http://stackoverflow.com/comment/32582737
tagged with: http://stackoverflow.com/tag/xml
score: 2
type: AnsweredQuestion
has title: Android ScrollView fill 60%
downvote count: 0
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21571103
has body: In my android app I like to fill the scrollView to 60% of the screen.. and inside the scrollView I need to display textviews... For that I wrote the following code.. but the scrollView is filling 100% .. what change I need to do for attaining 60%... I need to display this textviews inside a relative layout if it is possible.. Xml <?xml version="1.0" encoding="utf-8"?> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/textView3" android:layout_alignBottom="@+id/textView3" android:layout_toRightOf="@+id/textView3" android:text="PYNo" /> <TextView android:id="@+id/textView7" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/textView6" android:layout_alignBottom="@+id/textView6" android:layout_toRightOf="@+id/textView3" android:text="CPin" /> <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:padding="15dip" android:text="What 2014 brings for you...." android:textSize="16dip" /> <TextView android:id="@+id/textView5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/textView1" android:layout_marginLeft="20dp" android:text="Prediction for :" /> <TextView android:id="@+id/textView11" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/textView5" android:layout_below="@+id/textView5" android:text="D.O.B :" /> <TextView android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/textView11" android:padding="15dip" android:text="Your Personal Year Number : " /> <TextView android:id="@+id/textView4" android:layout_width="wrap_content" android:l…
has answer: http://stackoverflow.com/a/21571169
accepted answer: http://stackoverflow.com/a/21571169

http://stackoverflow.com/comment/32703851
score: 2
has text: You can't do this in Java: http://stackoverflow.com/questions/3698323/swap-two-strings-in-java-by-passing-them-to-a-utility-function-but-without-ret Java passes references by value, so while you have a reference in the function and it swaps there, you didn't actually modify anything. I think your interview question was a trick one :)
comment on: http://stackoverflow.com/q/21639966
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/94167815
has text: Thanks, this worked for me when I had a StackOverflowException in this configuration today..
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21639553

http://stackoverflow.com/a/21640160
score: 1
has comment: http://stackoverflow.com/comment/32723966
upvote count: 1
has comment: http://stackoverflow.com/comment/32718516
has comment: http://stackoverflow.com/comment/32717835
downvote count: 0
has comment: http://stackoverflow.com/comment/32725721
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32724020
has body: As John3136 already pointed out in https://stackoverflow.com/a/21639680 , the main problem is that you are always using the same Randoms instance. But admittedly, this Randoms class itself seems questionable in its current form. The random values are stored as fields implicitly causing the original issue. I could imagine that such a Randoms class might be more useful if it contained the appropriate methods. For example, methods like class Randoms { private static final Random random = new Random(System.currentTimeMillis()); public static Color createRandomColor() { int red = random.nextInt(255); int green = random.nextInt(255); int blue = random.nextInt(255); return new Color(red,green,blue); } public static int nextInt(int min, int max) { return random.nextInt(max - min) + min; } } Apart from that: The code for the "hourglass" is always the same. In such cases, you should consider creating a method like private void paintHourglass(Graphics g, int x0, int x1) { // Here the repeated code... } Maybe you should more clearly describe what you want to achieve. If you just want to generate a set of random shapes, then you can create them and store them in a list: import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Shape; import java.awt.geom.Ellipse2D; import java.awt.geom.Rectangle2D; import java.util.ArrayList; import java.util.List; import java.util.Random; import javax.swing.JFrame; import javax.swing.JPanel; public class RandomsTest extends JFrame { public static void main(String[] args) { JFrame frame = new JFrame(); frame.getContentPane().add(new TestPanel()); frame.setSize(1000, 700); frame.setTitle("Random things"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setVisible(true); //frame.setResizable(false); } } class TestPanel extends JPanel { private List&lt;Geometry&gt; geometries; TestPanel() { geometries = new ArrayList&lt;Geometry&gt;(); int numGeometries = Randoms.next…
has comment: http://stackoverflow.com/comment/32724094
accepted answer of: http://stackoverflow.com/q/21639620
type: Answer
answers question: http://stackoverflow.com/q/21639620

http://stackoverflow.com/comment/60690340
comment on: http://stackoverflow.com/q/21546278
score: 1
has text: Dupe http://stackoverflow.com/questions/11203483/run-a-java-application-as-a-service-on-linux
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21560991
type: Answer
answers question: http://stackoverflow.com/q/21559068
type: AcceptedAnswer
upvote count: 5
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21559068
has body: The listener-container element isn't meant for configuring a standalone JMS listener container. It is meant to act as a blueprint for all enclosed listener tags. What, at runtime, actually happens is that a JMS Listener Container is constructed for each enclosed listener. So there is not a single container but multiple. As @artembilan mentioned the id of the container is set to the id of the listener. However when you would reuse the listener for spring integration it would render the listener useless. A listener-container can only have a single MessageListener attached, not multiple. If you want to use a listener container for a Spring Integration gateway you will have to construct one yourself using one of the *MessageListenerContainer classes.
has comment: http://stackoverflow.com/comment/32564768
score: 5

http://stackoverflow.com/comment/32719888
score: 0
type: QuestionComment
type: Comment
has text: There is no exception that I get or catch at the catch blocks. The XML format is standard but I can not parse it using the pre defined codes. The problem here is actually I can not get an exception but Document is still null.How it can be possible?
comment on: http://stackoverflow.com/q/21648994

http://stackoverflow.com/comment/32553810
score: 1
comment on: http://stackoverflow.com/q/21555195
type: Comment
type: QuestionComment
has text: Your question about the max number of objects, doesn't really appear to match the question you're trying to ask of equals vs. hashcode. I suggest an edit.

http://stackoverflow.com/comment/32693102
score: 0
type: Comment
type: QuestionComment
has text: Any of them, i think you say that one height is from the 0 coordinate of the ground, and one from the start of the polygon
comment on: http://stackoverflow.com/q/21633984

http://stackoverflow.com/comment/32662961
comment on: http://stackoverflow.com/a/21616468
score: 0
type: AnswerComment
has text: Hi, would you be able to help me out if I upload my code, I am new to java and still trying to get my head around it. I will really appreciate if you can.
type: Comment

http://stackoverflow.com/q/21664242
tagged with: java
has comment: http://stackoverflow.com/comment/32746205
has answer: http://stackoverflow.com/a/21664328
type: Question
tagged with: try-catch
answer count: 3
accepted answer: http://stackoverflow.com/a/21664328
has answer: http://stackoverflow.com/a/21664516
score: 0
possible better answer: http://stackoverflow.com/a/21664325
has body: I'm just learning Java exception handling and Java in general. I've made a Swing GUI where the user will enter integers into two fields and then click a radio button with an arithmetic function and the answer will appear in a third text field. I want to include a try/catch block to catch exceptions if the user leaves one of the first two fields blank or enters something other than integers and a second catch if the user tries to divide by zero. The form works functionally, however the errors aren't caught and only return the stack trace and crash the program. I have a feeling I just have the try/catch block in the wrong place but the more I move it around the worse things get. Could somebody point to where I went wrong? import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ButtonGroup; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JRadioButton; import javax.swing.JTextField; import javax.swing.WindowConstants; import javax.swing.SwingUtilities; public class Main extends javax.swing.JFrame { private JTextField aTextField; private JRadioButton dRadioButton; private ButtonGroup buttonGroup; private JLabel aLabel; private JRadioButton cRadioButton; private JRadioButton bRadioButton; private JRadioButton aRadioButton; private JTextField cTextField; private JTextField bTextField; /** * Auto-generated main method to display this JFrame */ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { Main inst = new Main(); inst.setLocationRelativeTo(null); inst.setVisible(true); } }); } public Main() { super(); initGUI(); } private void initGUI() { try { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(null); { aTextField = new JTextField(); getContentPane().add(aTextField); aTextField.setBounds(12, 49, 62, 30); } { bTextField = new JTextField(); getContentPane().add(bTextField); bTextField.setBounds(178, 49, 62, 31); } { cT…
tagged with: swing
has title: Java Swing GUI Try/Catch Block
has answer: http://stackoverflow.com/a/21664325
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32745891

http://stackoverflow.com/a/21539605
upvote count: 4
answers question: http://stackoverflow.com/q/21539550
downvote count: 0
score: 4
has body: while(input.hasNext()) { outlook = input.next(); humidity = input.next(); temp = input.next(); verd = input.next(); You're checking if the input has ONE next element, and if it does, you get the FOUR next elements. You should check before getting each of them.
type: Answer

http://stackoverflow.com/a/21532169
has comment: http://stackoverflow.com/comment/32513538
upvote count: 2
has comment: http://stackoverflow.com/comment/32513529
has comment: http://stackoverflow.com/comment/32513470
answers question: http://stackoverflow.com/q/21531632
has comment: http://stackoverflow.com/comment/32513411
type: Answer
has comment: http://stackoverflow.com/comment/32513478
has body: Put matricepc and matrice inside a JPanel with the GridLayout, instead of the JFrame. Put the JPanel at the BorderLayout.CENTER of the JFrame then add your other right JPanel to the BorderLayout.EAST container = frame.getContentPane(); matricepc = new JPanel(); matrice = new JPanel(); matrice.setLayout(new GridLayout(griglia.getRow(), griglia.getColumn())); matricepc.setLayout(new GridLayout(griglia.getRow(), griglia.getColumn())); //container.setLayout(new GridLayout(0,2)); &lt;--+ //container.add(matricepc); |-- Remove this code //container.add(matrice); &lt;--+ JPanel centerPanel = new JPanel(new GridLayout(0,2)); &lt;--+ centerPanel.add(matricepc); | centerPanel.add(matrice); | container.add(centerPanel, BorderLayout.CENTER); |-- Add this code JPanel rightPanel = new JPanel(); | container.add(rightPanel, BorderLayout.EAST); &lt;--+
score: 2
downvote count: 0

http://stackoverflow.com/comment/32741150
comment on: http://stackoverflow.com/q/21661492
type: Comment
score: 0
type: QuestionComment
has text: Looks like the first line gives you the dimensions for the square array and the following lines give you the data. So you know how to dimension the array, and you know exactly how many more lines (or values, if you prefer to think about it that way) you'll need to read. That should be enough to write your control looks without even having to check for end-of-file...

http://stackoverflow.com/comment/32641662
type: AnswerComment
score: 0
type: Comment
has text: Thanks for your answer! I already tried to do `response.setContentType("text/css");` or `setHeader(...)` and even with content length but it's not working :(. Removing flushBuffer did not work either.
comment on: http://stackoverflow.com/a/21604978

http://stackoverflow.com/q/21610229
has answer: http://stackoverflow.com/a/21610309
score: 1
tagged with: java
type: Question
tagged with: casting
downvote count: 0
has answer: http://stackoverflow.com/a/21610311
favorite count: 0
has answer: http://stackoverflow.com/a/21610273
answer count: 5
has comment: http://stackoverflow.com/comment/32651030
has title: When casting the double value 0.9 to a long how can get 1?
has answer: http://stackoverflow.com/a/21610370
possible better answer: http://stackoverflow.com/a/21610293
has answer: http://stackoverflow.com/a/21610293
upvote count: 1
has body: When casting the double value 0.9 (or any 0. decimal) to a long how can get 1? At present it returns 0. Thanks
accepted answer: http://stackoverflow.com/a/21610273
has comment: http://stackoverflow.com/comment/32652449
has comment: http://stackoverflow.com/comment/32650795
type: AnsweredQuestion

http://stackoverflow.com/comment/32729831
type: Comment
comment on: http://stackoverflow.com/a/21654513
has text: @user3026693: that's not a good reason to make it static, seriously.
type: AnswerComment
score: 0

http://stackoverflow.com/q/21568990
answer count: 1
has answer: http://stackoverflow.com/a/21819109
type: UnansweredQuestion
has body: What ever value i choose from the p:multiSelectListbox it doesnot show the selected value in the front end as given in primefaces example, in the bean i get a null value. Also i need to get all the values selected in the process(parent + child values) i am using primefaces 4.0 jar in view scope with spring in liferay portlet. &lt;p:multiSelectListbox id="searchServerMultiSelect" value="{serverBean.serverParamValue}" effect="slide"&gt; &lt;f:selectItems value="#{serverBean.serverParameters}" itemDescription="desc" itemLabel="label"/&gt; &lt;/p:multiSelectListbox&gt; &lt;p:commandButton value="Search" id="searchServersButtonId" immediate="true" actionListener="#{serverBean.searchServer}" styleClass="buttonImage" style="align:right;margin:20px;" update="serverTablePanelGroup,out" /&gt; &lt;h:outputText id="out" value="Value: #{serverBean.serverParamValue}" style="display:block"/&gt;
tagged with: spring
tagged with: jsf
tagged with: java
type: Question
has title: p:multiSelectListbox gives a null value
tagged with: primefaces
score: 0

http://stackoverflow.com/q/21588821
has comment: http://stackoverflow.com/comment/32615356
tagged with: android
has comment: http://stackoverflow.com/comment/32614527
has comment: http://stackoverflow.com/comment/32614684
has answer: http://stackoverflow.com/a/21588992
has title: Correlating items from two arraylists in Java
has comment: http://stackoverflow.com/comment/32614849
accepted answer: http://stackoverflow.com/a/21588992
type: Question
type: AnsweredQuestion
tagged with: java
answer count: 2
has body: In my android app I have a spinner (drop-down) that contains category names. User selects a category by its name, say "Food and Drink" those categories are contained in an ArrayList categoryNamesArray there is another ArrayList categoryIDsArray which contains the category ID integers. The ordering for both matches, meaning category 1 is category Automotive, which it is supposed to be. I need to send the category ID to the database, when the user chooses a category by name. How can I do that. It gets more complicated with Subcategories, because their IDs start with 40-something. Additional info: I pull the ids from the server and put them in an arraylist, then I pull the category names from the server and put them in another arraylist. Then put the two arraylists in one Object[] and pass them to the activity that needs them
has comment: http://stackoverflow.com/comment/32614467
possible better answer: http://stackoverflow.com/a/21589084
tagged with: arraylist
score: 0
has answer: http://stackoverflow.com/a/21589084
has comment: http://stackoverflow.com/comment/32614647

http://stackoverflow.com/comment/32558866
comment on: http://stackoverflow.com/q/21533641
score: 0
type: QuestionComment
has text: *"I was just using the object our instructor gave us"* So a teacher is forcing you to code applets? Please refer them to [Why CS teachers should *stop* teaching Java applets](http://programmers.blogoverflow.com/2013/05/why-cs-teachers-should-stop-teaching-java-applets/). *"They all use Cp1252"* Wait, *what*?!? You do realize that [CP-1252](http://en.wikipedia.org/wiki/Windows-1252) relates only to text, right? It has nothing to do with the encoding of the sound itself!
type: Comment

http://stackoverflow.com/a/21542675
upvote count: 5
score: 5
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21542601
has body: Use A Dos Filter http://wiki.eclipse.org/Jetty/Reference/DoSFilter. To enable it in Jetty.xml you would insert this code DoSFilter org.eclipse.jetty.servlets.DoSFilter maxRequestsPerSec 30

http://stackoverflow.com/q/21657839
has comment: http://stackoverflow.com/comment/32734453
tagged with: android
favorite count: 0
has comment: http://stackoverflow.com/comment/32739858
has title: Unable to start activity ComponentInfo - Activity Crash
answer count: 0
type: UnansweredQuestion
has body: When loading an activity my app is instantly crashing with an "Unable to start activity ComponentInfo" logcat. The application crashes as soon as this activity tries to run. My activity code is: package com.example.cg4project; import android.os.Bundle; import android.app.ActionBar.LayoutParams; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; public class ChildScreen extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_child_screen); //Gte child array size int arraySize = Global.getInstance().childArray.size(); if (arraySize == 0){ }else{//Create new button Button myButton = new Button(this); //For loop from 0 to array size for(int counter = 0; counter &lt; arraySize; counter++){ //Set button text myButton.setText(Global.getInstance().childArray.get(counter).aFirstName + " " + Global.getInstance().childArray.get(counter).aLastName + " Stars: " + Global.getInstance().childArray.get(counter).aPoints); //Create linear layout LinearLayout ll = (LinearLayout)findViewById(R.id.layout1); LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); //Add button to layout ll.addView(myButton, lp); myButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //Open child activity Intent i = new Intent(ChildScreen.this, Child.class); ChildScreen.this.startActivity(i); } }); } } final Button btnLogin = (Button) findViewById(R.id.btnLogin); btnLogin.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //Open child create activity Intent i = new Intent(ChildScreen.this, ChildCreate.class); ChildScreen.this.startActivi…
upvote count: 1
has comment: http://stackoverflow.com/comment/32736420
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32734326
type: Question
downvote count: 0

http://stackoverflow.com/q/21541416
answer count: 1
has title: java 2D array search/sort/add
tagged with: sorting
score: 0
tagged with: multidimensional-array
has body: I have to take in a few ID numbers and how many boxes sold by the ID number...split those into two arrays...which I've done....then sort the array reporting the largest sale of boxes sold....the(and this is my problem) if the same id number is entered, add the number of boxes sold together and make it take up only one spot in the array example.... idNum 1 = 100 idNum 3 = 500 idNum 1 = 200 so idNum 1 = 300 //declarations int [][] stupidKids = new int[10][2];//10 rows....2 columns int entry = 0; int tempNum; int tempTotal = 0; int tempId; int found = -1; //user input section for(int i = 0; i &lt; 2; i++) { System.out.print("Please enter the class ID"); Scanner scan = new Scanner(System.in); stupidKids[i][0] = scan.nextInt(); System.out.print("Please enter the amount of cookies sold"); stupidKids[i][1] = scan.nextInt(); System.out.println(stupidKids[i][0] + "Cookies " + stupidKids[i][1]); } //sorting process for(int i = 0; i &lt; 2; i++) { if(stupidKids[i][1] &gt; stupidKids[i+1][1]) { tempNum = stupidKids[i][1]; stupidKids[i][1] = stupidKids[i + 1][1]; stupidKids[i + 1][1] = tempNum; tempId = stupidKids[i][0]; stupidKids[i][0] = stupidKids[i+1][0]; stupidKids[i+1][0] = tempId; } } //comparing for same ID Num for(int i = 0; i &lt; 1; i++) { if(stupidKids[i][0] == stupidKids[i+1][0]) { tempTotal = (stupidKids[i][1] + stupidKids[i+1][1]); } } System.out.println("Final num " + tempTotal);
accepted answer: http://stackoverflow.com/a/21541812
has answer: http://stackoverflow.com/a/21541812
type: AnsweredQuestion
tagged with: 2d
tagged with: java
type: Question
tagged with: arrays

http://stackoverflow.com/a/21673286
accepted answer of: http://stackoverflow.com/q/21672954
score: 0
answers question: http://stackoverflow.com/q/21672954
type: AcceptedAnswer
type: Answer
has comment: http://stackoverflow.com/comment/32767898
has body: When you already have a HashMap storing the mapping, you can just use a Comparator that compares the entries of the array by looking up and comparing the respective values in the map import java.util.Arrays; import java.util.Comparator; import java.util.LinkedHashMap; import java.util.Map; public class SortByName { public static void main(String[] args) { Integer input[] = { 1,22,44,3456,9999}; final String array[] = { "one", "twotwo", "fourfour", "threefourfivesix", "ninenineninenine"}; final Map&lt;Integer, String&gt; map = createMap(input, array); Arrays.sort(input, new Comparator&lt;Integer&gt;() { @Override public int compare(Integer i0, Integer i1) { return map.get(i0).compareTo(map.get(i1)); } }); System.out.println(Arrays.toString(input)); } private static &lt;K, V&gt; Map&lt;K, V&gt; createMap(K k[], V v[]) { Map&lt;K, V&gt; map = new LinkedHashMap&lt;K, V&gt;(); for (int i=0; i&lt;k.length; i++) { map.put(k[i], v[i]); } return map; } }

http://stackoverflow.com/comment/32555256
score: 1
has text: For your first example, why not just use String.valueOf(num)?
comment on: http://stackoverflow.com/q/21556322
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32561575
type: QuestionComment
comment on: http://stackoverflow.com/q/21559670
has text: Do you know what `Generics` are?
score: 0
type: Comment

http://stackoverflow.com/comment/32766277
type: QuestionComment
comment on: http://stackoverflow.com/q/21676256
has text: how jsonObject created from result string?
score: 0
type: Comment

http://stackoverflow.com/q/21534112
score: 0
answer count: 1
tagged with: jpa
has answer: http://stackoverflow.com/a/21862849
type: UnansweredQuestion
tagged with: entity-framework
tagged with: java
tagged with: hibernate
has body: Is there a large real world open source project with many JPA entities defined. Something that could illustrate best JPA practices for defining JPA entities? All the samples I find are so small or focused. I'm struggling, to find anything on what the accepted "good practices" are. For example how best to : add/removing entities in relationships(do I provide support for this type of thing on the entity?) For one2one, should I return null from the getter if its empty, throw, or provide an API to check isEmpty() do I do these thing's on the entity class, or proivde some type of helper?
type: Question
has title: Reference Application for JPA entity usage patterns

http://stackoverflow.com/q/21652551
downvote count: 0
answer count: 1
favorite count: 0
linked to: http://stackoverflow.com/q/754294
has body: I want to get a inputStream source from a file, and put this as a Byte in a ArrayList. But I didn´t find any thing about this. Can someone help me?
has title: Create a arraylist of bytes by a inputstream
type: AnsweredQuestion
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/21652572
has comment: http://stackoverflow.com/comment/32725192
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/21652572

http://stackoverflow.com/a/21654850
has body: Azure VM images do not include the JDK or any of the Java web servers (Tomcat, Jetty, etc.). You need to get them, from somewhere. So... when building a Java app via Eclipse and related Cloud Service template, there's a startup script that bootstraps your worker role instances. This involves grabbing the SDK and web server (Tomcat, Jetty, etc.) from somewhere and placing it on your instance's disk. Since you're using Cloud Services (worker role in this case), the OS disks are stateless: Each time a new VM instance spins up, it starts fresh, and you're responsible for setting things up (via startup script). So: You need to set up your SDK and web server. You can either bundle these with your deployment package or download them from somewhere. The former increases the deployment package size by quite a bit (maybe 100MB?). The latter requires you to download the bits from somewhere. You can either download from somewhere like Oracle (which requires you to go through a license agreement each time), or from your own storage account (which is very fast, as long as it's in the same region as your code deployment). Further: being in the same data center, there are no bandwidth charges when downloading stuff to your worker role instances. The current Eclipse plugin has a setting for your worker role, where you specify blob storage for your JDK and web server. By doing this, it's basically a one-time setup (except when it's time to upgrade the JDK or Tomcat/Jetty version, and then you'll need to re-upload to blob storage). Once these bits are in blob storage, you only need to include your Java classes in your deployment package.
accepted answer of: http://stackoverflow.com/q/21625826
answers question: http://stackoverflow.com/q/21625826
type: AcceptedAnswer
score: 0
has comment: http://stackoverflow.com/comment/32869293
type: Answer

http://stackoverflow.com/comment/32708374
comment on: http://stackoverflow.com/q/21642731
score: 0
has text: What is the actual question?
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21664282
answers question: http://stackoverflow.com/q/21664249
has comment: http://stackoverflow.com/comment/32746519
type: Answer
has comment: http://stackoverflow.com/comment/32753558
has body: Make sure you have included all the jars that come with XStream also specially "kxml2.jar" and "xmlpull-1.1.3.1.jar" file. Jar version may deffer incase of yours.
has comment: http://stackoverflow.com/comment/33680477
downvote count: 1
has comment: http://stackoverflow.com/comment/73511502
score: 18
upvote count: 19

http://stackoverflow.com/q/21555195
duplicate of: http://stackoverflow.com/q/27581
has title: How many unique object be there in HashSet And which method is used to check uniqueness equals or hashCode
score: 1
tagged with: java
tagged with: set
has answer: http://stackoverflow.com/a/21555366
type: Question
linked to: http://stackoverflow.com/q/7632126
tagged with: hashset
upvote count: 2
answer count: 2
downvote count: 1
has comment: http://stackoverflow.com/comment/32553810
has answer: http://stackoverflow.com/a/21555267
has body: Consider the below code import java.util.HashSet; import java.util.Random; import java.util.Set; public class Test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Person p1= new Person(); //Person p2= new Person(); p1.setName("same1"); //p2.setName("same2"); Person p2=p1; Set&lt;Person&gt; set= new HashSet&lt;Person&gt;(); set.add(p1); set.add(p2); for(Person p: set){ System.out.println(set.size()+"&gt;&gt;"+p.getName()+" hashcode "+p.hashCode()); } } } class Person{ private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public boolean equals(Object obj){ return true; } @Override public int hashCode() { Random ran = new Random(); int x = ran.nextInt(6) + 5; System.out.println("in hahcode method"+x); return x; } } As set does not contain duplicate, Here I have return true from equals method and return different hashcode for the same object. HashSet treat them as unique object. So far so good, as HashSet internally use HashMap to store objects. It appears from above code snippet that HashSet use hashCode to check uniqueness not equals method. If hashCode is different for two objects,they will be stored in HashSet whether they are equal or not? Please let me know if I am missing something.
favorite count: 0
linked to: http://stackoverflow.com/q/27581
type: UnansweredQuestion

http://stackoverflow.com/comment/32745396
comment on: http://stackoverflow.com/q/21664031
has text: Removed my comment. You shoul still change the name to toString() if you want to override the proper method. Here it's very bad practice.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21618875
has comment: http://stackoverflow.com/comment/32667134
has comment: http://stackoverflow.com/comment/32968485
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32667027
downvote count: 0
has comment: http://stackoverflow.com/comment/33339712
has comment: http://stackoverflow.com/comment/32754134
has comment: http://stackoverflow.com/comment/32843317
has comment: http://stackoverflow.com/comment/32843135
type: Answer
accepted answer of: http://stackoverflow.com/q/21618715
upvote count: 3
answers question: http://stackoverflow.com/q/21618715
has comment: http://stackoverflow.com/comment/32777836
has comment: http://stackoverflow.com/comment/32843185
has comment: http://stackoverflow.com/comment/32843195
has comment: http://stackoverflow.com/comment/32785376
score: 3
has comment: http://stackoverflow.com/comment/32792369
has comment: http://stackoverflow.com/comment/32754843
has comment: http://stackoverflow.com/comment/32843346
has body: Given row and column you will need to know the number of columns per row. With this information you can simply do (row * columns) + column which will return the index of the square. For example, with 8 columns per row, a request for row = 0, column = 4, will return 4 row = 1, column = 4, will return 12 row = 0, column = 0, will return 0 Rendering the sections of the square is more complex and can be achieved in at least two ways. You could use a Polygon which generates a triangle for each section or Shape and simply use Graphics2D#fill to fill it. This will come down to how you physically render each square... Take a look at 2D Graphics for more details and this for an example of both. A Shape would be much easier to rotate and position and would only require you to have a single instance (or a single instance for each square based on your needs), where as you would require at least 4 Polygons or do some fun rotation... Updated with simple example All done with rotating triangles... import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; import java.awt.Shape; import java.awt.geom.AffineTransform; import java.awt.geom.Path2D; import java.awt.geom.Point2D; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; public class DividedSquare { public static void main(String[] args) { new DividedSquare(); } public DividedSquare() { EventQueue.invokeLater(new Runnable() { @Override public void run() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { } JFrame frame = new JFrame("Testing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new Border…

http://stackoverflow.com/a/21624041
downvote count: 0
answers question: http://stackoverflow.com/q/21623941
type: Answer
has comment: http://stackoverflow.com/comment/32675432
score: 1
has body: if(strStatusID.equals("1")){ // Upload Done }else if(strStatusID.equals("2")){ // Upload Failed }else{ // Already Exist or any other value }
upvote count: 1

http://stackoverflow.com/a/21562953
score: 0
answers question: http://stackoverflow.com/q/21562794
type: Answer
has body: Basically you need some kind model, which both panels can interact with. The "control" panel would update the model with new information and the "history" panel would listen to the model for changes and update its view accordingly. The is a basic Producer/Consumer and Observer pattern problem. Consider your current example. You attach listeners to the components and are notified of changes. This is an example of the observer pattern.

http://stackoverflow.com/a/49672738
type: Answer
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/21589155
downvote count: 0
has body: I was facing the same issue while calling a Oracle Stored procedure: PACKAGE_NAME.PROCEDURE_NAME(?, ?, ?, ?,?, ?, ?, ?, ?)}]; 13:52:24.202 [main] DEBUG o.s.j.s.SQLStateSQLExceptionTranslator - Extracted SQL state class '99' from value '99999' org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{call PACKAGE_NAME.PROCEDURE_NAME(?, ?, ?, ?,?, ?, ?, ?, ?)}]; SQL state [99999]; error code [17074]; invalid name pattern: SCHEMA.Type_Param; nested exception is java.sql.SQLException: ***invalid name pattern: SCHEMA.Type_Param*** at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:1036) at org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1070) at org.springframework.jdbc.object.StoredProcedure.execute(StoredProcedure.java:144) My procedure was taking 1 Table type input parameter. This parameter was defined at package level scope. So I move this package level scope parameter to Schema level parameter and solved the issue. PLSQL types created within a package can't be accessed directly from java.

http://stackoverflow.com/q/21669743
answer count: 3
accepted answer: http://stackoverflow.com/a/21669777
tagged with: java
has comment: http://stackoverflow.com/comment/32755402
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21669784
tagged with: string
favorite count: 0
has answer: http://stackoverflow.com/a/21669784
tagged with: maze
type: Question
has answer: http://stackoverflow.com/a/21669861
has answer: http://stackoverflow.com/a/21669777
tagged with: regex
has body: [Abstract: I need a way to remove the newline token (\n) from a massive string, hopefully without regex] For my CS class, we have to read in a maze from a text file, which would look something like this: ############################## #@...........................# ############################## ############################## ############################## ############################## ############################## ############################## ############################## ############################## ------------------------------ ############################## ############################## #@...........................# ############################## ############################## ############################## ############################## ############################## ############################## ############################## ------------------------------ ############################## ############################## ############################## #@...........................# ############################## ############################## ############################## ############################## ############################## ############################## ------------------------------ The dashed Lines indicate separate floors. It's a 3D maze. This is just a test for reading the maze, so the pieces are irrelevant. We have to read the entire maze into a single string using the Scanner class, but then we have to be able to test each individual (x,y,z) and return what character exists at that point. My idea is to separate the huge string into a 3-dimensional array of chars (char[][][]), but that requires removing the newline characters from the huge maze string. Is there a way I can remove the \n tokens from the massive string, hopefully without using regex. I've looked around a lot, but can't quite find a solid answer. A lot of people suggest using regex, but I'm not too familiar with doing that and would like to avoid it if possible. Thanks for …
has comment: http://stackoverflow.com/comment/32755403
has title: Finding the Newline Character "\n" in a String
upvote count: 2
score: 0
downvote count: 2

http://stackoverflow.com/q/21534188
has comment: http://stackoverflow.com/comment/32517072
tagged with: arrays
tagged with: indexoutofboundsexception
answer count: 6
has comment: http://stackoverflow.com/comment/32517021
possible better answer: http://stackoverflow.com/a/21534252
has comment: http://stackoverflow.com/comment/32517171
has answer: http://stackoverflow.com/a/21534255
has answer: http://stackoverflow.com/a/21534252
score: 0
has answer: http://stackoverflow.com/a/21534248
has body: I am getting an array index out of bounds exception while iterating over an array through the for-loop. Can someone tell me why this is happening it I have set the boolean in the for-loop to be i public static boolean verify(int [] seq ){ for (int i=0; i&lt;seq.length; i++){ //If the number is even, the next number //must the half the previous number if (seq[i] %2==0){ if (seq[i+1] != (seq[i]/2)){ return false; } } //If the number is positive, the next number //must be 3 times + 1 the previous number else if (seq[i] %2!=0){ if (seq[i+1] != ((seq[i])*3+1)){ return false; } } } }
has answer: http://stackoverflow.com/a/21534254
has answer: http://stackoverflow.com/a/21534416
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32517075
has title: JavaArray Index out of Bounds exception w/ for loop
tagged with: java
accepted answer: http://stackoverflow.com/a/21534248
has comment: http://stackoverflow.com/comment/32517445
type: Question
has answer: http://stackoverflow.com/a/21534278

http://stackoverflow.com/q/21610045
possible better answer: http://stackoverflow.com/a/21610272
type: Question
has answer: http://stackoverflow.com/a/21610508
has answer: http://stackoverflow.com/a/21610272
has comment: http://stackoverflow.com/comment/32650783
has comment: http://stackoverflow.com/comment/32690723
has comment: http://stackoverflow.com/comment/32651445
has comment: http://stackoverflow.com/comment/32650559
has comment: http://stackoverflow.com/comment/32691435
has comment: http://stackoverflow.com/comment/32691149
has comment: http://stackoverflow.com/comment/32659170
has answer: http://stackoverflow.com/a/21610277
upvote count: 2
has title: Java Optimizing arithmetic and Assignment Operators for large input
has body: I have a piece of code that must run extremely fast in terms of clock speed. The algorithm is already in O(N). It takes 2seconds, it needs to take 1s. For most A.length inputs ~ 100,000 it takes .3s unless a particular line of code is invoked an extreme number of times. (For an esoteric programming challenge) It uses a calculation of the arithmetic series that 1,2,..N -> 1,3,4,10,15.. that can be represented by n*(n+1)/2 I loop through this equation hundreds of thousands of times. I do not have access to the input, nor can I display it. The only information I am able to get returned is the time it took to run. particularly the equation is: s+=(n+c)-((n*(n+1))/2); s and c can have values range from 0 to 1Billion n can range 0 to 100,000 What is the most efficient way to write this statement in terms of clock speed? I have heard division takes more time then multiplication, but beyond that I could not determine whether writing this in one line or multiple assignment lines was more efficient. Dividing and multiplying versus multiplying and then dividing? Also would creating custom integers types significantly help? Edit as per request, full code with small input case (sorry if it's ugly, I've just kept stripping it down): public static void main(String[] args) { int A[]={3,4,8,5,1,4,6,8,7,2,2,4};//output 44 int K=6; //long start = System.currentTimeMillis();; //for(int i=0;i&lt;100000;i++){ System.out.println(mezmeriz4r(A,K)); //} //long end = System.currentTimeMillis();; // System.out.println((end - start) + " ms"); } public static int mezmeriz4r(int[]A,int K){ int s=0; int ml=s; int mxl=s; int sz=1; int t=s; int c=sz; int lol=50000; int end=A.length; for(int i=sz;i&lt;end;i++){ if(A[i]&gt;A[mxl]){ mxl=i; }else if(A[i]&lt;A[ml]){ ml=i; } if(Math.abs(A[ml]-A[mxl])&lt;=K){ sz++; if(sz&gt;=lol)return 1000000000; if(sz&gt;1){ c+=sz; } }else{ if(A[ml]!=A[i]){ t=i-ml; s+=(t+c)-((t*(t+1))/(short)2); i=ml; ml++; mxl=ml; }else{ t=i-mxl; s+=(t+c)-((t*(t+1))/(short)2); i=mxl; mx…
has comment: http://stackoverflow.com/comment/32651098
answer count: 7
accepted answer: http://stackoverflow.com/a/21634882
has comment: http://stackoverflow.com/comment/32690322
tagged with: mathematical-optimization
tagged with: algorithm
has comment: http://stackoverflow.com/comment/32650997
has comment: http://stackoverflow.com/comment/32690164
tagged with: java
has comment: http://stackoverflow.com/comment/32650597
has comment: http://stackoverflow.com/comment/32650622
has answer: http://stackoverflow.com/a/21610420
has comment: http://stackoverflow.com/comment/32654302
score: 2
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32650417
has comment: http://stackoverflow.com/comment/32652325
downvote count: 0
linked to: http://stackoverflow.com/q/18560844
has answer: http://stackoverflow.com/a/21613880
has comment: http://stackoverflow.com/comment/32656522
has answer: http://stackoverflow.com/a/21610440
favorite count: 0
tagged with: optimization
has answer: http://stackoverflow.com/a/21634882

gmail
type: Tag
tags question: http://stackoverflow.com/q/21522544
tags question: http://stackoverflow.com/q/21645994
tags question: http://stackoverflow.com/q/21647948
tags question: http://stackoverflow.com/q/21642997
tags question: http://stackoverflow.com/q/21603877
tags question: http://stackoverflow.com/q/21648336
tag name: gmail

http://stackoverflow.com/comment/32658001
has text: @C.B. - Yeah, this is arguing over angels on a pinhead. In a well-designed JVM neither is expensive enough to worry about (though in some early JVMs there was cause for worry).
comment on: http://stackoverflow.com/q/21613098
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21563458
has comment: http://stackoverflow.com/comment/32569897
score: 0
has comment: http://stackoverflow.com/comment/32569806
has comment: http://stackoverflow.com/comment/32570433
type: Answer
has comment: http://stackoverflow.com/comment/32570567
has body: As mentioned you have deleted all plugins make sure some required plugins are still there in place. You can check them from Settings > Plugins It seems android plugins default tasks are missing so make sure you have apply plugin: 'android' in your module's build.gradle file. EDIT(As per the discussion in comments) : It seems you are using actionbarsherlock in your project make sure you have applied Sherlock theme in your AndroidManifest.xml file Something Like this : If you are using style.xml for you theming In your style.xml in your AndroidManifest.xml file
answers question: http://stackoverflow.com/q/21562933
has comment: http://stackoverflow.com/comment/32570766
has comment: http://stackoverflow.com/comment/32569751
has comment: http://stackoverflow.com/comment/32569595
has comment: http://stackoverflow.com/comment/32569666
has comment: http://stackoverflow.com/comment/32569123
has comment: http://stackoverflow.com/comment/32577700
has comment: http://stackoverflow.com/comment/32581186
has comment: http://stackoverflow.com/comment/32569899
has comment: http://stackoverflow.com/comment/32570371
has comment: http://stackoverflow.com/comment/32569511
has comment: http://stackoverflow.com/comment/32568732
has comment: http://stackoverflow.com/comment/32569273

http://stackoverflow.com/comment/32708979
has text: The only time I can think of needing to re-implement such a type [over ArrayList] is for specialized types, such as `int[]` as a backing, but this is not doing that (and even those already exist) .. also, for the love of nominative typing, implement List.
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21643123

http://stackoverflow.com/q/21640181
has answer: http://stackoverflow.com/a/21640283
tagged with: swing
has body: I have a Java exercise using KeyListeners that I have been stuck on for a while. Any help would be greatly appreciated. The exercise is: "Write a program to get a character input from the keyboard and display the character where the mouse points." I did some debugging and it seems like the KeyListener is never registering when a key is pressed. import java.awt.*; import java.awt.event.*; import javax.swing.*; @SuppressWarnings("serial") public class EventProgrammingExercise10 extends JFrame { CharPanel chars; private int x; private int y; String s; public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { EventProgrammingExercise10 frame = new EventProgrammingExercise10(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } public EventProgrammingExercise10() { setTitle("EventProgrammingExercise10"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(300, 300); chars = new CharPanel(); chars.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { chars.repaint(); } }); add(chars); } public void setX(int n) { x = n; } public void setY(int n) { y = n; } class MouseLocListener extends MouseMotionAdapter { public void mouseMoved(MouseEvent e) { setX(e.getX()); setY(e.getY()); } } class CharPanel extends JPanel { protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawString(String.valueOf('a'), x, y); } } } Thanks.
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21640283
accepted answer: http://stackoverflow.com/a/21640346
tagged with: java
tagged with: keylistener
type: Question
answer count: 3
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/21640346
tagged with: events
score: 2
has answer: http://stackoverflow.com/a/21640245
upvote count: 2
has title: Displaying characters typed at mouse location in Java GUI

http://stackoverflow.com/q/21552833
upvote count: 1
has body: The "other java proposals" that allows you to use the Ctrl+Space shortcut is missing from my Kempler install. I have redownloaded and reinstalled fresh from Eclipse and still do not have access to the shortcut from "other java proposals". When searching here it's been suggested it should be checked in the advanced section of the editor preferences for Java. I can't find anything about how to enable to disable it here or in the Eclipse help files so I thought I would ask. Thanks, Omega
type: UnansweredQuestion
tagged with: eclipse
has answer: http://stackoverflow.com/a/21553180
has title: Other Java Proposals Missing From Eclipse
downvote count: 0
tagged with: ide
score: 1
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/21597841
tagged with: java
answer count: 2

http://stackoverflow.com/a/21611353
type: Answer
has body: Instead of having another class further down the file, move it into a new file. For example: public class Fraction { //some code } class Tester { //some code } Is a perfectly valid source file, but you could split into two source files (and it is often clearer to do so): (in Fraction.java): public class Fraction { //some code } (in Tester.java): public class Tester { //some code } Remember to include the package declaration in both files (put package whateverYourPackageNameIs; at the top of both files) You can then test it by creating a fraction in the Tester class (via Fraction f = new Fraction(/*constructor args*/);) and call the relevant methods. Note: this works in any IDE, not just Netbeans. You could even do this with text file programming
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/21611255
downvote count: 0

http://stackoverflow.com/q/21639695
linked to: http://stackoverflow.com/q/10237903
type: Question
has body: I have a simple test program that has one button. When a user clicks the button, the program is supposed to create a Runnable JAR. The Runnable JAR is a simple program that opens google.com in Firefox. The program has three classes. 1) Main.java package test; public class Main { public static void main(String[] args) { Selenium.getGoogle(); } } 2) Selenium.Java package test; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class Selenium { public static void getGoogle () { WebDriver driver = new FirefoxDriver(); driver.get("http://google.com"); } } 3) TestGUI.java package test; import javax.swing.*; import javax.tools.JavaCompiler; import javax.tools.ToolProvider; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class TestGUI extends JFrame implements ActionListener { private static final long serialVersionUID = 1L; public TestGUI() { setSize(200, 100); setDefaultCloseOperation(EXIT_ON_CLOSE); setVisible(true); /* * JButton. */ JButton startButton = new JButton("Create Runnable JAR file ! "); add(startButton); startButton.addActionListener(this); } public static void main(String[] args) { new TestGUI(); } public void actionPerformed(ActionEvent e) { System.out.println("The Button Works"); String file1ToCompile = "test" + java.io.File.separator + "Main.java"; String file2ToCompile = "test" + java.io.File.separator + "Selenium.java"; JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); int compilationResult = compiler.run(null, null, null, file1ToCompile, file2ToCompile); if (compilationResult == 0) { System.out.println("Compilation is successful"); } else { System.out.println("Compilation Failed"); } } } I have two main classes . I added TestGUI.java to the manifest so the GUI will show up . Once a user clicks the button, I want my program to create a Runnable JAR that consists of Main.java and Selenium.java. However, I get an error null pointer exception for int compilationResult =…
accepted answer: http://stackoverflow.com/a/23480673
has comment: http://stackoverflow.com/comment/32898711
has comment: http://stackoverflow.com/comment/32703503
has comment: http://stackoverflow.com/comment/32703469
has comment: http://stackoverflow.com/comment/32703570
tagged with: java-compiler-api
has comment: http://stackoverflow.com/comment/32703468
has comment: http://stackoverflow.com/comment/32962536
answer count: 2
has comment: http://stackoverflow.com/comment/32703453
score: 2
has comment: http://stackoverflow.com/comment/33166245
has comment: http://stackoverflow.com/comment/32703464
favorite count: 0
has comment: http://stackoverflow.com/comment/32703435
has comment: http://stackoverflow.com/comment/32999675
has comment: http://stackoverflow.com/comment/32885201
has answer: http://stackoverflow.com/a/23480673
has comment: http://stackoverflow.com/comment/32703547
type: AnsweredQuestion
upvote count: 3
has comment: http://stackoverflow.com/comment/32703394
tagged with: java
possible better answer: http://stackoverflow.com/a/21789045
downvote count: 1
has title: Programmatically creating Runnable JAR that has external JARs from a GUI?
has answer: http://stackoverflow.com/a/21789045

http://stackoverflow.com/q/21583317
score: 1
has comment: http://stackoverflow.com/comment/32604165
upvote count: 1
type: Question
tagged with: java
has comment: http://stackoverflow.com/comment/32604171
has body: i have a servlet which takes emailid and password from a form, which is then supposed to access the table called hr.faculty, and if the credentials found correct, creates a session. but i am getting an error: java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended when i try to login. plz help. The code is as follows: email=request.getParameter("email"); pass=request.getParameter("pass"); try{ try { Class.forName(driver); } catch (ClassNotFoundException ex) { out.println(ex); } Connection con=null; con=DriverManager.getConnection(oracleURL,username,password); DatabaseMetaData dmd=con.getMetaData(); Statement s=con.createStatement(); String q="SELECT password FROM HR.faculty WHERE email=" + email; ResultSet rs=s.executeQuery(q); pw=rs.getString("password"); if(pw.equals(pass)){ //session creation }
tagged with: servlets
has answer: http://stackoverflow.com/a/21583420
answer count: 3
has title: SQL command not properly ended in servlets
downvote count: 0
has answer: http://stackoverflow.com/a/21583435
favorite count: 0
type: UnansweredQuestion
tagged with: jdbc
has answer: http://stackoverflow.com/a/21583587

http://stackoverflow.com/a/33555331
downvote count: 0
upvote count: 14
answers question: http://stackoverflow.com/q/21585892
type: Answer
has body: Overriding default equals method is not necessary. You simply use Date.compareTo() to compare two date objects.
score: 14

http://stackoverflow.com/a/21565983
has body: Refresh your project, right click over the project > Refresh or F5, so you can load the "jet.png" resource. If you load the image directly on your Eclipse´s project explorer you will have no problems, but if you load only in Windows Explorer you have to refresh your project.
score: 1
upvote count: 1
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21565624

http://stackoverflow.com/comment/32618204
comment on: http://stackoverflow.com/a/21589080
has text: Well, that's my point - there is no specified annotation. So this is a placeholder, what are the rules about what can be put there? Any annotation at all? Any custom annotation? Any annotation defined in this module?
type: Comment
score: 2
type: AnswerComment

http://stackoverflow.com/comment/32726130
type: Comment
type: QuestionComment
has text: Hi Saposiente, I have included the call to getViewData as requested. Do you really need the call to setViewData; as this is working? I agree that the issue is with getViewData and this is where I have concentrated my efforts; to no avail. I appreciate your help. Regards, Glyn.
comment on: http://stackoverflow.com/q/21641208
score: 0

http://stackoverflow.com/comment/32661429
type: Comment
type: QuestionComment
has text: In most cases the url-pattern in Web.xml doesn't match the one in @RemoteServiceRelativePath
comment on: http://stackoverflow.com/q/21609774
score: 0

http://stackoverflow.com/a/21575258
answers question: http://stackoverflow.com/q/21575156
has comment: http://stackoverflow.com/comment/32589897
accepted answer of: http://stackoverflow.com/q/21575156
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32590962
has body: You could just test the input against a regular expression using String.matches() to make sure it's only digits (no need to catch an exception such as a NumberFormatException - it can be considered bad practice to provoke exceptions to validate conditions). String j = txtAge.getText(); if (!j.matches("\\d+")) { // It is not a number } If you just want to try to convert to an Integer directly and catch an exception you should use Integer.parseInt() (it will throw a NumberFormatException if the input can't be parsed as an Integer): String j = txtAge.getText(); try { Integer i = Integer.parseInt(txtAge); } catch (NumberFormatException e) { // j isn't a number... } EDIT: There seems to be a little confusion with the answer you provided. In your question the error message was Please enter integer values, as if valid input was only digits. In the answer you posted the message was Please enter String values. If you want to validate the input doesn't have any numbers, you'll have to use another regex, such as .*\\d.*". If it matches, it means it has a digit. Or you could also use \\D+ to ensure it has one or more non-digits.
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/32589764
has comment: http://stackoverflow.com/comment/32589681
score: 1

http://stackoverflow.com/comment/32636913
type: Comment
has text: It's just that my constructor almost looks identical to your "method". And I've been told that the constructor's header will always have the same name as the class, so I assume that only the constructor may have that name, hence my jump to the conclusion that you just wrote a constructor.
comment on: http://stackoverflow.com/a/21602155
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32640473
score: 0
has text: Thats about loading class from compiled code, what about generating compiled code ?
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21603933

http://stackoverflow.com/q/21608891
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21644011
tagged with: java
has body: I have a method in which i use gwt PopupPanel to display an image while screen loads and server workloads. final static PopupPanel popup = new PopupPanel(false, true); The method i use is : public static void sBanner() { popup.setWidget(new Image("Images//Progress.gif")); popup.setGlassEnabled(true); popup.center(); } What i dont manage to do it is to show the image when the method its called. In local, runs fine; but when i deploy the code to Google App Engine, I get an icon like Google App Engine isnt finding the referenced file. I have also tried to upload the image to Google Drive and use the sharing url as the url to use, but so far i havent been successful. Anyone can enlight me?. Thank you.
type: Question
tagged with: gwt
has title: GWT PopupPanel not showing animated Image correctly
score: 0
has answer: http://stackoverflow.com/a/21644011
answer count: 1

http://stackoverflow.com/a/21672968
has comment: http://stackoverflow.com/comment/32760915
type: Answer
has comment: http://stackoverflow.com/comment/32760767
has comment: http://stackoverflow.com/comment/32761405
answers question: http://stackoverflow.com/q/21672782
has body: Try this in the onCreate() of your activity. this.requestWindowFeature(Window.FEATURE_NO_TITLE); This should hide the titlebar as Aleks G mentioned. Make sure to do this before setContentView()
score: 0

http://stackoverflow.com/comment/32625117
type: AnswerComment
has text: @user3278117, @nhgrif: The result of `int seconds = 36.0/3600` is an error at compile time. `36.0/3600` is a `double`, and Java will not let you convert a `double` to an `int` without a cast.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21594892

http://stackoverflow.com/comment/32679253
type: Comment
has text: You have shown one code and a compiler error complaining about completely different code.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21626664

http://stackoverflow.com/comment/32848629
type: Comment
comment on: http://stackoverflow.com/q/21642862
score: 0
type: QuestionComment
has text: nice edit now it is all clear

http://stackoverflow.com/comment/32552433
type: AnswerComment
comment on: http://stackoverflow.com/a/21554146
score: 0
type: Comment
has text: Throws InstantiationException, because SuperEntity is abstract. If I wont make it abstract, throws IllegalArgumentException, beacause it cannot set specificField to SuperEntity.

http://stackoverflow.com/a/21558540
answers question: http://stackoverflow.com/q/21558457
has body: Because the first j is in then branch while, the second one is in else branch... else and then have two differente scope, so if you declare the same variable in that way there is no problem.. A scope is delimited by { and }. Your code is the same this: public class Main { public static void main(String[] args) { int i=0; int j; if( i == 0){ j = 1; } else{ j = 2; } } }
type: Answer
score: 2
upvote count: 2
downvote count: 0

http://stackoverflow.com/a/21592105
answers question: http://stackoverflow.com/q/21592015
has comment: http://stackoverflow.com/comment/32621345
has comment: http://stackoverflow.com/comment/32657328
score: 0
type: Answer
has body: you need to call addView() for this inflated view View view = layoutInflater.inflate(R.layout.create_build_page, null);
has comment: http://stackoverflow.com/comment/32620867

http://stackoverflow.com/a/21603740
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21603541
has body: I will suggest creating a bounded list. Java does not have an inbuilt one however you can create a custom one using Google collections or use the one in Apache collections. See Is there a bounded non-blocking Collection in Java?

http://stackoverflow.com/q/21528477
has answer: http://stackoverflow.com/a/21528529
tagged with: java
has comment: http://stackoverflow.com/comment/32507461
possible better answer: http://stackoverflow.com/a/21528563
has body: I have an ArrayList in my program and some part of the program I'm parsin an soap object and every item is one tempArraylist.After the item iteration is finished I'm adding this ArrayList into another Arraylist my problem is it's not adding the content it is adding the reference of the tempArray.How can I add the value of array not reference of it. Here is my code. for (int i = 0; i &lt; count; i++) { tempContents.clear(); Log.i(TAG , String.valueOf(count)); Object property = response2.getProperty(i); if (property instanceof SoapObject) { SoapObject category_list = (SoapObject) property; for(int j = 0 ; j&lt;tags.size() ; j++) { if(category_list.getProperty(tags.get(j)).toString().contains("Resim")) { String tempResim = "htttp://www.balikesir.bel.tr/"; tempResim += category_list.getProperty(tags.get(j)).toString(); tempContents.add(tempResim); } else { if(category_list.getProperty(tags.get(j)).toString().equals("anyType{}")) {continue;} tempContents.add(category_list.getProperty(tags.get(j)).toString()); } } for(int k = 0 ;k &lt; tempContents.size() ; k++ ) Log.i("For ici 5 minare",tempContents.get(k)); Log.i("For disi 4 minare","Asdas asdas"); contents.add(tempContents); } }
has answer: http://stackoverflow.com/a/21528563
type: Question
answer count: 2
accepted answer: http://stackoverflow.com/a/21528529
tagged with: arraylist
score: 0
has comment: http://stackoverflow.com/comment/32507402
tagged with: android
has title: Adding ArrayList into Another ArrayList
tagged with: reference
type: AnsweredQuestion

http://stackoverflow.com/comment/32708856
type: Comment
has text: The easiest way to check whether object in the heap is to allocate instances with your hypothesis method, make heap dump with jmap and review objects with MAT.
comment on: http://stackoverflow.com/a/21589474
type: AnswerComment
score: 0

http://stackoverflow.com/comment/32499370
type: Comment
type: QuestionComment
has text: [<Punu_x0020_i_x0020_skraćenu_x0020_firmu_x0020_emitenta>Dioničko društvo</Punu_x0020_i_x0020_skraćenu_x0020_firmu_x0020_emitenta>]
comment on: http://stackoverflow.com/q/21524347
score: 0

http://stackoverflow.com/a/21640586
score: 3
upvote count: 3
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32850488
has comment: http://stackoverflow.com/comment/33031960
has comment: http://stackoverflow.com/comment/32760115
has body: There are couple things going on here: 1) Service Bus doesn't support message browse over AMQP at this time. Because the session was created with AUTO_ACKNOWLEDGE, every message you get from the Enumeration is immediately removed from the queue. 2) I have reproduced the hang in hasMoreElements() with QPid 0.25. It appears that hasMoreElements() is waiting for more messages to arrive in the queue, at least at first. If I send more messages, the loop will continue and some of the newly-arrived messages will be returned, but it stops fairly quickly. I am still investigating to determine what's going on there.
accepted answer of: http://stackoverflow.com/q/21606255
type: Answer
answers question: http://stackoverflow.com/q/21606255
has comment: http://stackoverflow.com/comment/33043139

http://stackoverflow.com/a/21626017
has comment: http://stackoverflow.com/comment/32680634
has comment: http://stackoverflow.com/comment/32679617
has comment: http://stackoverflow.com/comment/32682516
has comment: http://stackoverflow.com/comment/32678909
has comment: http://stackoverflow.com/comment/32679609
has comment: http://stackoverflow.com/comment/32678446
upvote count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/32679590
has comment: http://stackoverflow.com/comment/32678809
has comment: http://stackoverflow.com/comment/32678245
answers question: http://stackoverflow.com/q/21625214
has comment: http://stackoverflow.com/comment/32679279
has comment: http://stackoverflow.com/comment/32681930
has comment: http://stackoverflow.com/comment/32679704
type: Answer
has comment: http://stackoverflow.com/comment/32679482
has comment: http://stackoverflow.com/comment/32678580
has comment: http://stackoverflow.com/comment/32682941
has comment: http://stackoverflow.com/comment/32682822
has comment: http://stackoverflow.com/comment/32679465
has comment: http://stackoverflow.com/comment/32680828
has comment: http://stackoverflow.com/comment/32678160
has body: Write unit tests for your code: @Test public void testFooWithZero() { try{ Test tester = new Test(); assertEquals("Expect string returned", "positive", tester.foo(0)); catch(NullPointerException npe) { fail("Threw NPE"); } } Not only do they describe your expected behaviour (usually better than a lazily written Javadoc), it guarantees your code does what you expect. Write tests for the positive and negative scenarios and you're golden. Static code analysis certainly has its benefits, but it has its limitations - a common case would be how you'd protect against a get(Object) returning null from a HashMap or similar collection. SCA has no way of knowing what data is in the collection at runtime. You're not going to be able to annotate code from core Java packages or third-parties either. Unit tests should be used in a complementary way and will improve the quality of your code. See this question for several benefits and reasons why you should be considering it: Is Unit Testing worth the effort?
has comment: http://stackoverflow.com/comment/32679614
score: 1
has comment: http://stackoverflow.com/comment/32678878

http://stackoverflow.com/q/21674991
linked to: http://stackoverflow.com/q/1883321
duplicate of: http://stackoverflow.com/q/1883321
score: 2
answer count: 1
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/21675114
has body: When debugging code I tend to use System.out &amp; System.err quite a lot. The problem is when an exception is ocurring and i use System.out the same time the outcome doesn't look very organized. [CLIENT]:postinit: vic.rpg.gui.GuiMain.init() java.net.ConnectException: Connection refused: connect [CLIENT]:Destroying Network Thread... [CLIENT]:done! at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) ... [CLIENT]:Starting Server... It's not very severe but it makes reading logs a little bit difficult sometimes.
has comment: http://stackoverflow.com/comment/32764071
linked to: http://stackoverflow.com/q/6121786
tagged with: system.out
type: AnsweredQuestion
upvote count: 2
tagged with: java
type: Question
tagged with: debugging
tagged with: system.err
has title: Synchronize System.out & System.err
has answer: http://stackoverflow.com/a/21675114

http://stackoverflow.com/q/21608240
has body: There's a consensus that using interfaces is better than using classes. I surely agree: a library method accepting ArrayList instead of List would be a crap. There's also a consensus that the performance is always the same. Here my benchmark begs to differ. There are 1 to 4 implementations of both an interface and an abstract class. When more than two implementations get used, the performance starts to diverge. I'm looking for an explanation for this behavior (and also for the origin of the false consensus).
tagged with: java
has answer: http://stackoverflow.com/a/21609074
upvote count: 12
has title: Performance difference between passing interface and class reloaded
accepted answer: http://stackoverflow.com/a/21609074
has comment: http://stackoverflow.com/comment/32647750
answer count: 1
downvote count: 0
tagged with: abstract-class
has comment: http://stackoverflow.com/comment/32647468
tagged with: interface
has comment: http://stackoverflow.com/comment/32648520
linked to: http://stackoverflow.com/q/21571479
favorite count: 0
score: 12
has comment: http://stackoverflow.com/comment/32649901
has comment: http://stackoverflow.com/comment/32647371
type: Question
type: AnsweredQuestion
tagged with: performance

http://stackoverflow.com/comment/32715084
type: AnswerComment
comment on: http://stackoverflow.com/a/21641319
type: Comment
has text: First of all thanks for your help I really appreciate it, as you said I was wrong in the loop, but now I get NullReferenceException in the addToTail method, I have checked it many times, in java works fine and I almost sure but not at all that is beacuse the way that C# works is different, but again Im not sure.
score: 0

http://stackoverflow.com/comment/32521186
comment on: http://stackoverflow.com/q/21536382
score: 0
type: QuestionComment
type: Comment
has text: problem isn't clear enough. maybe you could show it on a sketch - what you are trying to achieve, vs what you get?

http://stackoverflow.com/a/21647467
has comment: http://stackoverflow.com/comment/32725016
answers question: http://stackoverflow.com/q/21645869
type: Answer
accepted answer of: http://stackoverflow.com/q/21645869
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/32723386
has comment: http://stackoverflow.com/comment/32873723
upvote count: 2
type: AcceptedAnswer
has body: You cannot really have two different entries with the same alias. But this is how you can get list of all first level certificates from the key store as a list List&lt;Certificate&gt; certificates = new ArrayList&lt;Certificate&gt;(); Enumeration&lt;String&gt; aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { String alias = aliases.nextElement(); Certificate certificate = keyStore.getCertificate(alias); if (certificate != null) { certificates.add(certificate); } }

http://stackoverflow.com/q/21538448
tagged with: api
answer count: 1
has title: Java application, guitar tuner
favorite count: 0
accepted answer: http://stackoverflow.com/a/21538714
type: AnsweredQuestion
tagged with: java
upvote count: 1
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/21538714
has body: I am currently trying to build a guitar tuner in JAVA using the netbeans IDE. I am hoping to capture the audio using "guitar rig" usb interface with an electric guitar as the input. Does anyone have any guidance on which library would best suit this. javax.sound.sampled or javax.sound.midi? I would also appreciate any guidance on how create the graphics and how best to capture the audio in java. What library is best suited to capture the input. I am fairly new to programming but I am familiar with the best concepts of the JAVA language. Please forgive my naivety. Regards to you all and I appreciate any help.
has comment: http://stackoverflow.com/comment/32525389
score: 0

http://stackoverflow.com/a/21617034
has comment: http://stackoverflow.com/comment/32665198
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/32664067
has body: You would retrieve the data in the same manner that you placed it in: by the key. I don't know what the value of name is which you pass in to your wrapping add method, but in essence, it would be something similar to this: public Info retrieve(String name) { return myTable.get(name); } Further to this, unless you really need the synchronization, use a Map&lt;String, Info&gt; interface with a HashMap concrete implementation instead of Hashtable. It's one of the things that the Javadoc recommends at the bottom.
answers question: http://stackoverflow.com/q/21617007
downvote count: 0
has comment: http://stackoverflow.com/comment/32664350
type: Answer
has comment: http://stackoverflow.com/comment/32664030

http://stackoverflow.com/comment/32560264
comment on: http://stackoverflow.com/q/21558975
score: 1
type: Comment
type: QuestionComment
has text: It appears from the traceback that you're attempting to init a DateTime object withDayOfYear(366). What is the line below the last line above?

http://stackoverflow.com/q/21615510
has body: I had been using admob ads perfectly fine until recently when I decided to run house ads, and then after those stopped it seems like admob turned off all my ads, on their website it shown 0 impressions. When I run the app and an ad request is called this is what the logcat displays: 02-06 17:27:46.757: ERROR/Ads(9298): AdLoader can't parse gWhirl server configuration. 02-06 17:27:46.757: INFO/Ads(9298): The following was caught and handled: org.json.JSONException: No value for ad_networks at org.json.JSONObject.get(JSONObject.java:354) at org.json.JSONObject.getJSONArray(JSONObject.java:544) at com.google.ads.c.a(SourceFile:102) at com.google.ads.internal.c.b(SourceFile:994) at com.google.ads.internal.c.run(SourceFile:902) at java.lang.Thread.run(Thread.java:864) 02-06 17:27:46.757: INFO/Ads(9298): onFailedToReceiveAd(There was an internal error.) This is how my ads are called: AdmobAd.loadAd(new AdRequest()); is this some kind of problem with admob, or is there something I can do to fix it? I had no luck at all in finding contact info for admob on their website. Any advice is appreciated
tagged with: admob
type: UnansweredQuestion
has title: Issue with displaying admob ads
answer count: 0
downvote count: 0
score: 1
favorite count: 0
type: Question
has comment: http://stackoverflow.com/comment/32664627
tagged with: android
tagged with: ads
tagged with: java
upvote count: 1

http://stackoverflow.com/q/21631641
upvote count: 5
linked to: http://stackoverflow.com/q/5451010
has comment: http://stackoverflow.com/comment/32688127
has body: I am trying to teach myself Java and had a question that I wasn't able to answer so far. In some of my reading online I have found two ways of using action listener that seem to do the same thing. But I am trying to figure out what is the advantage/disadvantage of one over the other. Is it better to use anonymous class like this: public MyClass() { ... myButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { //doSomething } }); ... } or is it best to implement at the beginning of the class like so: public MyClass() implements ActionListener { ... myButton.addActionListener(this); public void actionPerformed(ActionEvent e) { //doSomething } ... }
answer count: 3
downvote count: 0
tagged with: event-handling
favorite count: 0
accepted answer: http://stackoverflow.com/a/21631750
tagged with: anonymous-class
has title: java action listener: implements vs anonymous class
type: AnsweredQuestion
tagged with: implements
tagged with: java
has answer: http://stackoverflow.com/a/21631737
type: Question
has answer: http://stackoverflow.com/a/21631744
tagged with: actionlistener
score: 5
has answer: http://stackoverflow.com/a/21631750
possible better answer: http://stackoverflow.com/a/21631737

http://stackoverflow.com/q/21651573
tagged with: mysql
has answer: http://stackoverflow.com/a/21651664
type: Question
upvote count: 0
accepted answer: http://stackoverflow.com/a/21651664
answer count: 1
favorite count: 0
has title: MySQL,Use command line Or GUI tools
score: -2
type: AnsweredQuestion
tagged with: java
has body: I am a java programmer for 2 years. My programs usually uses a database (mysql) (Java SE). Should i use classically command line environment or use GUI tools, mysql administrator for example? Is it necessary to be a database administrator? Or not? I want to be a java programmer. Sorry for this question!
downvote count: 2

http://stackoverflow.com/q/21664677
has title: Creating a contact list with java and object oriented
tagged with: arraylist
upvote count: 2
answer count: 2
has answer: http://stackoverflow.com/a/21664826
accepted answer: http://stackoverflow.com/a/21664826
downvote count: 1
has comment: http://stackoverflow.com/comment/32746797
favorite count: 0
has body: I am new to programming and object oriented design. This is my last requirement to finish my bachelors degree (not in programming). I am so confused with how to make object oriented work, and nothing I look at seems to help. The assignment is to create a contact list that uses inheritance, polymorphism,and collections. I need a contact list that is stores two types of contacts: business and personal. 1. Prompt to select which contact to add or display. 2. Prompt to allow user to enter the contact info. 3. Prompt that will display the output of a chosen contact back. I have the following class and subclasses. I am stuck on how I am supposed to read in the inputs to the specific arraylists. I don't even know if the classes are built right either. Any help would be awesome, I just need to get through this, then I will gladly leave programing to those that know what they are doing. This is what I have for my Parent Class: package ooo1; public abstract class Contact { private String contactId; private String firstName; private String lastName; private String address; private String phoneNumber; private String emailAddress; public Contact(String contactId,String firstName,String lastName, String address, String phoneNumber, String emailAddress) { this.contactId = contactId; this.firstName = firstName; this.lastName = lastName; this.address = address; this.phoneNumber = phoneNumber; this.emailAddress = emailAddress; } public void setContactId(String input){ this.contactId = input; } public String getContactId(){ return contactId; } public void setFirstName(String input){ this.firstName = input; } public String getFirstName(){ return firstName; } public void setLastName(String input){ this.lastName = input; } public String getLastName(){ return lastName; } public void setAddress(String input){ this.address = input; } public String getAddress(){ return address; } public void setPhoneNumber(String input){ this.phoneNumber = input; } public String getPhoneNumber(){ return phon…
possible better answer: http://stackoverflow.com/a/34844972
has answer: http://stackoverflow.com/a/34844972
type: AnsweredQuestion
tagged with: oop
score: 1
tagged with: java
type: Question

http://stackoverflow.com/comment/32623794
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21594071
has text: What is going on in that new Class() constructor? There is something that you aren't showing us as Class isn't Runnable so instance.run() can't possibly work. That, and attach a profiler and figure out where the time goes.
score: 0

http://stackoverflow.com/comment/32671251
has text: All those functions are for date checking. I want to check if for eg . Saturday falls b/w a range of Wednesday to Monday
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21621735

http://stackoverflow.com/a/21575683
type: AcceptedAnswer
type: Answer
has body: You are putting same key, value pair in map and referring same list for both keys. You can check if map contains key if it exists just retrieve value(i.e. list) and add filePath to that list If key does not exist then create new list and add filePath to newly created list, finally add key, value to map Try this code String serverIP = completeFileAddress.substring(0, index); String filePath = completeFileAddress.substring(index, completeFileAddress.length()) + ".WAV"; if(filesMap.containsKey(serverIP)) { ArrayList&lt;String&gt; sourceList = filesMap.get(serverIP); sourceList.add(filePath); } else { ArrayList&lt;String&gt; sourceList = new ArrayList&lt;String&gt;(); sourceList.add(filePath); filesMap.put(serverIP, sourceFileList); }
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/21575502
accepted answer of: http://stackoverflow.com/q/21575502
upvote count: 1

http://stackoverflow.com/a/21673396
type: Answer
score: 0
has comment: http://stackoverflow.com/comment/32763529
has comment: http://stackoverflow.com/comment/32766435
answers question: http://stackoverflow.com/q/21668684
has body: Use the attribute dependsOnMethods, of @Test, to sequentialize your tests. You can read further about the annotations in TestNG at - TectNG Annotations.

http://stackoverflow.com/a/21522897
accepted answer of: http://stackoverflow.com/q/21522831
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/21522831
type: AcceptedAnswer
downvote count: 0
has body: You'd normally create a custom 403 error page and mapping in the web.xml. You'd have this mapped in your web.xml with something like... 403 /general-error.html /general-error.html would be your custom 403 error page. My understanding is these pages should be relatively generic as all the webapp has at the time is the error code, so they should be the same for all users.
type: Answer

http://stackoverflow.com/comment/32652449
comment on: http://stackoverflow.com/q/21610229
has text: Sorry, I thought you added the "0.decimal" part, but I see on review that you didn't.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21633384
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/21633470
has title: Find next smallest key (performance advice needed)
has body: I need some advice in terms of performance. I've got a Map&lt;DateTime, String&gt;. And I need something like the following method: Map&lt;DateTime, BigDecimal&gt; map; // about 50 entries. Btw: Which impl to choose? BigDecimal findNextSmaller(DateTime input) { DateTime tmp = null; for(DateTime d : map.keySet()) { if(tmp == null &amp;&amp; d &lt; input) { tmp = d; } if(d &lt; input &amp;&amp; d &gt; tmp) { tmp = d; } } return map.get(tmp); } So basically I just iterate over the keySet of my Map and try to find the key which is the next smallest compared to input. This method will get called about 1.000.000 times in a row: BigDecimal sum; List&lt;Item&gt; items; // about 1.000.000 Items for(Item i : items) { sum = sum.add(findNextSmaller(i.getDateTime())); } Now I'm looking for a way to make things faster. My first thought was to make an OrderedList out of the Map's keySet. So in average I just have to iterate over half of the DateTimes. And then just do a map.get(dateTimeFromOrderedList) to get the matching value. But is that all I can do about it?
tagged with: dictionary
type: AnsweredQuestion
tagged with: list
accepted answer: http://stackoverflow.com/a/21633470
type: Question
possible better answer: http://stackoverflow.com/a/21633468
tagged with: algorithm
has answer: http://stackoverflow.com/a/21633468
tagged with: java
tagged with: search

http://stackoverflow.com/a/21664275
upvote count: 1
has body: Arrays.binarySearch(lowerBounds, 0) is wrong because you are comparing Range Objects.SO you need to pass a Range Object instead of an Integer Object which results in java.lang.ClassCastException: java.lang.Integer cannot be cast to compareToTest.Range" You need to create a RangeObject and pass it in binarySearch method Range r = new Range(0,&lt;any integer&gt;) Arrays.binarySearch (lowerBounds, r);
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21664198
score: 1

android-activity
tags question: http://stackoverflow.com/q/21673774
tags question: http://stackoverflow.com/q/21651542
tags question: http://stackoverflow.com/q/21598610
tags question: http://stackoverflow.com/q/21658814
tags question: http://stackoverflow.com/q/21627815
tags question: http://stackoverflow.com/q/21646457
tags question: http://stackoverflow.com/q/21661224
tags question: http://stackoverflow.com/q/21547165
tags question: http://stackoverflow.com/q/21597600
tag name: android-activity
tags question: http://stackoverflow.com/q/21662145
tags question: http://stackoverflow.com/q/21667190
tags question: http://stackoverflow.com/q/21666727
tags question: http://stackoverflow.com/q/21516020
type: Tag

http://stackoverflow.com/q/21677142
tagged with: java
has answer: http://stackoverflow.com/a/23567677
has comment: http://stackoverflow.com/comment/35628391
type: Question
has answer: http://stackoverflow.com/a/22618127
has answer: http://stackoverflow.com/a/22590498
has comment: http://stackoverflow.com/comment/35036597
downvote count: 0
tagged with: hdfs
has answer: http://stackoverflow.com/a/26018723
has comment: http://stackoverflow.com/comment/32926919
has title: Running a Job on Spark 0.9.0 throws error
tagged with: apache-spark
answer count: 7
favorite count: 0
has comment: http://stackoverflow.com/comment/41209014
has answer: http://stackoverflow.com/a/27798056
type: UnansweredQuestion
tagged with: scala
has answer: http://stackoverflow.com/a/21696422
score: 13
upvote count: 13
has answer: http://stackoverflow.com/a/37407930
has body: I have a Apache Spark 0.9.0 Cluster installed where I am trying to deploy a code which reads a file from HDFS. This piece of code throws a warning and eventually the job fails. Here is the code /** * running the code would fail * with a warning * Initial job has not accepted any resources; check your cluster UI to ensure that * workers are registered and have sufficient memory */ object Main extends App { val sconf = new SparkConf() .setMaster("spark://labscs1:7077") .setAppName("spark scala") val sctx = new SparkContext(sconf) sctx.parallelize(1 to 100).count } The below is the WARNING message Initial job has not accepted any resources; check your cluster UI to ensure that workers are registered and have sufficient memory how to get rid of this or am I missing some configurations.

http://stackoverflow.com/q/21542774
has title: Any known issues with DELETE-statement in Java's MySQL-Connector?
tagged with: java
tagged with: mysql
tagged with: mysql-connector
accepted answer: http://stackoverflow.com/a/21542833
type: Question
has answer: http://stackoverflow.com/a/21542873
has answer: http://stackoverflow.com/a/21556298
score: 0
possible better answer: http://stackoverflow.com/a/21542842
tagged with: sql
tagged with: jdbc
has answer: http://stackoverflow.com/a/21542842
answer count: 4
has answer: http://stackoverflow.com/a/21542833
has body: I have checked around, and I have checked up the issue all over Google, tried all kind of solutions, but I haven't found any solution. The issue is that the DELETE-statement isn't really working. java.sql.Connection conn = new Connection().getConnection(); try { conn = new Connection().getConnection(); PreparedStatement statement = (PreparedStatement) conn.prepareStatement("DELETE FROM _users WHERE _id = ?"); statement.setInt(1, 4); statement.executeUpdate(); } catch (Exception e) { System.out.println(e); } finally { try { conn.close(); } catch (Exception e) { System.out.println(e); } } This is the code I am using, and for all I have understood statement.executeUpdate() is the method to use. I have also tried statement.execute() and all kinds of tries. There is no exception, so no known error. The new Connection().getConnection() gives away an valid connection ( working with SELECT,INSERT,UPDATE ) and the user has permissions for SELECT,INSERT,UPDATE and DELETE. I am currently using technology such as: Java 6 (1.6) mysql-connector-java-5.1.28.jar and I also had the same experience with mysql-connector-java-5.1.19.jar So I would highly appreciate if anyone had the same problem as I seem to have, what it might be because of and/or how to fix it. Thank you everyone at Stackoverflow. :) Hope this been relevant to anyone else.
has comment: http://stackoverflow.com/comment/32554026
type: AnsweredQuestion

http://stackoverflow.com/a/21619229
has comment: http://stackoverflow.com/comment/32667477
has comment: http://stackoverflow.com/comment/32667567
has comment: http://stackoverflow.com/comment/32792774
type: Answer
has body: You are adding to the list that already contains 5 elements. If you don't want the original elements, you should add to a new list.
score: 0
answers question: http://stackoverflow.com/q/21619114

http://stackoverflow.com/comment/32509000
type: AnswerComment
score: 0
type: Comment
has text: Thank you! It was driving me mad :D
comment on: http://stackoverflow.com/a/21516542

http://stackoverflow.com/q/21618028
has answer: http://stackoverflow.com/a/21618140
has comment: http://stackoverflow.com/comment/32665416
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21618313
has body: I'm working on a project that has two classes. The main class outputs the data while the other class does all the calculations. Quick summary: The user inputs a lot of numbers (0-200) and then has to type a letter to stop input and calculate the numbers inputted. The project that I'm working on says that the other class will have a method public boolean inputInformation that takes in a Scanner object passed in from main(). For some reason I'm having a brain fart and am having trouble understanding what that means (translating to code). Extra Q: my other method public boolean addNumber takes in an integer grade &lt;--- what does that mean in code?
has title: Need help understanding how to connect an object from different class to main class in Java
tagged with: class
has comment: http://stackoverflow.com/comment/32665675
score: 0
answer count: 3
accepted answer: http://stackoverflow.com/a/21618313
has answer: http://stackoverflow.com/a/21618089
possible better answer: http://stackoverflow.com/a/21618140
type: AnsweredQuestion

http://stackoverflow.com/a/21656797
score: 0
answers question: http://stackoverflow.com/q/21656769
type: Answer
upvote count: 1
downvote count: 1
has body: Questions / Attempted Answers: As I follow you have a method using a wildcard that extends comparable where it compares types T and "above." Methods can extend nothing, so no, this is not correct. The method is generic and can be used with concrete class that extends Comparable. It then returns a new Comparator which apparrently has a method inside it that returns value of a compareTo using two objects of type T. So questions: OK, kind of correct. 1) Is this defining a method inside a method? I thought you couldn't do that in Java. It is not a method in a method. It's a method that returns an object of the type Comparator that has its own compare method. 2) Is it returning a method? Something I also thought you couldn't do in Java. No, it returns an object of an anonymous inner class. 3) How do I use this? The book uses examples where other, similar, methods have parameters. This has no parameters, so where do o1 and o2 come from? The o1 and o2 are the declared parameters of the Comparator object's compare method.

http://stackoverflow.com/comment/32534624
comment on: http://stackoverflow.com/q/21544319
score: 0
type: Comment
type: QuestionComment
has text: @crv can you suggest some workaround for the same

http://stackoverflow.com/q/21558675
linked to: http://stackoverflow.com/q/1200621
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32560157
has title: Why is this array not working correctly?
has comment: http://stackoverflow.com/comment/32559699
tagged with: java
downvote count: 3
has comment: http://stackoverflow.com/comment/32559749
type: Question
has answer: http://stackoverflow.com/a/21558719
upvote count: 0
score: -3
favorite count: 0
answer count: 3
has body: Why is this array not working? I'm taking Java as a class and this array isn't working, can you let me know why it's not working? I would have searched if this question was already asked, but I think it's just a super basic question and I don't think anyone has asked it before. Here's the array: class identify { public static void main(String arge[]); { int a[]= new a[4]; a[]={12,14,15,17,21}; System.out.println(a[3]); System.out.println(a[4]); } } http://ideone.com/cvD1I7
has answer: http://stackoverflow.com/a/21558708
has answer: http://stackoverflow.com/a/21558817

http://stackoverflow.com/comment/32598603
type: QuestionComment
comment on: http://stackoverflow.com/q/21580236
score: 1
has text: Looking up the time functions in any Java documentation should be fairly trivial yet you've not said whether or not you attempted this and what problems you encountered. Surely if you could write this code, you could search for time functions?
type: Comment

http://stackoverflow.com/a/21621848
downvote count: 0
score: 30
upvote count: 30
accepted answer of: http://stackoverflow.com/q/21621803
type: Answer
has body: ConcurrentMap.putIfAbsent returns the previous value associated with the specified key, or null if there was no mapping for the key. You did not have a value associated with "key 3". All correct. NOTE: Not just for ConcurrentMap, this applies to all implementations of Map.
answers question: http://stackoverflow.com/q/21621803
type: AcceptedAnswer

http://stackoverflow.com/a/21637818
answers question: http://stackoverflow.com/q/21637752
has comment: http://stackoverflow.com/comment/32700107
has body: There is no performance impact here, because the compiler does all the calculation. The only reason it is done is readability: it is easy to see that 1 &lt;&lt; 30 is two to the power of thirty; not everybody can conclude the same by looking at the decimal representation of the same number 1073741824. Note that a hexadecimal literal would be fine as well: 0x40000000 // same as 1 &lt;&lt; 30 In general, whenever you are dealing with bit patterns, it is much more convenient to show them as a combination of shifts and ORs, as hexadecimal, or as octal literals, because these literals are closely aligned with binary representation. It is much easier to convert them to binary in your head, because you need to deal with one digit at a time.
score: 3
upvote count: 3
has comment: http://stackoverflow.com/comment/32700033
downvote count: 0
type: Answer

http://stackoverflow.com/a/61773554
score: 2
has body: Thats what helps me @Test public void koi8r() { String input = "=?koi8-r?Q?11=5F=F4=ED=5F21=2E05=2Erar?="; String decode = EncodingUtils.decodeKoi8r(input); Assertions.assertEquals("11_ТМ_21.05.rar", decode); } @Test public void koi8rWithoutStartTag() { String input = "=CF=D4=C4=C5=CC=D8=CE=D9=CD =D4=D2=C1=CE=DB=C5=CD =D2=C5=DA=C0=CD=.eml"; String decode = EncodingUtils.decodeKoi8r(input); Assertions.assertEquals("отдельным траншем резюм=.eml", decode); } public static String decodeKoi8r(String text) { String decode; try { decode = MimeUtility.decodeText(text); } catch (UnsupportedEncodingException e) { decode = text; } if (isQuotedKoi8r(decode)) { decode = decode(text, "KOI8-R", "quoted-printable", "KOI8-R"); } return decode; } public static boolean isQuotedKoi8r(String text) { return text.contains("=") || text.toLowerCase().contains("koi8-r"); } public static String decode(String text, String textEncoding, String encoding, String resultCharset) { if (text.length() == 0) { return text; } try { byte[] bytes = text.getBytes(textEncoding); InputStream decodedStream = MimeUtility.decode(new ByteArrayInputStream(bytes), encoding); byte[] tmp = new byte[bytes.length]; int n = decodedStream.read(tmp); byte[] res = new byte[n]; System.arraycopy(tmp, 0, res, 0, n); return new String(res, resultCharset); } catch (IOException | MessagingException e) { return text; } }
has comment: http://stackoverflow.com/comment/115373164
downvote count: 0
upvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/21574745

http://stackoverflow.com/q/21598293
has answer: http://stackoverflow.com/a/21598386
score: 0
answer count: 1
has title: Write variables automatically into child class
type: UnansweredQuestion
tagged with: android
tagged with: oop
tagged with: java
type: Question
has body: I’m trying to achieve the following. I have several a Model that has some basic Methods, such as saveModel, loadModel, laodModel from. Now, I have other classes that extend this Model, e.g. User and Movie. User now has the variables id userName userMail userPW Movie has id movieTitle movieLength movieGenre Now, I create a new User object and load it from the database. So now I when I load a model from Movie, I have a JSON-Object containing the following information: id = x movieTitle = "bla" movieLength = "bla" movieGenre = "bla" As you can see, the jSON contains the correct key and values, now I just have to write them into the child Model. How is it possible, that my Model now writes all the field values into the user object? In PHP I would do it simply like this foreach ($row as $key=&gt;$val) { $this-&gt;$key = $val; } In Java, however it doesn’t seem to be possible. So how can the parent class automatically write variables into the child class. Or isn’t this possible and I have to do it manually? The problem I see here, is, that I would have to do it for every Model again, when I could just do it in the super class. How would I do that?

http://stackoverflow.com/a/21674681
has comment: http://stackoverflow.com/comment/32764637
has body: Your problem is not in JSON and not in the JSONArray so if you got this exception then this means the string to JSONArray not as you expected. Print the string result and the string length before this line "JSONArray jArray=new JSONArray(result);". You can use the below print message for that Log.d("My String", "string result :[" + result + "] and its length is :" + result.length()); Note that, I used the below code and it working fine String str = "[{\"name\":\"Muhaimin\",\"address\":\"Sylhet\",\"bgroup\":\"o+\"}]"; try { JSONArray json = new JSONArray(str); Log.d(TAG, "Json value :" + json); Log.d(TAG, "Json value :" + json.getJSONObject(0).getString("bgroup")); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } result: Json value :[{"bgroup":"o+","address":"Sylhet","name":"Muhaimin"}] Json value :o+
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21674326
answers question: http://stackoverflow.com/q/21674326
type: Answer
has comment: http://stackoverflow.com/comment/32763821
has comment: http://stackoverflow.com/comment/60062670
has comment: http://stackoverflow.com/comment/32763995
has comment: http://stackoverflow.com/comment/32764935
score: 0

permissions
tag name: permissions
type: Tag
tags question: http://stackoverflow.com/q/21575919

http://stackoverflow.com/a/21678337
score: -1
downvote count: 1
type: Answer
upvote count: 0
has body: Is method[0] returning the parseInt method of Integer class ? May be this will help you :- Method m =Integer.class.getMethod("parseInt", String.class); System.out.println(m.invoke(null, "23")); String.class is parameter passing to parseInt i.e "23"
answers question: http://stackoverflow.com/q/21677781

http://stackoverflow.com/a/21603456
upvote count: 3
type: Answer
score: 3
downvote count: 0
has body: The answer is rather simple. The decimal number you wrote in your code with one 9 more is closer to the double which represents exactly 255 than any other double. So, the double that is used in the compilation is exactly equal to 255. While the decimal number with one 9 less is optimally represented with a double I show below. This means that it lies closer to that specific double than any other double. Check out this demo: http://ideone.com/hSqJTJ This is the output: Original double: 254.9999999999999 Cast to int: 254 Exact double: 254.9999999999998863131622783839702606201171875 Original double: 255.0 Cast to int: 255 Exact double: 255
answers question: http://stackoverflow.com/q/21603243

http://stackoverflow.com/a/24551326
type: AcceptedAnswer
type: Answer
upvote count: 1
has body: You could use any of the projects below: Apache Commons OGNL MVEL JBoss EL Spring Expression Language (SpEL)
accepted answer of: http://stackoverflow.com/q/21547637
score: 1
answers question: http://stackoverflow.com/q/21547637
downvote count: 0

sensors
type: Tag
tag name: sensors
tags question: http://stackoverflow.com/q/21658956

http://stackoverflow.com/comment/32501514
type: AnswerComment
comment on: http://stackoverflow.com/a/21525009
type: Comment
has text: You probably need to import it. Just hit `Ctrl + Shift + I` to resolve the import
score: 0

http://stackoverflow.com/q/21567248
has answer: http://stackoverflow.com/a/21573518
has title: Strange performance drop of JDK8 LocalDate.toEpochDay
type: Question
tagged with: benchmarking
score: 5
has answer: http://stackoverflow.com/a/21567499
tagged with: caliper
answer count: 2
has body: I was curious if we finally get a fast datetime library with JDK8. Nearly all LocalDate computations use toEpochDay so I looked at the source and the large number of divisions and branches made me curious if I could do better. I eliminated some branching and all but one division, however the speedup is worse than expected. So my first question how is it possible that an algorithm using multiple division takes only about 30 cycles (throughput). Holger's comments seem to have answered this: Division by a small constant gets JIT-ed to multiplication. I did it manually and now I'm consistently beating the original implementation by a factor of 2. The benchmark is pretty straightforward, just iterate though an array of random LocalDates and convert each of them toEpochDay. Despite the randomness, the results are pretty consistent. The size of the array is a parameter and my main question is where the big slowdown between 2000 and 30000 comes from. There's should be some slowdown as the data no more fit in the L1 cache, but the memory accesses of both algorithms are exactly the same (i.e., none but fetching the date from the array). The still open question is: How it comes that the behaviour of two simple memory-access-free implementations of the same function change when iterating over an array? The original algorithm suffers a much bigger slowdown than mine. My algorithm is probably not worth copying here, it's undocumented and about as cryptic as the original, and there's only a very rudimentary test.
upvote count: 5
type: UnansweredQuestion
tagged with: datetime
tagged with: performance
downvote count: 0
tagged with: java
favorite count: 0

http://stackoverflow.com/q/21613597
favorite count: 0
has body: I followed the Jersey tutorials to implement a completely custom SecurityContext for my application. I created a custom ContainerRequestFilter to set the SecurityContext as follows: package com.my.security; @Provider @Priority(Priorities.AUTHORIZATION) public class SecurityRequestFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) { requestContext.setSecurityContext(new MySecurityContext(requestContext)); } public static final class MySecurityContext implements SecurityContext { private String token; public MySecurityContext(ContainerRequestContext requestContext) { token = requestContext.getHeaderString("token"); } @Override public boolean isUserInRole(String role) { return role.equals("admin") &amp;&amp; token.equals("token-for-admin"); } // other methods omitted } } The logic in the isUserInRole method is irrelevant, it's just a mock to make the point. My endpoint looks something like: package com.my.rest; @PermitAll @Path("/people") public class PeopleRestService { @RolesAllowed({"admin"}) @Path("/{email}") @DELETE public Response deletePerson(@PathParam("email") final String email) { peopleService.removePerson(email); return Response.ok().build(); } } Now I created a test (using JerseyTest) configured with the packages where the two classes are: @Override protected Application configure() { return new ResourceConfig().packages("com.my.rest", "com.my.security"); } If I execute the following in my test: Response response = target("people/my@email.com") .request().header("token", "token-for-admin").delete(); Assert.assertEquals(200, response.getStatus()); everything works fine. However, if I execute the following: Response response = target("people/my@email.com").request().delete(); Assert.assertEquals(403, response.getStatus()); I would expect a 403 error code because I didn't set the authentication token. However, I get a 500 error code and a Grizzly (the container used for the test) HTML response with …
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
tagged with: http
type: Question
tagged with: jersey
has title: JAX-RS custom SecurityContext leads to wrong error code in Jersey
has answer: http://stackoverflow.com/a/21613705
accepted answer: http://stackoverflow.com/a/21613705
answer count: 1
tagged with: http-status-code-403
tagged with: rest
upvote count: 1

http://stackoverflow.com/a/21629943
type: Answer
has comment: http://stackoverflow.com/comment/32685405
downvote count: 0
has comment: http://stackoverflow.com/comment/32685515
has comment: http://stackoverflow.com/comment/32686798
answers question: http://stackoverflow.com/q/21629726
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/32685741
has comment: http://stackoverflow.com/comment/32685318
has body: First create a project in eclipse with class A (Creating project in Eclipse) Export this project as jar (Exporting jar in Eclipse) Create another project with class B and set class path of for exported jar (Setting class path in Eclipse) Now you can use object of A in B. import com.A; public class B{ public static void main(String[] args){ A a=new A(); //....... } }

http://stackoverflow.com/a/21579480
type: Answer
has body: If the problem is actually determining which color to paint a cell, the easiest way is to look at whether the two numbers added together is an odd number or an even number and paint the cell accordingly. i.e. for each cell boolean blackSquare = (x+y)%2==0; If blackSquare is set then paint the cell one colour, if not then paint it the other. To actually set the colour, just make the appropriate call before painting the square.
upvote count: 3
score: 3
downvote count: 0
answers question: http://stackoverflow.com/q/21579281
has comment: http://stackoverflow.com/comment/32597029

http://stackoverflow.com/q/21637912
tagged with: authentication
type: Question
tagged with: jakarta-ee
has comment: http://stackoverflow.com/comment/32878051
has comment: http://stackoverflow.com/comment/32835352
score: 0
has comment: http://stackoverflow.com/comment/32882153
has comment: http://stackoverflow.com/comment/32714640
tagged with: websocket
has body: I have created a WebSocket with the JEE7 standard API. I have a class annotated with @ServerEndPoint and three methods annotated with @OnOpen, @OnClose and OnMessage. I´m deploying the application in a Glassfish v4 and it works but when I invoke the getUserPrincipal() method from some Session instance, it returns always null. This is the code I´m ussing to test it: @ServerEndpoint(value = "/chat") public class ChatServerEndpoint { private static final Logger LOG = LoggerFactory.getLogger(ChatServerEndpoint.class); @OnOpen public void onOpen(Session session) { LOG.debug("Opening a session with id " + session.getId() + " for " + session.getUserPrincipal()); } @OnClose public void onClose(Session session) { LOG.debug("Closing the session " + session.getId() + " associated with " + session.getUserPrincipal()); } @OnMessage public void onMessage(Session session, String msg) { LOG.debug("There are " + session.getOpenSessions().size() + " opened sessions"); for (Session sess : session.getOpenSessions()) { LOG.debug("Session " + sess.getId() + " associated with " + sess.getUserPrincipal()); try { sess.getBasicRemote().sendText(msg); } catch (IOException e) { LOG.error("Error sending message", e); } } } } This code is as simple as possible to narrow the problem. This is the log output: 22:22:48.638 [http-listener-1(1)] DEBUG e.p.server.rs.ChatServerEndpoint - Opening a session with id 437a9b4d-c694-4a19-b912-47b88da4eb9a for null 22:22:54.350 [http-listener-1(5)] DEBUG e.p.server.rs.ChatServerEndpoint - There are 1 opened sessions 22:22:54.351 [http-listener-1(5)] DEBUG e.p.server.rs.ChatServerEndpoint - Session 437a9b4d-c694-4a19-b912-47b88da4eb9a associated with null 22:23:58.888 [http-listener-1(2)] DEBUG e.p.server.rs.ChatServerEndpoint - Closing the session 437a9b4d-c694-4a19-b912-47b88da4eb9a associated with null I tried to make it work by including the websocket path in the web-resource-collection of the security-constraint for JAAS configuration (web.xml file) but in…
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32711881
has comment: http://stackoverflow.com/comment/32783054
answer count: 0
has comment: http://stackoverflow.com/comment/32882169
has title: Method getUserPrincipal in Websockets implementation for Glassfish is not working
tagged with: java
tagged with: glassfish-4

http://stackoverflow.com/comment/32668177
comment on: http://stackoverflow.com/q/21617082
score: 0
type: Comment
type: QuestionComment
has text: could you post the log of the server which will be diplayed on console?

http://stackoverflow.com/a/21601422
has comment: http://stackoverflow.com/comment/32635913
has comment: http://stackoverflow.com/comment/32636763
score: 5
type: Answer
has comment: http://stackoverflow.com/comment/32677187
has body: Change: if(tempUser.getPhoneNumber().equals(array[1])) To: if(java.util.Objects.equals(tempUser.getPhoneNumber(), array[1])) Objects.equals is null-safe and will not mind when the phone number is null.
upvote count: 5
has comment: http://stackoverflow.com/comment/32677285
has comment: http://stackoverflow.com/comment/32678427
accepted answer of: http://stackoverflow.com/q/21600799
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21600799
has comment: http://stackoverflow.com/comment/32635388

http://stackoverflow.com/comment/32532265
type: Comment
type: QuestionComment
score: 0
has text: I'm on windows 7, 64 bit. I'm using Java 7 JDK and JRE, both update in the past 24 hours. I'm using Eclipse v.3.3.2. (Screenshot added)
comment on: http://stackoverflow.com/q/21538345

http://stackoverflow.com/a/21541764
score: 0
type: Answer
has body: For regex expressions, you have to escape the [ and ] characters because they are part of regex delimiters. So you would need to do this: String[] splitOne = i.split("\\["); String[] splitTwo = splitOne[1].split("\\]"); However, you don't even need to split it a second time. If you're sure that the number after [ is only one digit, you could simply do this: public static int splitter(String i) { String[] splitOne = i.split("\\["); int extractedNumber = Integer.parseInt(splitOne[1].substring(0,1)); return extractedNumber; } Using substring to only parse the first digit.
answers question: http://stackoverflow.com/q/21541627

http://stackoverflow.com/q/21533356
has answer: http://stackoverflow.com/a/21533881
accepted answer: http://stackoverflow.com/a/21533881
tagged with: imageicon
possible better answer: http://stackoverflow.com/a/21533747
type: AnsweredQuestion
downvote count: 0
tagged with: dynamic
score: 1
tagged with: java
has body: My program currently adds an image to a List, which it then creates a Jbutton dynamically storing a thumbnail. Like found here. although the images are added as the user selects them. The issue I am having is that I cannot get the image to change to the thumbnail that is selected as they are not linked to the images in the list. Is there a way I can store the index number of the image in the button, so when I click it I know which image to show in the List? Or is there another more intelligent way? Thanks. //Create thumbnail private void createThumbnail(ImpImage image){ Algorithms a = new Algorithms(); ImpImage thumb = new ImpImage(); //Create Thumbnail thumb.setImg(a.shrinkImage(image.getImg(), 75, 75)); //Create ImageIcon ImageIcon icon = new ImageIcon(thumb.getImg()); //Create JButton JButton iconButton = new JButton(icon); //Create ActionListener iconButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { bottomBarLabel.setText("Clicked"); imagePanel.removeAll(); imagePanel.add(images.get(position)); //Needs Fixing imagePanel.revalidate(); } }); //Add to previewPanel previewPanel.add(iconButton); previewPanel.revalidate(); previewPanel.repaint(); } The way I have implemented this is: 1) Open image, 2) Add image to List, 3)Create a thumbnail of image -> add to ImageIcon -> add to Jbutton -> add to component w/ actionListener. The issue is I don't store the buttons in a list so it doesn't know what number its respective image is in the List.
type: Question
tagged with: jbutton
has answer: http://stackoverflow.com/a/21533747
tagged with: image
answer count: 2
upvote count: 1
has title: Is there a way to store data in a JButton?
favorite count: 0

http://stackoverflow.com/q/21566061
tagged with: java
upvote count: 1
has title: how to check if FTP path exists and writable in java
type: Question
has answer: http://stackoverflow.com/a/21566101
answer count: 1
downvote count: 0
has body: I would like to check the below in my java spring project. Ftp path:- ftp://mmepx/gpi/nsdsdfdt/fromDIR 1) I want to check if the above mentioned FTP path is working and accessible for writing in that folder "fromDir I am using JDK1.6 and spring. Appreciate any help. Thanks
accepted answer: http://stackoverflow.com/a/21566101
favorite count: 0
has comment: http://stackoverflow.com/comment/32573799
linked to: http://stackoverflow.com/q/17454529
type: AnsweredQuestion
score: 1

http://stackoverflow.com/q/21634617
has body: I'm making a simple temperature conversion program in Java that converts Fahrenheit to Celsius. My program compiles just fine, but no matter what number I input, it always says that Celsius is 0.0! What could I be doing wrong? Here is my full code: import javax.swing.JOptionPane; public class FahrenheitToCelsius { public static void main(String[] args) { double fahrenheit, celsius; String input = JOptionPane.showInputDialog("Please enter the temperature in Fahrenheit:"); fahrenheit = Double.parseDouble(input.trim()); celsius = (5 / 9) * (fahrenheit - 32); JOptionPane.showMessageDialog(null, "The temperature is " + celsius + " degrees celsius."); } }
has answer: http://stackoverflow.com/a/21635075
tagged with: swing
answer count: 4
type: AnsweredQuestion
tagged with: joptionpane
tagged with: java
accepted answer: http://stackoverflow.com/a/21634637
linked to: http://stackoverflow.com/q/7325882
has title: Celsius is always 0.0?
type: Question
has comment: http://stackoverflow.com/comment/32693853
linked to: http://stackoverflow.com/q/21400191
duplicate of: http://stackoverflow.com/q/7325882
has answer: http://stackoverflow.com/a/21634663
duplicate of: http://stackoverflow.com/q/21400191
score: 0
possible better answer: http://stackoverflow.com/a/21634663
has answer: http://stackoverflow.com/a/21634658
has answer: http://stackoverflow.com/a/21634637

http://stackoverflow.com/a/21675348
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21674747
has comment: http://stackoverflow.com/comment/32769820
answers question: http://stackoverflow.com/q/21674747
downvote count: 0
has comment: http://stackoverflow.com/comment/32768923
upvote count: 2
type: Answer
has body: You could use scene2d in this case, if you want to catch input events on your Actors, for example mouse clicks. That's actually one of the main uses for scene2d (and why it's used mostly for UI). Another reason is the ability to group actors, but I think you wouldn't need that. If you do not want to catch input events on your game objects, then you should not use scene2d. Simulating what scene2d's Stage does is as easy as maintaining a List&lt;Entity&gt; and calling entity.update(delta) (equivalent to stage.act()) and entity.render(delta) (equivalent to stage.draw()) on each entity in the list.
score: 2
has comment: http://stackoverflow.com/comment/32770644

jpanel
tags question: http://stackoverflow.com/q/21516056
tags question: http://stackoverflow.com/q/21668016
tags question: http://stackoverflow.com/q/21592492
tags question: http://stackoverflow.com/q/21614400
tags question: http://stackoverflow.com/q/21541052
tags question: http://stackoverflow.com/q/21617469
tags question: http://stackoverflow.com/q/21648533
tags question: http://stackoverflow.com/q/21657220
tags question: http://stackoverflow.com/q/21555968
tags question: http://stackoverflow.com/q/21619170
tags question: http://stackoverflow.com/q/21587309
tags question: http://stackoverflow.com/q/21558916
tags question: http://stackoverflow.com/q/21636895
tags question: http://stackoverflow.com/q/21526631
type: Tag
tags question: http://stackoverflow.com/q/21581247
tags question: http://stackoverflow.com/q/21617162
tags question: http://stackoverflow.com/q/21649366
tags question: http://stackoverflow.com/q/21567437
tags question: http://stackoverflow.com/q/21641542
tags question: http://stackoverflow.com/q/21658144
tags question: http://stackoverflow.com/q/21572777
tags question: http://stackoverflow.com/q/21589134
tags question: http://stackoverflow.com/q/21639620
tags question: http://stackoverflow.com/q/21548866
tags question: http://stackoverflow.com/q/21567177
tags question: http://stackoverflow.com/q/21581671
tags question: http://stackoverflow.com/q/21642617
tags question: http://stackoverflow.com/q/21644014
tags question: http://stackoverflow.com/q/21654777
tags question: http://stackoverflow.com/q/21588060
tags question: http://stackoverflow.com/q/21617038
tags question: http://stackoverflow.com/q/21534755
tags question: http://stackoverflow.com/q/21562350
tags question: http://stackoverflow.com/q/21672466
tags question: http://stackoverflow.com/q/21678077
tag name: jpanel
tags question: http://stackoverflow.com/q/21516570
tags question: http://stackoverflow.com/q/21584703
tags question: http://stackoverflow.com/q/21586765
tags question: http://stackoverflow.com/q/21562638
tags question: http://stackoverflow.com/q/21650420
tags question: http://stackoverflow.com/q/21524781
tags question: http://stackoverflow.com/q/21538789

http://stackoverflow.com/comment/32683034
type: Comment
has text: That's a whole different question, isn't it?
comment on: http://stackoverflow.com/a/21627919
type: AnswerComment
score: 1

http://stackoverflow.com/q/21632411
has answer: http://stackoverflow.com/a/21632745
has title: Texture/background Image for polygon
type: Question
tagged with: polygon
downvote count: 0
favorite count: 0
answer count: 1
tagged with: textures
linked to: http://stackoverflow.com/q/20734438
has body: I'm writing a tiled game board with hexagonal shape tiles using java swing. I'm able to draw polygon with help of this SOF thread. Now I want to add background image to these hexagons and I have totally no idea how to do this. Here is a tutorial that draws background on "Rectangle" but how can I do the same on Hexagon?
upvote count: 2
tagged with: swing
accepted answer: http://stackoverflow.com/a/21632745
score: 2
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/q/21649566
has title: Android JSON object parse store in array list which will change each time button clicked
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32720143
has comment: http://stackoverflow.com/comment/32720381
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has body: I am having problems parsing JSON data to my android application. I need to parse a JSON object as listed below. For my application i want to pull this json data store it in an array. then display each question along with possible answers using text view and buttons. I then want to display then next question in the array along with the possible answers. JSON Object { "52f66c6eb82944cc1c00002a": { "_id": { "$id": "52f66c6eb82944cc1c00002a" }, "Question": "Capital city of England", "Answer 1": "Paris", "Answer 2": "Liverpool", "Correct Answer": "London" }, "52f66c8ab82944780d000029": { "_id": { "$id": "52f66c8ab82944780d000029" }, "Question": "Capital city of Ireland", "Answer 1": "Cork", "Answer 2": "Liverpool", "Correct Answer": "Dublin" } } android code import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicNameValuePair; import org.json.JSONException; import org.json.JSONObject; import android.app.Activity; import android.content.Intent; import android.graphics.Color; import android.os.Bundle; import android.os.StrictMode; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends Activity { protected TextView TitleTextView; protected Button PossibleAnswer1; protected Button PossibleAnswer2; protected Button CorrectAnswer; protected String URL ="http://127.0.0.1/mongo-form-create-quiz/processform.php"; protected HttpClient HTTPClient; protected HttpPost HT…
type: Question
tagged with: mongodb
has answer: http://stackoverflow.com/a/21649854
has comment: http://stackoverflow.com/comment/32720085
answer count: 1
has comment: http://stackoverflow.com/comment/32720019
score: 0
tagged with: android
has comment: http://stackoverflow.com/comment/32719938
tagged with: mongohq

http://stackoverflow.com/q/21516540
has answer: http://stackoverflow.com/a/21646183
score: 3
accepted answer: http://stackoverflow.com/a/21646183
upvote count: 3
tagged with: java
tagged with: multithreading
type: Question
has comment: http://stackoverflow.com/comment/32699136
linked to: http://stackoverflow.com/q/533783
tagged with: weblogic11g
linked to: http://stackoverflow.com/q/3212255
answer count: 1
downvote count: 0
favorite count: 0
has body: I need a custom threda on my weblogic server; I cannot use TimerEJB or Delayed MDB since I have to use a 3d library. I know that custom threads on application server are discouraged; here a related post (4 years old): Why is spawning threads in Java EE container discouraged? Is it still discouraged? Can I use ExecutorService or Quartz? Or I have to consider only commonj and worker manager?
has comment: http://stackoverflow.com/comment/32701263
tagged with: commonj
has title: Custom Thread on Weblogic Server 11g
type: AnsweredQuestion

http://stackoverflow.com/comment/32745722
type: Comment
type: QuestionComment
score: 2
has text: The second parameter of `binarySearch` is the value to search for, so it should not be an int but a `Range` object.
comment on: http://stackoverflow.com/q/21664198

http://stackoverflow.com/a/21626540
has comment: http://stackoverflow.com/comment/53363907
downvote count: 3
has comment: http://stackoverflow.com/comment/32679233
has comment: http://stackoverflow.com/comment/32678989
score: -1
has body: Use a Comparator... public class AnimalAgeComparator implements Comparator&lt;Animal&gt; { @Override public int compare(Animal a1, Animal a2) { ... } }
type: Answer
answers question: http://stackoverflow.com/q/21626439
upvote count: 2

http://stackoverflow.com/a/21666787
score: 0
type: AcceptedAnswer
type: Answer
answers question: http://stackoverflow.com/q/21647331
has body: The problem was quite obvious -- the instance of HibernateDataAccess I was using wasn't the same on the server was calling the listener methods on, so the session factory that was having the current session registered was a different one to the one my code was trying to use. The solutions was to separate the two concerns: have an entirely separate @WebListener class that called to my singleton HibernateDataAccess to start and close sessions.
accepted answer of: http://stackoverflow.com/q/21647331

http://stackoverflow.com/a/21604707
has comment: http://stackoverflow.com/comment/32641431
has comment: http://stackoverflow.com/comment/32640994
answers question: http://stackoverflow.com/q/21604580
has body: Actually it is not the way to do that in JDBC. That way, even if you sort your syntax error, your code is prone to sql injection attacks. The right way would be: // Let's say your user id is an integer PreparedStatement stmt = connection.prepareStatement("select * from userx where id=?"); stmt.setInt(1, getUser.ID); ResultSet rs = stmt.executeQuery(); This way you are guarded against any attempt to inject SQL in your application request parameters
upvote count: 5
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/32640968
has comment: http://stackoverflow.com/comment/32641700
score: 5

http://stackoverflow.com/a/27906924
upvote count: 2
has body: Make sure that you are using the right client library. This example is based on YouTube Data API v3 pom.xml com.google.apis google-api-services-youtube v3-rev125-1.19.1 SubscriberCount.java HttpRequestInitializer httpRequestInitializer = new HttpRequestInitializer() { public void initialize(HttpRequest request) throws IOException { } }; YouTube youTube = new YouTube.Builder(new NetHttpTransport(), new JacksonFactory(), httpRequestInitializer) .setApplicationName("<Your-Application-Name>") .build(); YouTube.Channels.List search = youTube.channels().list("statistics"); search.setForUsername("codeherenow"); search.setKey("<Insert-API-Key>"); ChannelListResponse response = search.execute(); List<Channel> channels = response.getItems(); for (Channel channel : channels) { System.out.println(channel.getStatistics().getSubscriberCount()); }
downvote count: 0
answers question: http://stackoverflow.com/q/21665532
type: Answer
score: 2

http://stackoverflow.com/q/21662078
downvote count: 0
score: 1
favorite count: 0
has body: I have some code that is parsing an int from a string: int number = Integer.parseInt(a[0]); there is no guarantee that the string I will receive is well formed and this may throw a NumberFormatException. However, as this exception is optional, Eclipse does not give me a light bulb for generating it. Is there a menu or context menu option to wrap an exception of a method beneath the cursor or carrot?
tagged with: exception
has answer: http://stackoverflow.com/a/21662274
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21662274
tagged with: java
upvote count: 1
tagged with: eclipse
type: Question
possible better answer: http://stackoverflow.com/a/21662106
has answer: http://stackoverflow.com/a/21662106
has title: How to generate code for an optional Java exception in Eclipse
answer count: 2

http://stackoverflow.com/q/21626653
downvote count: 0
has answer: http://stackoverflow.com/a/21627369
tagged with: java
tagged with: swing
tagged with: jtextfield
type: Question
has answer: http://stackoverflow.com/a/21626751
has title: How to validate an email from JTextField
score: 4
possible better answer: http://stackoverflow.com/a/21626751
answer count: 2
tagged with: validation
favorite count: 0
has body: Just like the title says, I want to display a jOptionPane if there's a missing specific character in a jTextField. Let's say that character is "@". I tried something like this: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { String email = (String)txtEmail.getText(); if (!email.equals(email) &amp;&amp; email.equals("@")){ jOptionPane1.showMessageDialog(null, "Please"); } } However, I can't get this to work. I also tried using contains() and contentEquals() but I don't know how to use it properly so I had changed the code. Searching on Google also doesn't help because I can't find what I want. Please consider helping. BTW, I'm using netbeans.
accepted answer: http://stackoverflow.com/a/21627369
upvote count: 4
type: AnsweredQuestion
tagged with: joptionpane

http://stackoverflow.com/a/21571656
answers question: http://stackoverflow.com/q/21571279
type: Answer
score: -1
downvote count: 2
upvote count: 1
has comment: http://stackoverflow.com/comment/32586250
has comment: http://stackoverflow.com/comment/32586631
has body: Try stringName.split('*'), where * is what character you want to split the string at. It returns a String array.

http://stackoverflow.com/a/21634005
answers question: http://stackoverflow.com/q/21633912
has comment: http://stackoverflow.com/comment/32696664
has comment: http://stackoverflow.com/comment/32692991
has comment: http://stackoverflow.com/comment/32693142
score: -1
has comment: http://stackoverflow.com/comment/32693608
upvote count: 0
has comment: http://stackoverflow.com/comment/32693328
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32693266
has comment: http://stackoverflow.com/comment/32693428
has comment: http://stackoverflow.com/comment/32693564
has body: This will get you close, it will need some tweaking StringBuffer input = new StringBuffer(); while (scanner.hasNextLine()) { input.append(scanner.nextline()); } System.out.println(input.toString());
type: Answer
has comment: http://stackoverflow.com/comment/32692778
has comment: http://stackoverflow.com/comment/32693363
has comment: http://stackoverflow.com/comment/32693510
has comment: http://stackoverflow.com/comment/32693752
has comment: http://stackoverflow.com/comment/32692633
downvote count: 1
accepted answer of: http://stackoverflow.com/q/21633912
has comment: http://stackoverflow.com/comment/32702247
has comment: http://stackoverflow.com/comment/32693432

http://stackoverflow.com/comment/32553266
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21553012
has text: @Gorb *"Still, attitude yo :/"* It's OK. Folks are very forgiving of a petulant, 'I am a precious snowflake' attitude like you just displayed. Chill.. ;)
score: 0

http://stackoverflow.com/q/21659895
has answer: http://stackoverflow.com/a/21660094
downvote count: 0
favorite count: 0
linked to: http://stackoverflow.com/q/7469018
type: UnansweredQuestion
has title: No such file or directory on bolts
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/21660029
upvote count: 1
tagged with: apache-storm
has comment: http://stackoverflow.com/comment/32783353
type: Question
has comment: http://stackoverflow.com/comment/53924051
has body: Sometimes I see the following exception: java.io.IOException: No such file or directory at java.io.UnixFileSystem.createFileExclusively(Native Method) ~[na:1.7.0_11] at java.io.File.createNewFile(File.java:947) ~[na:1.7.0_11] at backtype.storm.util$touch.invoke(util.clj:442) ~[storm-core-0.9.0-wip17.jar:na] at backtype.storm.daemon.worker$eval4389$exec_fn__1048__auto____4390.invoke(worker.clj:337) ~[na:na] at clojure.lang.AFn.applyToHelper(AFn.java:185) [clojure-1.4.0.jar:na] at clojure.lang.AFn.applyTo(AFn.java:151) [clojure-1.4.0.jar:na] at clojure.core$apply.invoke(core.clj:601) ~[clojure-1.4.0.jar:na] at backtype.storm.daemon.worker$eval4389$mk_worker__4445.doInvoke(worker.clj:329) [na:na] at clojure.lang.RestFn.invoke(RestFn.java:512) on bolt startup. From the launcher, everything seems fine (it tells me that the topology was submitted correctly). However, when I'm trying to read the logs in the bolt, I see the above exception. Another weird thing - I can see the exception, only when I have 2 topologies I created up and running (the topologies have different name, and their bolts are not identical (meaning - some bolts are the same, some aren't) Do you know what is the source of it?
answer count: 2

http://stackoverflow.com/comment/32643015
type: Comment
has text: @TanmayPatil so i am not wrong? xD I tryed to google it but could not find it anymore... However i allready implemented it xD
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21596317

http://stackoverflow.com/comment/32657136
type: Comment
type: QuestionComment
has text: @HotLicks in regards to the objects or their references?
comment on: http://stackoverflow.com/q/21613098
score: 0

http://stackoverflow.com/comment/118917866
comment on: http://stackoverflow.com/a/67273330
type: Comment
has text: You might want to explain why you believe the previous (which?) switch needs fixing. + Why are you using `ls` to check for a folder existence? That's inefficient. Use `stat`.
score: 0
type: AnswerComment

http://stackoverflow.com/a/21601269
answers question: http://stackoverflow.com/q/21601168
type: Answer
type: AcceptedAnswer
downvote count: 0
has body: The signature of mehod getAnnotation looks like this: public <A extends Annotation> A getAnnotation(Class annotationClass) Now the difference between the 2 calls is, you are using raw type Class for myClass in 2nd code. When you use raw type for a generic type, all the generic type information is erased, and the compiler will see only the erasure of the method getAnnotation for that particular reference, which is: public Annotation getAnnotation(Class annotationClass) So, it returns Annotation, and not MyAnnotation. From JLS §4.6 - Type Erasure: The erasure of a type variable (§4.4) is the erasure of its leftmost bound. Whereas, in case of using Class<?>, the type parameter A will be inferred as MyAnnotation from the parameter you are passing to the method - Class<MyAnnotation>. So, the return type of method is seen as MyAnnotation. See JLS § 4.8 - Raw Types: The type of a constructor (§8.8), instance method (§8.4, §9.4), or non-static field (§8.3) M of a raw type C that is not inherited from its superclasses or superinterfaces is the raw type that corresponds to the erasure of its type in the generic declaration corresponding to C.
accepted answer of: http://stackoverflow.com/q/21601168
score: 8
upvote count: 8

http://stackoverflow.com/a/21586787
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21586637
has comment: http://stackoverflow.com/comment/32611450
has body: You can use property as Point class public class Point { private int x = 0; public void setX(int x) { this.x = x; } } public class Curve { Point cenetrPoint; public void setCenterPoint(Point p) { this.cenetrPoint = p; } }
has comment: http://stackoverflow.com/comment/32611287

http://stackoverflow.com/comment/42266761
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/26851779
has text: In the code of android I think only one line should be be changed it. i.e instead of String url ="http://192.168.2.7:90/IService/Service.svc?wsdl" String url ="http://192.168.2.7:90/IService/Service.svc" should be mentioned.

http://stackoverflow.com/q/21593825
has comment: http://stackoverflow.com/comment/32622961
score: 1
tagged with: java
has title: boolean function that contains "bab"
has comment: http://stackoverflow.com/comment/32623642
type: Question
has body: How could I have a recursive boolean method that will check if it contains bab. I have this but I I'd like to do it recursively. public static boolean hasBAB(String str) { if (str.length() &lt; 3) return false; if (str.substring(0,3).equals("bab")) return true; else return false; }
has answer: http://stackoverflow.com/a/21593867
has answer: http://stackoverflow.com/a/21594554
downvote count: 0
has comment: http://stackoverflow.com/comment/32623778
has comment: http://stackoverflow.com/comment/32623406
accepted answer: http://stackoverflow.com/a/21594554
answer count: 3
has comment: http://stackoverflow.com/comment/32623841
favorite count: 0
has comment: http://stackoverflow.com/comment/32622956
possible better answer: http://stackoverflow.com/a/21593872
has comment: http://stackoverflow.com/comment/32623048
has comment: http://stackoverflow.com/comment/32623151
has answer: http://stackoverflow.com/a/21593872
upvote count: 1
has comment: http://stackoverflow.com/comment/32622966
tagged with: recursion
type: AnsweredQuestion

http://stackoverflow.com/comment/32566147
type: AnswerComment
has text: Okay, You guys have managed to hit on one of my pet peeves. it's -1 now for pedantically following the letter of the question and not considering what the OP might really need
type: Comment
comment on: http://stackoverflow.com/a/21562106
score: 1

http://stackoverflow.com/q/21583613
has comment: http://stackoverflow.com/comment/32606666
has answer: http://stackoverflow.com/a/21633742
type: UnansweredQuestion
tagged with: annotations
tagged with: java
has comment: http://stackoverflow.com/comment/32604605
type: Question
has answer: http://stackoverflow.com/a/21594304
answer count: 2
tagged with: jpa
score: 0
has title: Getting value of attribute specified in JPA annotation
has body: Assuming that I have some entity with a field annotated as follows: @Column(name="title", length=255) private String title; how could I get the value of the 'length' attribute with Java?

http://stackoverflow.com/a/21570482
upvote count: 0
has comment: http://stackoverflow.com/comment/32581686
has comment: http://stackoverflow.com/comment/32584687
score: -2
answers question: http://stackoverflow.com/q/21570417
downvote count: 2
has comment: http://stackoverflow.com/comment/32583734
has comment: http://stackoverflow.com/comment/32585068
has body: You have to check systemFunctions whether it is null and whether its length is greater than 0: if(systemFunctions!=null &amp;&amp; systemFunctions.length&gt;0){ ... }
type: Answer

http://stackoverflow.com/q/21649958
has title: How to use a java iterator across classes?
type: AnsweredQuestion
has body: I am using this iterator for the board class and now i want to use the stack i return in some other class where i want to iterate over this stact how do i iterate through it using this stack. Thanks in advance public Iterable&lt;Board&gt; neighbors(){ Stack&lt;Board&gt; boardit=new Stack&lt;Board&gt;(); int i=0,j=0; for(i=0;i&lt;N;i++){ for(j=0;j&lt;N;j++){ if(this.board[i][j]==0) break; } } if(this.validate(i-1, j)){ Board ngh1=new Board(this.board); int temp=ngh1.board[i][j]; ngh1.board[i][j]=ngh1.board[i-1][j]; ngh1.board[i-1][j]=temp; boardit.push(ngh1); } if(this.validate(i+1, j)){ Board ngh2=new Board(this.board); int temp=ngh2.board[i][j]; ngh2.board[i][j]=ngh2.board[i+1][j]; ngh2.board[i+1][j]=temp; boardit.push(ngh2); } if(this.validate(i, j-1)){ Board ngh3=new Board(this.board); int temp=ngh3.board[i][j]; ngh3.board[i][j]=ngh3.board[i][j-1]; ngh3.board[i][j-1]=temp; boardit.push(ngh3); } if(this.validate(i, j+1)){ Board ngh4=new Board(this.board); int temp=ngh4.board[i][j]; ngh4.board[i][j]=ngh4.board[i][j+1]; ngh4.board[i][j+1]=temp; boardit.push(ngh4); } return boardit; }
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32720647
tagged with: iterator
upvote count: 0
answer count: 1
has answer: http://stackoverflow.com/a/21649971
has comment: http://stackoverflow.com/comment/32720591
score: -2
favorite count: 0
accepted answer: http://stackoverflow.com/a/21649971
downvote count: 2

http://stackoverflow.com/q/21612287
tagged with: factorization
has comment: http://stackoverflow.com/comment/32654966
has comment: http://stackoverflow.com/comment/32654816
has comment: http://stackoverflow.com/comment/32654770
downvote count: 0
score: 7
tagged with: java
has comment: http://stackoverflow.com/comment/32654705
possible better answer: http://stackoverflow.com/a/21613012
has comment: http://stackoverflow.com/comment/32655496
has body: Is there an algorithm to find ALL factorizations of an integer, preferably in Python/Java but any feedback is welcome. I have an algorithm to calculate the prime factors. For instance [2,2,5] are the prime factors of 20. def prime_factorization(n): primfac = [] d = 2 while d*d &lt;= n: while (n % d) == 0: primfac.append(d) n /= d d += 1 if n &gt; 1: primfac.append(n) return primfac I also have an algorithm to compute all factors (prime and non-prime) of an algorithm. For instance, the factors of 20 are [1, 2, 4, 5, 10, 20]. def factors(n): a, r = 1, [1] while a * a &lt; n: a += 1 if n % a: continue b, f = 1, [] while n % a == 0: n //= a b *= a f += [i * b for i in r] r += f if n &gt; 1: r += [i * n for i in r] return sorted(r) What I'm searching for is an algorithm to return all factorizations (not factors) of a given integer. For the integer 20, the algorithm would produce the following: [1,20] [2,10] [4,5] [2,2,5] Thanks!
has comment: http://stackoverflow.com/comment/32654837
type: Question
has comment: http://stackoverflow.com/comment/32654918
has comment: http://stackoverflow.com/comment/32661055
tagged with: algorithm
has comment: http://stackoverflow.com/comment/32665045
has comment: http://stackoverflow.com/comment/32654830
has title: Algorithm to find ALL factorizations of an integer
answer count: 3
has comment: http://stackoverflow.com/comment/32656752
upvote count: 7
has answer: http://stackoverflow.com/a/21613012
linked to: http://stackoverflow.com/q/8558292
has comment: http://stackoverflow.com/comment/32654789
has comment: http://stackoverflow.com/comment/32655599
favorite count: 0
linked to: http://stackoverflow.com/q/12421969
accepted answer: http://stackoverflow.com/a/21613018
has comment: http://stackoverflow.com/comment/32655771
has comment: http://stackoverflow.com/comment/32654937
tagged with: python
has comment: http://stackoverflow.com/comment/32655067
has comment: http://stackoverflow.com/comment/32655236
has answer: http://stackoverflow.com/a/21613018
has answer: http://stackoverflow.com/a/21613922
type: AnsweredQuestion

http://stackoverflow.com/q/21559552
score: 4
linked to: http://stackoverflow.com/q/21555968
tagged with: illegalargumentexception
answer count: 2
has title: JToolBar IllegalArgumentException when dropped back into GridBagLayout
has answer: http://stackoverflow.com/a/21569744
accepted answer: http://stackoverflow.com/a/21569744
tagged with: layout-manager
favorite count: 0
has answer: http://stackoverflow.com/a/21564005
has comment: http://stackoverflow.com/comment/32565635
upvote count: 4
type: AnsweredQuestion
downvote count: 0
tagged with: java
tagged with: swing
possible better answer: http://stackoverflow.com/a/21564005
type: Question
tagged with: gridbaglayout
has body: Why does this code throw an IllegalArgumentException when the tool bar is dragged off the GUI, then closed (to return it to the GUI)? I could understand why it might be improper to add a component with no constraint, but in this case, the initial addition of the toolbar to the panel (which uses GridBagLayout) without a constraint causes no such problem. Why should it occur the 2nd and subsequent times it is added? The code is adapted from this answer, but both codes show the same problem. Code import java.awt.*; import javax.swing.*; public class GridBagToolBarOddity { public static void main(String[] args) { Runnable r = new Runnable() { @Override public void run() { JPanel gui = new JPanel(new GridBagLayout()); JToolBar tb = new JToolBar(); tb.add(new JLabel("Drag me off, then drop me back!")); gui.add(tb); gui.setPreferredSize(new Dimension(300, 100)); gui.setBackground(Color.RED); JFrame f = new JFrame("Demo"); f.add(gui); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setLocationByPlatform(true); f.pack(); f.setVisible(true); } }; SwingUtilities.invokeLater(r); } } Exception Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: cannot add to layout: constraints must be a GridBagConstraint at java.awt.GridBagLayout.addLayoutComponent(GridBagLayout.java:702) at java.awt.Container.addImpl(Container.java:1120) at java.awt.Container.add(Container.java:966) at javax.swing.plaf.basic.BasicToolBarUI$FrameListener.windowClosing(BasicToolBarUI.java:1265) at java.awt.Window.processWindowEvent(Window.java:2051) at javax.swing.JDialog.processWindowEvent(JDialog.java:681) at java.awt.Window.processEvent(Window.java:2009) at java.awt.Component.dispatchEventImpl(Component.java:4861) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Window.dispatchEventImpl(Window.java:2719) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735) at java.awt.EventQueue.access$200(E…

http://stackoverflow.com/q/21526538
has comment: http://stackoverflow.com/comment/32502880
tagged with: android-asynctask
accepted answer: http://stackoverflow.com/a/21526626
tagged with: android
has comment: http://stackoverflow.com/comment/32502955
has comment: http://stackoverflow.com/comment/32512050
has comment: http://stackoverflow.com/comment/32507950
tagged with: java
type: Question
type: AnsweredQuestion
has title: error: unreported exception InterruptedException; must be caught or declared to be thrown (calling AsyncTask)
has answer: http://stackoverflow.com/a/21526695
has answer: http://stackoverflow.com/a/21526626
has comment: http://stackoverflow.com/comment/32502761
score: 0
answer count: 2
possible better answer: http://stackoverflow.com/a/21526695
has body: This is my class that extends AsyncTask public class JSONFunctions extends AsyncTask&lt;Void, Void, String&gt; { @Override protected String doInBackground(Void... urls) { String line = ""; HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet("http://appDev.milasevicius.com/server/homeresults.php"); try { HttpResponse response = httpclient.execute(httpget); if(response != null) { InputStream inputstream = response.getEntity().getContent(); line = convertStreamToString(inputstream); } else { line = "Unable to complete your request"; } } catch (ClientProtocolException e) { line = "Caught ClientProtocolException"; } catch (IOException e) { line = "Caught IOException"; } catch (Exception e) { line = "Caught Exception"; } return line; } protected void onProgressUpdate(Integer... progress) { } protected void onPostExecute(String result) { } } And this is my call: String output = new JSONFunctions().execute().get(); But compilator says that error: unreported exception InterruptedException; must be caught or declared to be thrown sorry for my noobish question, but how to fix that? And am I doing right call to get result?
has comment: http://stackoverflow.com/comment/32502838
linked to: http://stackoverflow.com/q/16752073

http://stackoverflow.com/q/21589231
upvote count: 2
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/24513397
score: 2
tagged with: java
tagged with: mrunit
tagged with: unit-testing
type: Question
tagged with: hadoop
has title: Hadoop unit test with mocked out Context
has body: I am trying to write an unit test for a hadoop job. The catch is that the mapper uses the Context argument passed on to it in order to determine which file is being read by it at that moment. It makes the following call: String inputFile = ((FileSplit) context.getInputSplit()).getPath().toString(); However, while writing a unit test for the mapper using MRUnit, I cant seem to find any way to mock out this Context object. Even MapDriver does not seem to have any option for setting a new Context object. Is there a way I can write a unit test for this mapper class?
downvote count: 0
answer count: 1
favorite count: 0

http://stackoverflow.com/a/21537423
score: 0
answers question: http://stackoverflow.com/q/21537324
type: Answer
has body: You should set setLongClickable(true); on list like: list.setLongClickable(true);

http://stackoverflow.com/comment/32561086
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21535857
has text: I added a second example that may look more like what you need.

http://stackoverflow.com/q/21661464
tagged with: java
tagged with: swing
type: Question
has title: JScrollPanes empty despite input arrays and DefaultListModels not being empty
has comment: http://stackoverflow.com/comment/32769162
score: 0
linked to: http://stackoverflow.com/q/7229226
tagged with: jscrollpane
answer count: 1
has body: Ok, so I'm trying to create two separate JScrollPanes that takes two lists; One list of users and one list of books and simply presents them. The problem is that right now, I have 19 items in my "bookData"-array and 15 in my "userData"-array, but both my JScrollPanes are as empty as my wallet. When checking my DefaultListModels with getSize(), I see that they too are 15 and 19 in size. I feel like I'm missing something crucial here. The million dollar question is what? !! - EDIT: Just noticed the ODDEST behaviour! My lists aren't empty as such - This is how the window looks on start; http://i60.tinypic.com/2nr0kyu.png BUT - and here's the twist! As soon as I change size on the window by dragging the corners - MY LISTS APPEAR! Thus, the error is not in the lists, but in the graphics, methinks. :3 http://i61.tinypic.com/2ah7ac3.png This is how my method looks; public void newLoan(){ StringBuilder sb = new StringBuilder(); StringBuilder string = new StringBuilder(); JLabel userLabel; JLabel bookLabel; JButton btnRegister; // Build a string of all users, separated with a "–" for (int i = 1; i &lt; Processes.userList.size()+1; i++) { sb.append(Processes.userList.get(i).getFirstname()+" "+Processes. userList.get(i).getSurname()+", "+Processes.userList. get(i).getPersonalID()+"–"); System.out.println(Processes.userList.get(i).getFirstname()+" "+Processes. userList.get(i).getSurname()+", "+Processes.userList. get(i).getPersonalID()); } // Build a string of all books, separated with a "–" for (int i = 1; i &lt; Processes.bookList.size()+1; i++) { if (Processes.bookList.get(i).getAvailable()- Processes.bookList.get(i).getOnLoan()!=0) { string.append(Processes.bookList.get(i).getAvailable()- Processes.bookList.get(i).getOnLoan()+" available - "+ Processes.bookList.get(i).getTitle()+" by "+Processes. bookList.get(i).getAuthor_firstname()+" "+Processes. bookList.get(i).getAuthor_surname()+" ("+Processes. bookList.get(i).getIsbn()+")–"); System.out.println(Processes.bookList.get(…
has answer: http://stackoverflow.com/a/21813600
linked to: http://stackoverflow.com/q/15073853
tagged with: jlist
has comment: http://stackoverflow.com/comment/32750558
accepted answer: http://stackoverflow.com/a/21813600
type: AnsweredQuestion

http://stackoverflow.com/q/21562442
has title: How to fetch data from multiple table query by hibernate?
answer count: 3
has body: I have a user management application that allocate each user a team and one or many access to different application. Now for the reporting page I am trying to fetch data from two table (UserInfo &amp; UserAppAccess) by Hibernate but I can't. Here are the tables : Table 1 (UserInfo): @Entity @Table(name = "user_info", uniqueConstraints = { @UniqueConstraint(columnNames = "username"), @UniqueConstraint(columnNames = "email") }) public class UserInfo implements java.io.Serializable { public enum UserStatus { active, inactive } public enum UserType { user, creator } private static final long serialVersionUID = 2650114334774359089L; @Id @Column(name = "id", unique = true, nullable = false, length = 100) private String id; @Column(name = "username", unique = true, nullable = false, length = 50) private String username; @Column(name = "password", nullable = false, length = 80) private String password; @Column(name = "status", nullable = false, length = 10) @Enumerated(EnumType.STRING) private UserStatus status; @Column(name = "type", nullable = false, length = 10) @Enumerated(EnumType.STRING) private UserType type; @Column(name = "phone", nullable = true, length = 30) private String phone; @Column(name = "email", nullable = true, length = 50) private String email; @Column(name = "first_name", nullable = true, length = 50) private String firstName; @Column(name = "last_name", nullable = true, length = 50) private String lastName; @Column(name = "login", nullable = true, length = 100) private long login; @Column(name = "alert", nullable= true, length=500) private String alert; @OneToOne @JoinColumn(name = "team_id") private Team team; } Table 2 (Team): @Entity @Table(name = "team", uniqueConstraints = { @UniqueConstraint(columnNames = "team_name"), @UniqueConstraint(columnNames = "team_code") }) public class Team implements java.io.Serializable { private static final long serialVersionUID = 7933770163144650730L; @Id @Column(name = "id", unique = true, nullable = false, lengt…
tagged with: java
tagged with: hibernate
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/21794310
linked to: http://stackoverflow.com/q/263850
tagged with: sql
downvote count: 0
has answer: http://stackoverflow.com/a/21809006
has answer: http://stackoverflow.com/a/21564116
favorite count: 0
has comment: http://stackoverflow.com/comment/32566718
type: Question
score: 3
has answer: http://stackoverflow.com/a/21564395
has comment: http://stackoverflow.com/comment/32566884
upvote count: 3

http://stackoverflow.com/comment/32599746
type: QuestionComment
comment on: http://stackoverflow.com/q/21580847
has text: Where is `rs` declared?
score: 0
type: Comment

http://stackoverflow.com/comment/32625169
type: QuestionComment
has text: @Gautham Code is fine its working but I am getting all the values as 0
score: 0
comment on: http://stackoverflow.com/q/21595078
type: Comment

http://stackoverflow.com/q/21536498
favorite count: 0
tagged with: jclouds
tagged with: cloudfiles
has title: Error creating BlobContext using jclouds in a Spring MVC application
type: AnsweredQuestion
score: 3
tagged with: guava
upvote count: 3
tagged with: java
has body: I have a Spring MVC 4.0.1 web application that needs to upload files to Rackspace Cloud Files. I am using Apache jClouds in order to do this. When trying to create the BlobStore using the following code: BlobStoreContext context = ContextBuilder.newBuilder("cloudfiles-us").credentials("username","password").buildView(BlobStoreContext.class); I get the following exception: com.google.inject.CreationException: Guice creation errors: 1) No implementation for com.google.common.base.Supplier&lt;java.lang.String&gt; annotated with @org.jclouds.openstack.swift.TemporaryUrlKey() was bound. while locating com.google.common.base.Supplier&lt;java.lang.String&gt; annotated with @org.jclouds.openstack.swift.TemporaryUrlKey() for parameter 4 at org.jclouds.openstack.swift.blobstore.SwiftBlobSigner.&lt;init&gt;(SwiftBlobSigner.java:88) at org.jclouds.cloudfiles.CloudFilesApiMetadata$CloudFilesTemporaryUrlExtensionModule.bindRequestSigner(CloudFilesApiMetadata.java:101) 2) No implementation for org.jclouds.openstack.swift.CommonSwiftClient was bound. while locating org.jclouds.openstack.swift.CommonSwiftClient for parameter 4 at org.jclouds.cloudfiles.blobstore.CloudFilesBlobStore.&lt;init&gt;(CloudFilesBlobStore.java:63) at org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule.configure(CloudFilesBlobStoreContextModule.java:64) 3) No implementation for org.jclouds.openstack.swift.CommonSwiftClient was bound. while locating org.jclouds.openstack.swift.CommonSwiftClient for parameter 0 at org.jclouds.openstack.swift.blobstore.strategy.internal.SequentialMultipartUploadStrategy.&lt;init&gt;(SequentialMultipartUploadStrategy.java:51) while locating com.google.inject.Provider&lt;org.jclouds.openstack.swift.blobstore.strategy.internal.MultipartUploadStrategy&gt; for parameter 14 at org.jclouds.cloudfiles.blobstore.CloudFilesBlobStore.&lt;init&gt;(CloudFilesBlobStore.java:63) at org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule.configure(CloudFil…
type: Question
has answer: http://stackoverflow.com/a/21538187
tagged with: guice
answer count: 1
downvote count: 0
accepted answer: http://stackoverflow.com/a/21538187

http://stackoverflow.com/q/21617648
has comment: http://stackoverflow.com/comment/32664725
upvote count: 3
tagged with: java
downvote count: 1
has comment: http://stackoverflow.com/comment/32664894
has answer: http://stackoverflow.com/a/21618186
has comment: http://stackoverflow.com/comment/70620102
has body: I'm trying to connect a Oracle database to my JAVA web project. and when creating the connection to the database using system user connection is successfully established. But when I execute a simple select * command in the connection it says Error code 942, SQL state 42000: ORA-00942: table or view does not exist. These sql queries work in sqldeveloper. No errors. I'm using oracle 10g thin client ojdbc6 driver and jdk 1.7 what can be the problem? Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist Error Code: 942 Call: SELECT USERID, FULLNAME, USERNAME, USER_CREDENTIALSID, USER_TYPEID FROM USERS Query: ReadAllQuery(referenceClass=Users sql="SELECT USERID, FULLNAME, USERNAME, USER_CREDENTIALSID, USER_TYPEID FROM USERS")
has comment: http://stackoverflow.com/comment/32664945
has title: Oracle DB table or view does not exist
has comment: http://stackoverflow.com/comment/32665069
type: Question
score: 2
tagged with: oracle-database
type: AnsweredQuestion
tagged with: sql
has comment: http://stackoverflow.com/comment/32665483
accepted answer: http://stackoverflow.com/a/21618186
favorite count: 0
has comment: http://stackoverflow.com/comment/32664994
answer count: 1

http://stackoverflow.com/comment/32542737
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21539579
has text: I'm not familiar with Google Speech API sorry. The 200 code show a success, but you probably need to set a breakpoint somewhere and observe the structure of the response.
score: 0

http://stackoverflow.com/comment/32731415
type: QuestionComment
has text: You can store multiple values for the same key by making your value a `Collection` of some sort. Although, I still don't understand why you think using a `Map` would be a reasonable approach.
comment on: http://stackoverflow.com/q/21656030
score: 0
type: Comment

http://stackoverflow.com/a/21667656
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/21667592
upvote count: 1
type: Answer
has body: Normally when I want to extract RGB from a BufferedImage I do something like this: File img_file = new File("../foo.png"); BufferedImage img = ImageIO.read(img_file); Color color = new Color(img.getRGB(i,j)); int red = color.getRed();

http://stackoverflow.com/a/21621365
downvote count: 0
has comment: http://stackoverflow.com/comment/32670620
type: Answer
has body: Try this: String line="Hello 12 hi 458 h20 Bye 8"; String line2 = line.replaceAll("\\D+",""); System.out.println(line2); Output: 12458208 You can add all values to list like: for(int i=0;i&lt;line2.length();i++) { specs.add(Integer.parseInt(line2.charAt(i)+"")); }
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/21621288

http://stackoverflow.com/comment/32680985
score: 0
type: Comment
has text: You need to create another variable then. Create a "k" variable. Do not use the i, because this one you are incrementing in the for loop.
comment on: http://stackoverflow.com/a/21627132
type: AnswerComment

http://stackoverflow.com/q/21640494
has comment: http://stackoverflow.com/comment/32704866
has comment: http://stackoverflow.com/comment/32704729
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21640662
downvote count: 1
type: Question
tagged with: java
score: -1
has body: I am trying to print out the column size and the row size of a two-dimensional array. My program compiles but it prints out: Welcome to DrJava. Working directory is C:\Users\mulk\Downloads &gt; run Lab4 Print out the rowsize: 4.0 Print out the columnsize: 4.0 &gt; Shouldn't the row size be 3.0? I am counting from zero. /* * Purpose: Prints the row and column averages */ class Lab4 { public static void main(String[] args) { int [][] scores = {{ 20, 18, 23, 20, 16 }, { 30, 20, 18, 21, 20 }, { 16, 19, 16, 53, 24 }, { 25, 24, 22, 24, 25 }}; outputArray(scores); } public static void outputArray(int[][] array) { double rowsize = 0.0; double columnsize= 0.0; for(double i=0.0;i &lt;= array.length;i++) { rowsize = array.length; } System.out.println("Print out the rowsize: " +rowsize); for (double j = 0; j &lt;=array[0].length; j++) { columnsize = array.length; } System.out.println("Print out the columnsize: " +columnsize); } }
upvote count: 0
tagged with: arrays
answer count: 1
favorite count: 0
has title: Why is the length of an array 1 greater than expected?

http://stackoverflow.com/comment/32701440
has text: Anyway this seems like a bad pattern, since it breaks the substitution principle (you cannot use an instance of `SubFoo` like an instance of `Foo`, even if they are in an `is an` relationship). Maybe (from the very high level description of the problem) should delegate the communication details to another different class and subclasses.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21638538
score: 0

http://stackoverflow.com/comment/32752288
type: Comment
has text: Write a test program that creates an Account object with an account ID of 1122, a balance of $20,000, and an annual interest rate of 4.5%. Use the withdraw method to withdraw $2,500, use the deposit method to deposit $3,000, and print the balance, the monthly interest, and the date when this account was created. sorry, here is the output requirement..
comment on: http://stackoverflow.com/q/21667793
score: 0
type: QuestionComment

http://stackoverflow.com/a/21646164
accepted answer of: http://stackoverflow.com/q/21646012
has comment: http://stackoverflow.com/comment/32719828
has comment: http://stackoverflow.com/comment/32713964
has comment: http://stackoverflow.com/comment/32725585
has comment: http://stackoverflow.com/comment/32714110
upvote count: 1
type: AcceptedAnswer
has body: Two things here. If you want your servlet to serve the root URL, you have to do two things 1 - you have to set your webapp context to root, like this 2 - then you have to set your servlet context to root too import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet("/") public class MyServlet extends HttpServlet { private static final long serialVersionUID = 1L; public MyServlet() { super(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.getWriter().write("OK"); response.getWriter().flush(); } } that's because the URL your servlet serve is like this http://yourserver:port/yourapp/yourservlet where yourapp is defined by #1 and yourservlet is defined by #2 like this
type: Answer
answers question: http://stackoverflow.com/q/21646012
downvote count: 0
score: 1

http://stackoverflow.com/q/21530642
tagged with: java
tagged with: date
possible better answer: http://stackoverflow.com/a/21530787
type: Question
has title: parse check doesn't work
has answer: http://stackoverflow.com/a/21530787
tagged with: string
has body: hi guys i am using this method to check if a string can be converted to a date or not but it seems that it's not working, this is the code i wrote, the user inputs a date in this format dd/MM/YYYY then this is what happens for checking it ... String date = JOptionPane.showInputDialog(frame,"Insert Date:"); if (date ==null) { return;} while (!(isValidDate(date))) { JOptionPane.showMessageDialog(frame, "Incorrect Date"); date = JOptionPane.showInputDialog(frame,"Insert Date:"); if (date ==null) { return;} } String[] parts = date.split("/"); int year = Integer.parseInt(parts[2]); int month = Integer.parseInt(parts[1]); int day = Integer.parseInt(parts[0]); ... and this is the method for check the date public boolean isValidDate(String dateString) { SimpleDateFormat df = new SimpleDateFormat("dd/MM/YYYY"); if (dateString.length() != "ddMMYYYY".length()) { return false; } try { df.parse(dateString); return true; } catch (ParseException e) { return false; } this seems not to work cause it always goes into the while block whatever i insert in the input, what is the problem with this code ? EDIT fixed the error on the condition if (dateString.length() != "ddMMYYYY".length()) now i got another problem it accepts values like 54/12/2030 which obvioiusly are not a date format
score: 0
has answer: http://stackoverflow.com/a/21530734
has answer: http://stackoverflow.com/a/21531691
answer count: 4
accepted answer: http://stackoverflow.com/a/21530721
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32510442
has answer: http://stackoverflow.com/a/21530721

http://stackoverflow.com/q/21663761
type: Question
has title: Eclipse plugin project and user library
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21663929
tagged with: java
tagged with: eclipse
has body: I tried to add my own User Library to my eclipse plugin project. But when I run the project, I get the java.lang.ClassNotFoundException. It only works, when I add single jars like mentioned in the accepted answer to this question: Adding jars to a Eclipse PlugIn How do I use custom User Libraries correctly in eclipse plugin projects?
linked to: http://stackoverflow.com/q/5744520
answer count: 2
tagged with: eclipse-plugin
score: 0
accepted answer: http://stackoverflow.com/a/21663959
possible better answer: http://stackoverflow.com/a/21663929
has answer: http://stackoverflow.com/a/21663959

http://stackoverflow.com/comment/32679755
comment on: http://stackoverflow.com/a/21626266
type: AnswerComment
score: 0
type: Comment
has text: People tend to down vote if it's something that can be found out by reading the documentation.

http://stackoverflow.com/comment/32767335
type: QuestionComment
has text: Do you have control over all the code? Or do you need to stick to given classes unchanged?
score: 0
comment on: http://stackoverflow.com/q/21676884
type: Comment

http://stackoverflow.com/comment/32574831
score: 0
has text: For better help sooner, post a [Minimal Complete Tested and Readable Example](http://stackoverflow.com/help/mcve) (MCTRE).
type: Comment
comment on: http://stackoverflow.com/q/21566396
type: QuestionComment

http://stackoverflow.com/q/21662439
has title: "A sharing violation occurred" - caused by not-closed stream?
answer count: 0
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32785038
tagged with: file
upvote count: 1
tagged with: inputstream
type: Question
has comment: http://stackoverflow.com/comment/32765485
has comment: http://stackoverflow.com/comment/32754170
has comment: http://stackoverflow.com/comment/32743484
has comment: http://stackoverflow.com/comment/32787227
downvote count: 0
has comment: http://stackoverflow.com/comment/32743994
favorite count: 0
has body: I'm developing a tool for Minecraft resource packs, basically it shows tree structure, previews of images and lets you edit some things. It works great on Linux, but Windows users keep reporting bugs like this: I'm having an error that won't let me save my new textures after editing them with paint: A sharing violation occurred while accessing C:\Users\Me\Appdata\Roaming.mcRPW\tmp\workdir\project_files\assets\minecraft\textures\blocks\repeater_off.png I use InputStream for reading the previews, and as it turns out, the method doesn't close it after it's done with it. I assumed garbage collector would take care of that, but maybe I was wrong. Anyway I have no idea what's going on, I can edit the images just fine on Linux. This reading is about the only way my Java application interacts with the file. Is my suspicion correct? If no, how to fix it?
type: UnansweredQuestion
tagged with: windows

http://stackoverflow.com/comment/32735070
has text: @nicktalbot Synchronizing a single array element may be of no use, but it certainly isn't impossible. You'll just need a lot of locks.
type: AnswerComment
comment on: http://stackoverflow.com/a/21657518
score: 0
type: Comment

http://stackoverflow.com/comment/32530862
score: 0
type: Comment
has text: Generally I tackle this type of question by doing it myself on graph paper, by hand a few times. This gives me ideas on how to best implement it. Can you give us some examples of good game boards?
type: QuestionComment
comment on: http://stackoverflow.com/q/21541681

http://stackoverflow.com/comment/32675231
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/21623787
has text: *"How i'm supposed to draw it without JfreeChart?"* Don't draw the graph. Simply replace it with an image in a `JLabel`. Getting an image is as simple as `BufferedImage bi = new BufferedImage(400,300,BufferedImage.TYPE_INT_RGB);`..
type: Comment

http://stackoverflow.com/a/21570213
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21569863
has comment: http://stackoverflow.com/comment/32581342
has body: The time difference you are experiencing because of the system resources and the time of allocation of them. The System.out.println("") always takes the same time but depending upon the system resources allocated at that time, the run-time differs.
has comment: http://stackoverflow.com/comment/32581299

http://stackoverflow.com/q/21586244
has body: I have downloaded ecllipse kepler - latest version from ecllipse website. I downloaded junit 4.10 jar file from sourseforge website (did not get a copy on github) After opening ecllipse i added my jar file as external jars (it was successfully added) I imported by saying "import static org.junit.Assert.*;" then for the testing method i wrote on the top @Test then followed by method definition Now ecllipse is poping me an error for @Test that -- "cannot convert from test to annotation" and it not even giving me an option to run my class as JUnit test. Am I missing any step somewhere? I am pasting my code here : package test; import static org.junit.Assert.*; public class Test { @Test public static void main(String[] args) { // TODO Auto-generated method stub assertEquals(0, voidMethod(), 0); } static int voidMethod() { return 0; } } Thanks in advance
tagged with: eclipse
downvote count: 1
tagged with: unit-testing
type: Question
upvote count: 0
has answer: http://stackoverflow.com/a/21586389
has comment: http://stackoverflow.com/comment/32609959
answer count: 2
has title: installation of JUnit on ecllipse
has answer: http://stackoverflow.com/a/21586647
tagged with: junit
favorite count: 0
score: -1
has comment: http://stackoverflow.com/comment/32609766
type: UnansweredQuestion
tagged with: java

http://stackoverflow.com/a/21619576
type: Answer
score: 0
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/21619305
has body: Either create a "libs" folder and put the "android-support-v4.jar" file else import the " android-support-v4.jar" to Android Private Libraries folder, and restart the IDE to take effect.

http://stackoverflow.com/q/21642862
tagged with: methods
type: Question
upvote count: 4
accepted answer: http://stackoverflow.com/a/21674680
tagged with: algorithm
tagged with: rectangles
tagged with: math
has comment: http://stackoverflow.com/comment/32793742
score: 4
has title: Snap to Edge Effect
answer count: 1
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/32757980
has answer: http://stackoverflow.com/a/21674680
has body: My final goal is to have a method, lets say: Rectangle snapRects(Rectangle rec1, Rectangle rec2); Imagine a Rectangle having info on position, size and angle. Dragging and dropping the ABDE rectangle close to the BCGF rectangle would call the method with ABDE as first argument and BCGF as second argument, and the resulting rectangle is a rectangle lined up with BCGF's edge. The vertices do not have to match (and preferrably won't so the snapping isn't so restrictive). I can only understand easily how to give the same angle, but the position change is quite confusing to me. Also, i believe even if i reached a solution it would be quite badly optimized (excessive resource cost), so I would appreciate guidance on this. (This has already been asked but no satisfatory answer was given and the question forgotten.) ------------------------------------------------------------------ Edit: It seems my explanation was insufficient so I will try to clarify my wishes: The following image shows the goal of the method in a nutshell: Forget about "closest rectangle", imagine there are just two rectangles. The lines inside the rectangles represent the direction they are facing (visual aid for the angle). There is a static rectangle, which is not to be moved and has an angle (0->360), and a rectangle (also with an angle) which I want to Snap to the closest edge of the static rectangle. By this, i mean, i want the least transformations possible for the "snap to edge" to happen. This brings many possible cases, depending on the rotation of the rectangles and their position relative to each other. The next image shows the static rectangle and how the position of the "To Snap" rectangle changes the snapping result: The final rotations might not be perfect since it was done by eye, but you get the point, it matters the relative position and also both angles. Now, in my point of view, which may be completely naive, I see this problem solved on two important and distinct steps on transformi…
has comment: http://stackoverflow.com/comment/32762210
has comment: http://stackoverflow.com/comment/32757892
has comment: http://stackoverflow.com/comment/32848629
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/q/21628614
score: 1
linked to: http://stackoverflow.com/q/17843521
favorite count: 0
has comment: http://stackoverflow.com/comment/32682752
has comment: http://stackoverflow.com/comment/32683237
accepted answer: http://stackoverflow.com/a/21675030
type: AnsweredQuestion
tagged with: onclick
upvote count: 2
tagged with: java
has comment: http://stackoverflow.com/comment/32741437
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/32687339
tagged with: href
has title: HtmlUnit a href click not working
has answer: http://stackoverflow.com/a/21675030
tagged with: htmlunit
has body: I have webform which I am filling with credentials. Then I want to click on login link. But it still gives me the same page in which I am clicking. HtmlForm loginForm = loginPage.getFormByName("Login1Form"); HtmlTextInput inLoginName = loginForm.getInputByName("loginId"); HtmlPasswordInput inPassword = loginForm.getInputByName("passwd"); HtmlTextInput inCaptcha = loginForm.getInputByName("checkcode"); inLoginName.setText(loginName); inPassword.setText(password); inCaptcha.setText(captcha.toUpperCase()); //HtmlElement loginLink =loginPage.getFirstByXPath("//a[@href=\"javascript:submitPB('9');\"]"); HtmlAnchor loginLink = loginPage.getAnchorByHref("javascript:submitPB('9');"); HtmlPage resultPage = resultPage = loginLink.click(); And resultPage even has same object id as loginPage has. I've tried webClient.wait methods and all I've found here. But nothing is working for me. Here is html link I need to click on &lt;a href="javascript:submitPB('9');"&gt; &lt;img src="images/pf/login-001.gif" width="43" height="21" border="0" alt=""&gt; &lt;/a&gt; Any ideas please? Thanks EDIT:// WebClient settings: mWebClient = new WebClient(BrowserVersion.FIREFOX_3_6); mWebClient.getOptions().setJavaScriptEnabled(true); mWebClient.getOptions().setRedirectEnabled(true); mWebClient.setAjaxController(new NicelyResynchronizingAjaxController()); mWebClient.getCookieManager().setCookiesEnabled(true);
answer count: 1

http://stackoverflow.com/a/26021969
has body: For those who are still looking for an answer to this question as I was, Please check your hibernate config xml and make sure your hibernate entity is declared there
score: 21
answers question: http://stackoverflow.com/q/21526867
has comment: http://stackoverflow.com/comment/84070793
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/66528500
has comment: http://stackoverflow.com/comment/84567738
upvote count: 21
accepted answer of: http://stackoverflow.com/q/21526867

http://stackoverflow.com/q/21557578
has comment: http://stackoverflow.com/comment/32559321
has comment: http://stackoverflow.com/comment/32557691
tagged with: spring
tagged with: spring-mvc
tagged with: java
has answer: http://stackoverflow.com/a/21560210
type: Question
tagged with: jakarta-ee
has comment: http://stackoverflow.com/comment/32557931
has comment: http://stackoverflow.com/comment/32557951
has comment: http://stackoverflow.com/comment/32557907
score: 0
answer count: 1
has title: SPRING 3.0 MVC 2 page 1 controller
tagged with: spring-security
has body: I just want to have 2 functions in JAVA Spring 3.0 MVC like page1.htm and page2.htm and just 1 controller, kinda is in CodeIgniter, i don't know why is so hard ... This is what i did till now /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package controllers; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.validation.BindException; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.SimpleFormController; // Import models import models.LoginModel; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; /** * * @author Candy */ @RequestMapping("/app") public class LoginController extends SimpleFormController { public LoginController() { //Initialize controller properties here or //in the Web Application Context setCommandClass(models.Employee.class); setCommandName("Employee"); //setSuccessView("pages/login/login_form_view"); //setFormView("pages/login/login_execute_view"); } // On form load @Override protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception { LoginModel loginModel = new LoginModel(request); if(!loginModel.isLogged()) { ModelAndView mv = new ModelAndView("pages/login/login_form_view"); // mv.addObject("chestie",loginModel.isLogged()); return mv; } else { return new ModelAndView("redirect:/dashboard.htm"); } } @Override protected void doSubmitAction(Object command) throws Exception { throw new UnsupportedOperationException("Not yet implemented"); } //Use onSubmit instead of doSubmitAction //when you need access to the Request, Response, or BindException objects @Override protected ModelAndView onSubmit( HttpServletRequest request, HttpServletRespon…
type: UnansweredQuestion

http://stackoverflow.com/comment/32635908
type: Comment
type: QuestionComment
has text: yes, because on phone keyboard under 5 you have "JKL" letters.
comment on: http://stackoverflow.com/q/21601657
score: 0

http://stackoverflow.com/q/21592698
has answer: http://stackoverflow.com/a/21604533
tagged with: java
upvote count: 1
type: Question
tagged with: jruby
answer count: 1
downvote count: 0
score: 1
favorite count: 0
tagged with: ruby
type: UnansweredQuestion
has body: I'm new to Ruby &amp; Jruby . I want to test some stuffs of jruby in java code Here is my code : import java.util.ArrayList; import java.util.HashMap; import org.jruby.embed.LocalVariableBehavior; import org.jruby.embed.ScriptingContainer; public class Test { public static void main(String[] args){ ScriptingContainer container = new ScriptingContainer(LocalVariableBehavior.PERSISTENT); Test t = new Test(); LogStatBean bean = t.new LogStatBean(); container.setHomeDirectory("classpath:/META-INF/jruby.home"); container.put("bean", bean); container.runScriptlet("arr = [1, 2, 3, 4, 5, 6]"); container.runScriptlet("puts arr"); container.runScriptlet("bean.setOutput(arr) "); System.out.println(bean.getOutput()); } public class LogStatBean { public ArrayList&lt;HashMap&lt;String, Object&gt;&gt; getOutput() { return output; } public void setOutput(ArrayList&lt;HashMap&lt;String, Object&gt;&gt; output) { this.output = output; } public ArrayList&lt;HashMap&lt;String, Object&gt;&gt; output; } } I cannot set the java local variable with type ArrayList in jruby ,it raise an error TypeError: cannot convert instance of class org.jruby.RubyArray to class java.util.ArrayList (root) at &lt;script&gt;:1 What i have to do ?
has title: Convert instance of class org.jruby.RubyArray to class java.util.ArrayList

http://stackoverflow.com/q/21547877
has body: what is wrong with this code?? int amount= (int) amountSpnr.getValue(); // 1 float total = (float) productData[3]*amount; // 2 total2pay+=total; totalFld.setText(total2pay+""); model.addRow(new Object[]{productData[0], productData[1],productData[2],productData[3], amount, total});` says : inconvertible types (for the 1st line)- required int found Object (for the 2nd line)- required float found Object What can i do?
has title: java error:inconvertible types required int
has answer: http://stackoverflow.com/a/21547987
has comment: http://stackoverflow.com/comment/32540581
accepted answer: http://stackoverflow.com/a/21547997
type: AnsweredQuestion
tagged with: netbeans
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/21547997
score: 0
answer count: 2
possible better answer: http://stackoverflow.com/a/21547987

http://stackoverflow.com/comment/32680114
type: Comment
has text: @BoristheSpider , can you edit the code in an efficient manner ?
type: QuestionComment
comment on: http://stackoverflow.com/q/21626979
score: 0

http://stackoverflow.com/comment/92621386
comment on: http://stackoverflow.com/a/21620436
type: AnswerComment
score: 0
type: Comment
has text: When I'm tried above solution,I'm getting below error Android Support Jar not found:] E:\eclipse-java-kepler-SR2-win32-x86_64\eclipse\v4\android-support-v4.jar

http://stackoverflow.com/q/21584762
has comment: http://stackoverflow.com/comment/32606818
score: 0
has body: So I'm pretty new to Java, and I'm trying to write a for loop to go through all of the pixels in an image, but for some unknown reason, the for loop never increments. When I try to run the code, it prints out the height and the width of the image, that are assigned to the variables "height" and "width" respectively, and then enters the for loops but only prints out 0, and 0 before finishing running. public class ImageProcessor { public static Pic image; public static Pic modImage; public static int width; public static int height; public static int average; public static Pixel modPixel; public static void main(String[] args) { Pic image = new Pic(args[0]); int width = image.getWidth(); int height = image.getHeight(); System.out.println(width); System.out.println(height); greyscale(); } public static Pic greyscale() { for (int w = 0; w &lt;= width; w++) { for (int h = 0 ; h &lt;= height; h++) { System.out.println(w); System.out.println(h); } } return image; } }
has title: For loop isn't incrementing Java
has answer: http://stackoverflow.com/a/21584871
has answer: http://stackoverflow.com/a/21584891
possible better answer: http://stackoverflow.com/a/21584798
has answer: http://stackoverflow.com/a/21584798
answer count: 4
type: AnsweredQuestion
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21584961
accepted answer: http://stackoverflow.com/a/21584961

http://stackoverflow.com/q/21541206
type: Question
answer count: 2
has body: I don't know why the lines won't print in the while loop. I can't exit either. Please help. The program runs but nothing inside the while loop will print. public class RomanNumeralHelper { /** * (Insert a brief description that describes the purpose of this method) * * @param args */ public static void main(String[] args) { Scanner in = new Scanner(System.in); String myRoman; String upperRoman; System.out.print("Enter a roman numeral [Q | q to quit]: "); myRoman = in.next(); upperRoman = myRoman.toUpperCase(); while (upperRoman != "Q") { if (upperRoman == "I") { System.out.println("&gt;&gt; 1"); } else if (upperRoman == "II") { System.out.println("&gt;&gt; 2"); } else if (upperRoman == "III") { System.out.println("&gt;&gt; 3"); } else if (upperRoman == "IV") { System.out.println("&gt;&gt; 4"); } else if (upperRoman == "V") { System.out.println("&gt;&gt; 5"); } System.out.print("Enter a roman numeral [Q | q to quit]: "); myRoman = in.next(); upperRoman = myRoman.toUpperCase(); } System.out.println("Good Bye!"); // (5) Closes the in object to avoid a resource leak. in.close(); } }
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/32529861
has answer: http://stackoverflow.com/a/21541218
possible better answer: http://stackoverflow.com/a/21541285
accepted answer: http://stackoverflow.com/a/21541218
has answer: http://stackoverflow.com/a/21541285
tagged with: while-loop
has comment: http://stackoverflow.com/comment/32529783
linked to: http://stackoverflow.com/q/513832
type: AnsweredQuestion
has title: Lines won't print inside while loop
duplicate of: http://stackoverflow.com/q/513832

http://stackoverflow.com/a/21626703
score: 3
answers question: http://stackoverflow.com/q/21626543
upvote count: 3
type: Answer
has body: If the GUI class gets big and unwieldy it is practical to divide it into several classes. One way to do that would be to create one class for each "page". Let the HomePage class have instance variables that hold references to the "page" objects.
has comment: http://stackoverflow.com/comment/32681227
downvote count: 0

http://stackoverflow.com/q/21629910
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/32685415
type: Question
accepted answer: http://stackoverflow.com/a/21630339
score: 0
answer count: 1
has title: regex to split string with option stubstrings, into three
has body: I have asked a few regex related questions on here, and am learning a lot from the answers, but every now and then, I hit something that just stumps me. This is one of those times! I have a load of strings (all of which are single line), that I want to break up into three parts. However, some of the parts are optional. To simplify this example, I will use people's names. Lets assume I have the following names Mr Homer Simpson Mrs Marge Simpson Esq Mr Homer Simpson Junior Esq Bart Simpson Lisa Simpson Esq Maggie Simpson Junior Esq Using a replace function , I would want to separate these into Prefix, Name and Suffix. With the list above, I would expect to see "Mr" "Homer Simpson" "" "Mrs" "Marge Simpson" "Esq" "Mr" "Homer Simpson" "Junior Esq" "" "Bart Simpson" "" "" "Lisa Simpson" "Esq" "" "Maggie Simpson" "Junior Esq" The closest I can get is the following, which obviously is way off ((Mr|Mrs)\s)?(.*?)((Senior|Junior)?(?:\sEsq)?) Can anyone assist? Thanks
has answer: http://stackoverflow.com/a/21630339
tagged with: regex

http://stackoverflow.com/comment/33027342
type: Comment
has text: This error was happened , when ever the Big table(it has more than 20million records) get used in a query. so currently we optimized the query, in such a way that to process the record little faster, by introducing the temp tables intermediately. now a days we are not getting this error
type: AnswerComment
comment on: http://stackoverflow.com/a/21570869
score: 0

http://stackoverflow.com/a/21523522
has comment: http://stackoverflow.com/comment/32499337
answers question: http://stackoverflow.com/q/21521309
has body: There is nothing wrong with your code, but I suspect that you're running it from behind a proxy or firewall that blocks outgoing DNS. When you ask for dns:/www.google.com you're essentially asking your local DHCP-supplied resolver for the IP of www.google.com - just as when typing the address in the browser address line. However, when using dns://8.8.8.8/www.google.com you're asking to use Google DNS to resolve google.com which requires that your proxy/firewall allows outgoing TCP/UDP port 53 traffic, which is usually not the case in corporate environments... Cheers,
upvote count: 2
type: AcceptedAnswer
type: Answer
score: 2
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21521309

http://stackoverflow.com/a/21630392
type: Answer
has comment: http://stackoverflow.com/comment/32686465
has comment: http://stackoverflow.com/comment/32686839
answers question: http://stackoverflow.com/q/21630363
has body: Your schemaLocation value should be of the form namespace-name schema-location [namespace-name schema-location] You're missing http://www.springframework.org/schema/context before http://www.springframework.org/schema/context/spring-context-3.1.xsd It should therefore be xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"&gt; Note that I've changed the util schema to version 3.1. Don't mix and match. Use all the same versions.
has comment: http://stackoverflow.com/comment/32686748
score: 15
upvote count: 15
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32687170
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21630363
has comment: http://stackoverflow.com/comment/32687141

http://stackoverflow.com/q/21608566
tagged with: jakarta-ee
has comment: http://stackoverflow.com/comment/32650686
has title: ExtJS /Java/Eclipse project
tagged with: extjs
has answer: http://stackoverflow.com/a/29652972
tagged with: extjs4
accepted answer: http://stackoverflow.com/a/21659971
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32705216
possible better answer: http://stackoverflow.com/a/29652972
type: Question
has body: I have to build small app using Eclipse JEE framework and ExtJS for the frontend part. I downloaded Eclipse Kepler for JEE developers. All went good until I imported extjs into my project. Eclipse started to use CPU by 100% which gets the computer stuck. What eclipse is doing is building workspace and it needs 100% of CPU and lot of time to process 14000 files in ExtJS framework. Ok I turned off all validators but still the PC is stuck only on javaw.exe process. I also turned of "Build automatically" option. Still 100% CPU I tried to add only necessary files from ExtJS but the GUI I am getting is ruined, so that means only ext-all-debug.js file and ext-all.css is not enough to create your application. What do I do? Or should I state this question like this: Which files/libraries form the extjs-gpl.zip should I add to my project so that I see all GUI parts rendered properly? I am using remote computer which has 1.5 GB RAM so I cannot change it. Eclipse JEE version eats up to 600 - 700 MB
answer count: 2
has comment: http://stackoverflow.com/comment/32656314
score: 0
tagged with: java
has answer: http://stackoverflow.com/a/21659971
tagged with: eclipse
has comment: http://stackoverflow.com/comment/32659917

http://stackoverflow.com/comment/32710752
type: QuestionComment
score: 2
comment on: http://stackoverflow.com/q/21644277
has text: Not really, nor any other number of decimal digits. It has 23(+1) *bits* of precision. The decimal representation is highly misleading.
type: Comment

http://stackoverflow.com/comment/32575934
comment on: http://stackoverflow.com/q/21567051
type: QuestionComment
type: Comment
has text: No, I've searched through my context xml files and also checked by commenting out the progressWorker1, progressWorker2 beans from my applicationContext.xml file and the application starts up without error. The ProgressWorkerFactory bean is a property of one other bean, a ProgressService bean. It's the ProgressService bean which calls the ProgressWorkerFactory.getProgressWorker() method. These are also new beans and pieces of code I've added to the application this morning.
score: 0

java-8
tags question: http://stackoverflow.com/q/21612555
tags question: http://stackoverflow.com/q/21650155
tags question: http://stackoverflow.com/q/21653477
tags question: http://stackoverflow.com/q/21586845
tags question: http://stackoverflow.com/q/21646683
tags question: http://stackoverflow.com/q/21640002
tags question: http://stackoverflow.com/q/21555936
tags question: http://stackoverflow.com/q/21606748
tag name: java-8
tags question: http://stackoverflow.com/q/21553270
tags question: http://stackoverflow.com/q/21522341
type: Tag
tags question: http://stackoverflow.com/q/21520380

http://stackoverflow.com/q/21523883
score: 3
has comment: http://stackoverflow.com/comment/32499162
has answer: http://stackoverflow.com/a/21524246
tagged with: java
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/130646060
downvote count: 0
tagged with: event-handling
linked to: http://stackoverflow.com/q/408820
tagged with: awt
favorite count: 0
has title: What is sun.awt.windows.WToolkit?
upvote count: 3
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21523953
has body: I have the following piece of code import java.awt.*; import java.awt.event.*; import java.lang.reflect.*; import javax.swing.*; class QueueTest { static int i=0; public static void main(String[] args) throws InterruptedException, InvocationTargetException { EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); eventQueue.push(new MyEventQueue()); Frame f=new Frame(); f.setSize(400,400); //f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLocation(150,150); f.setLayout(new FlowLayout()); f.setVisible(true); Button b=new Button("button"); //b.setEnabled(false); f.add(b); /* b.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae) { System.out.println("button is clicked"); } }); */ } private static class MyEventQueue extends EventQueue { public void postEvent(AWTEvent theEvent) { // System.out.println("Event Posted"); System.out.println("The source of event is "+theEvent.getSource()); super.postEvent(theEvent); } protected void dispatchEvent(AWTEvent event) { System.out.println("The source of event ("+(i++)+") is "+event.getSource()); super.dispatchEvent(event); } } } In the output i could sometimes see The source of event is (78) sun.awt.windows.WToolkit@77ef83 when I think i have only two sources, the java.awt.Button and the java.awt.Frame. Also when I am pressing the mouse, I could see two events being generated for which one is sun.awt.windows.WToolkit is the source and for the other is Button (when I clicked on button). My questions are what is sun.awt.windows.WToolkit? why am I able to see two events on a single mouse press?

http://stackoverflow.com/q/21572656
type: Question
answer count: 2
tagged with: jpa
tagged with: websphere-8
upvote count: 2
has body: i have web application. fetch from table working well but when I'm trying to update the same table, by using JPA i got exception message: javax.persistence.TransactionRequiredException: No active transaction for PuId =.... i am using transaction-type="JTA"(container manage) and transaction.required. it seemed that ** I have an example of an update from MDB using JTA transaction type and there it's works well ** this is my persistence.xml <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> org.apache.openjpa.persistence.PersistenceProviderImpl comp/env/jdbc/sys-SRV com.sys.admin.jpa.sysAdminAppl com.sys.admin.jpa.sysAdminTable com.sys.admin.jpa.sysAdminTablePK com.sys.admin.jpa.Dbsys0001 <exclude-unlisted-classes>true</exclude-unlisted-classes> <property name="openjpa.jdbc.DBDictionary" value="sqlserver" /> <property name="Multithreaded" value="true" /> <property name="openjpa.jdbc.Schema" value="dbsys" /> <property name="openjpa.TransactionMode" value="managed"/> <property name="openjpa.ConnectionFactoryMode" value="managed"/> org.apache.openjpa.persistence.PersistenceProviderImpl comp/env/jdbc/jpa com.sys.admin.jpa.sysAdminAppl com.sys.admin.jpa.sysAdminTable com.sys.admin.jpa.sysAdminTablePK com.sys.admin.jpa.dbsys0001 <exclude-unlisted-classes>true</exclude-unlisted-classes> <property name="openjpa.jdbc.DBDictionary" value="sqlserver" /> <property name="Multithreaded" value="true" /> <property name="openjpa.jdbc.Schema" value="dbsys" /> my servlet package com.sys.admin.servlet; import java.io.IOException; import java.io.StringWriter; import java.io.Writer; import java.util.Enumeration; import javax.ejb.TransactionAttribute; import javax.ejb.TransactionAttributeType; import javax.ejb.TransactionManagement; import javax.ejb.Transactio…
favorite count: 0
has title: javax.persistence.TransactionRequiredException: No active transaction for PuId=
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21720770
score: 2
has answer: http://stackoverflow.com/a/21588604
downvote count: 0
tagged with: java
tagged with: web-applications

http://stackoverflow.com/comment/32745644
type: AnswerComment
type: Comment
has text: No, that should work. I tried a very similar query on one of my MySQL databases and it worked. Now, the result is either 1 (exists) or 0 (non-exists). You might want to try running your query directly against the database - by using the mysql command line.
comment on: http://stackoverflow.com/a/21654145
score: 0

http://stackoverflow.com/comment/32664477
comment on: http://stackoverflow.com/a/21617499
type: Comment
has text: Calling `f.pack()` in the end of the constructor also worked.
score: 0
type: AnswerComment

http://stackoverflow.com/q/21659079
answer count: 4
has body: My snippet code are as follow: FileOutputStream fos = new FileOutputStream("newFile.txt"); OutputStreamWriter out = new OutputStreamWriter(fos, "UTF-8"); Writer w = out; for(String str : arrayName) { w.write("sample"); //I wish to insert new line here } w.close(); Is there other way than to write a blank space manually? i.e. w.write("\n"); EDITED. Sorry for causing some misunderstanding regarding if I am looking for new line or blank space.
has title: I am using Writer class in Java for UTF8 encoding output. How do I insert new line when writing?
has answer: http://stackoverflow.com/a/21659126
tagged with: line
type: AnsweredQuestion
tagged with: java
type: Question
score: 0
has answer: http://stackoverflow.com/a/21659139
has answer: http://stackoverflow.com/a/21659092
has answer: http://stackoverflow.com/a/21659121
tagged with: writer
accepted answer: http://stackoverflow.com/a/21659121
possible better answer: http://stackoverflow.com/a/21659092
tagged with: utf-8

http://stackoverflow.com/comment/32728856
has text: Its for an array assignment.
type: Comment
comment on: http://stackoverflow.com/a/21654230
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32621035
type: Comment
comment on: http://stackoverflow.com/a/21592797
has text: @ajb After I posted OP edited his question. I will edit my answer accordingly.
score: 0
type: AnswerComment

http://stackoverflow.com/q/21629636
has body: I have this public WSDL: http://ihexds.nist.gov:12080/tf6/services/xdsregistryb?wsdl It's the WSDL for a public XDS Registry service and I want to make calls to it from my application. When I run "wsdl2java" on it with Apache CXF 2.7.8 I get the following exception WSIBP Validator found &lt;{http://serviceclasses.ws.registry.nist.gov}xdsregistrybHttpBinding&gt; is NOT a SOAP binding WSDLToJava Error: java.lang.ClassCastException: javax.xml.namespace.QName cannot be cast to java.lang.String org.apache.cxf.tools.common.ToolException: java.lang.ClassCastException: javax.xml.namespace.QName cannot be cast to java.lang.String at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:420) at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103) at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113) at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86) at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:184) Caused by: java.lang.ClassCastException: javax.xml.namespace.QName cannot be cast to java.lang.String at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.annotator.WSActionAnnotator.getAction(WSActionAnnotator.java:56) at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.annotator.WSActionAnnotator.annotate(WSActionAnnotator.java:83) at org.apache.cxf.tools.common.model.JavaMethod.annotate(JavaMethod.java:368) at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.OperationProcessor.process(OperationProcessor.java:68) at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.PortTypeProcessor.process(PortTypeProcessor.java:149) at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.WSDLToJavaProcessor.wsdlDefinitionToJavaModel(WSDLToJavaProcessor.java:82) at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.WSDLToJavaProcessor.process(WSDLToJavaProcessor.java:59) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContai…
downvote count: 0
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32685204
answer count: 0
tagged with: cxf
score: 1
tagged with: java
upvote count: 1
tagged with: wsdl2java
type: Question
has title: Apache CXF cast exception on WSDL
has comment: http://stackoverflow.com/comment/32684969
has comment: http://stackoverflow.com/comment/32684894

http://stackoverflow.com/q/21516069
has comment: http://stackoverflow.com/comment/32484911
has body: Here's the algorithm: boolean findTripleA(int[] anArray) { if (anArray.length &lt;= 2) { return false; } for (int i=0; i &lt; anArray.length; i++) { // check if anArray[i] occurs at least three times // by counting how often it occurs in anArray int count = 0; for (int j = 0; j &lt; anArray.length; j++) { if (anArray[i] == anArray[j]) { count++; } } if (count &gt;= 3) { return true; } } return false; } The algorithm is designed to determine whether an array contains at least one number that occurs three times or more in the array. My job is to figure out what would be the worst-case for this array, and its time complexity. My thinking is that the worst case would be if the algorithm had two occurrences of every entry (with the extra entry being unique if the array has an odd number of elements). In this case, the if statement within for (int j = 0; j &lt; anArray.length; j++) is always violated twice for each pass through the array, forcing the computation to be performed twice, but the algorithm doesn't actually terminate until it has checked every element. I was thinking that this would have a time complexity of O(n^2). Can anyone provide any insight into this one? Because I have a nagging suspicion that I'm incorrect, and if I am I'd like to figure out the correct answer and why it's correct.
tagged with: big-o
has comment: http://stackoverflow.com/comment/32485018
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32485011
has title: What would be the worst case time complexity for this algorithm?
tagged with: algorithm
has answer: http://stackoverflow.com/a/21516249
tagged with: java
has comment: http://stackoverflow.com/comment/32484963
possible better answer: http://stackoverflow.com/a/21516135
has comment: http://stackoverflow.com/comment/32485001
has answer: http://stackoverflow.com/a/21516135
type: Question
answer count: 2
tagged with: time-complexity
tagged with: arrays
accepted answer: http://stackoverflow.com/a/21516249
score: 0
has comment: http://stackoverflow.com/comment/32485028

http://stackoverflow.com/a/28535378
has body: Just type save instead of saveOrUpdate in your hibernate query. This is due to previous logs your class is generating some other ID which was previously stored in your table. So hibernate tries to update with same ID and it finds no row with that ID so it gives a staleStateException.
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/21625059
upvote count: 1

http://stackoverflow.com/comment/32688590
type: Comment
has text: Glad you figured it out :) and thanks for the feedback on Spring Security!
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21630593

http://stackoverflow.com/q/21671530
downvote count: 0
has title: Does it matter (performance-wise) where a static function is defined?
favorite count: 0
type: Question
has body: Say I defined a standalone static function. No need to access any outside variables -- completely self-contained. Are there any performance penalties/benefits to consider when defining it, or should I just stick it wherever it makes the most sense? (This is by far the function that takes up the most CPU time, so I don't want to be inadvertently hurting myself.)
possible better answer: http://stackoverflow.com/a/21671578
upvote count: 2
tagged with: java
has answer: http://stackoverflow.com/a/21671578
answer count: 3
has answer: http://stackoverflow.com/a/21671562
has answer: http://stackoverflow.com/a/21671576
has comment: http://stackoverflow.com/comment/32758089
tagged with: static-methods
score: 2
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21671562

http://stackoverflow.com/comment/32711757
comment on: http://stackoverflow.com/a/21644769
type: Comment
has text: @user3085390: Yes, but you have to test by yourself. BTW, In the issues page, there is detail description of the bug.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32878051
comment on: http://stackoverflow.com/q/21637912
score: 0
type: Comment
type: QuestionComment
has text: When I´ve been preparing a small project to share it... it worked! When this has occurred, I´ve been looking for an explanation. I tested the new code in my main project and it worked too! I didn´t understand anything. Then I reviewed my code one more time and I saw the difference. The code that didn´t work was accessing by using this URI ws://192.168.0.201:8080/chat/chat but the demo project that worked well used the localhost version: ws://localhost:8080/chat/chat. The mistake was on the use of the IP in place of localhost or 127.0.0.1. ¿Is that a normal behavior?

http://stackoverflow.com/a/21516285
has comment: http://stackoverflow.com/comment/32526469
type: Answer
answers question: http://stackoverflow.com/q/21516214
has comment: http://stackoverflow.com/comment/32485762
has comment: http://stackoverflow.com/comment/32525966
score: 3
upvote count: 3
has body: I do not know how to accomplish this.. usage of prepared components in GUI builder can be a disadvantage you can to start to reading Oracle tutorial Using Swing Components Currently I am using jFrames for pages and do not know how to automatically create new jFrames from within a jFrame. use CardLayout instead of multiple JFrames
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21516214

http://stackoverflow.com/comment/32551361
type: Comment
type: QuestionComment
has text: May be a better question for [code review SE](http://codereview.stackexchange.com/)
comment on: http://stackoverflow.com/q/21554232
score: 0

http://stackoverflow.com/a/21555443
has comment: http://stackoverflow.com/comment/32554051
answers question: http://stackoverflow.com/q/21555393
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21555393
type: Answer
has comment: http://stackoverflow.com/comment/32554215
score: 3
has comment: http://stackoverflow.com/comment/32554264
upvote count: 3
has body: The array size is 5 but at below loop for max value of i you are incrementing it by 1, and so trying to access array[5] (array[4+1]), which causes your ArrayIndexOutOfBoundsException. for(int i=0;i &lt; 5;i++) { if(array[i] &gt; array[i+1]) --------------------------------------^ maxt = array[i]; }
has comment: http://stackoverflow.com/comment/32554526

http://stackoverflow.com/comment/32529095
type: QuestionComment
has text: Don't keep creating `BufferedReaders` inside the loop. Do it once. You may be losing buffered data.
comment on: http://stackoverflow.com/q/21540597
score: 1
type: Comment

http://stackoverflow.com/comment/32616890
type: Comment
type: QuestionComment
has text: @CQM - I do iPhone development. "Terribly memory constrained" does not describe an iPhone or Android device.
score: 0
comment on: http://stackoverflow.com/q/21589971

http://stackoverflow.com/a/21562505
downvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/32567317
answers question: http://stackoverflow.com/q/21562432
has body: It's called short-circuiting and it's perfectly fine to do that. if (person != null &amp;&amp; person.getAge &gt; 20) {...} Always make sure you do a null check and &amp;&amp; will move to check the next condition only if the previous one is true. In this case person.getAge &gt; 20 is checked only if person != null is true. Also check this SO question: Java logical operator short-circuiting For further reading: Avoiding “!= null” statements in Java?
score: 0
upvote count: 1
has comment: http://stackoverflow.com/comment/32572181

http://stackoverflow.com/comment/32590211
type: Comment
comment on: http://stackoverflow.com/q/21575011
has text: @RohitJain A quick search suggests you can hack it together from the date extraction functions. http://whyjava.wordpress.com/2010/04/18/hql-which-gives-no-of-hours-bw-two-timestamps/, http://stackoverflow.com/q/639522/398670 . Ugly, but workable.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/32488060
score: 0
has text: @ android developer: I followed an old guide long ago, so I'm not sure why I did what I did. I am not that experienced with Java or Android development, so could you please explain how I would do the changes you suggested? Thanks so much for your reply
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21517681

http://stackoverflow.com/comment/32611317
type: AnswerComment
comment on: http://stackoverflow.com/a/21586945
has text: Basically when the button in Panel.java is pressed / clicked; I would like it to change screen to the Panel2.
type: Comment
score: 0

http://stackoverflow.com/a/21642594
accepted answer of: http://stackoverflow.com/q/21642115
upvote count: 9
answers question: http://stackoverflow.com/q/21642115
has comment: http://stackoverflow.com/comment/32714509
type: AcceptedAnswer
downvote count: 0
type: Answer
has body: Clojure uses a Java library called ASM to generate bytecode. A fork of a part of the lib is embedded into the clojure project here: https://github.com/clojure/clojure/tree/master/src/jvm/clojure/asm
score: 9

http://stackoverflow.com/q/21634785
accepted answer: http://stackoverflow.com/a/24661334
possible better answer: http://stackoverflow.com/a/21635258
type: Question
score: 3
tagged with: java
tagged with: comparison
has answer: http://stackoverflow.com/a/21636126
linked to: http://stackoverflow.com/q/1725993
answer count: 3
downvote count: 0
has title: Compare two documents where both parent elements and child elements are ordered diffently
linked to: http://stackoverflow.com/q/141993
has answer: http://stackoverflow.com/a/24661334
favorite count: 0
has body: I'm trying to unit test some methods that produce xml. I have an expected xml string and the result string and after googling and searching stack overflow, I found XMLUnit. However it doesn't seem to handle one particular case where repeating elements in different orders contain elements that are in different orders. For example: Expected XML: David Rosalyn Alexander Linda Actual XML: Linda Alexander Rosalyn David You can see the parent node repeats and it's contents can be in any order. These two xml pieces should be equivalent but nothing from the stackoverflow examples I've seen does the trick with this. (Best way to compare 2 XML documents in Java) (How can I compare two similar XML files in XMLUnit) I've resorted to creating Documents from the xml strings, stepping through each expected parent node and then comparing it to each actual parent node to see if one of them is equivalent. It seems to me like a lot of reinventing of the wheel for something that should be a relatively common comparison. XMLUnit seems to do a lot, perhaps I've missed something but from what I can tell, it falls short in this particular case. Is there an easier/better way to do this? My Solution: DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setCoalescing(true); dbf.setIgnoringElementContentWhitespace(true); dbf.setIgnoringComments(true); DocumentBuilder db = dbf.newDocumentBuilder(); // parse and normalize expected xml Document expectedXMLDoc = db.parse(new ByteArrayInputStream(resultXML.getBytes())); expectedXMLDoc.normalizeDocument(); // parse and normalize actual xml Document actualXMLDoc = db.parse(new ByteArrayInputStream(actual.getXml().getBytes())); actualXMLDoc.normalizeDocument(); // expected and actual parent nodes NodeList expectedParentNodes = expectedXMLDoc.getLastChild().getChildNodes(); NodeList actualParentNodes = actualXMLDoc.getLastChild().getChildNodes(); // assert same amount of nodes in actual and expected assertEquals("actual XML does not h…
tagged with: parsing
tagged with: http://stackoverflow.com/tag/xml
tagged with: xmlunit
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21635258
upvote count: 3

http://stackoverflow.com/comment/32710852
type: Comment
has text: Never mind @user3164190
comment on: http://stackoverflow.com/q/21644312
score: 1
type: QuestionComment

deserialization
type: Tag
tags question: http://stackoverflow.com/q/21605594
tag name: deserialization
tags question: http://stackoverflow.com/q/21555569
tags question: http://stackoverflow.com/q/21552692
tags question: http://stackoverflow.com/q/21520337

http://stackoverflow.com/comment/32965442
type: Comment
comment on: http://stackoverflow.com/a/21569907
score: 0
type: AnswerComment
has text: Thank you sir. The Accumulator appears to be working. I have posted the solution implementing the Accumulator interface above.

http://stackoverflow.com/q/21627918
tagged with: java
has comment: http://stackoverflow.com/comment/32681981
tagged with: itext
has body: I'm working with a label printer which prints my pdf file. I create the file like this: public static Document createPDF() { float pageWidth = 176f; float pageHeight = 200f; Rectangle pageSize = new Rectangle(pageWidth, pageHeight); Document document = new Document(pageSize); document.setMargins(5, 5, 1, 0); String file = MainActivity.FILE_URI; try { PdfWriter.getInstance(document,new FileOutputStream(file)); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (DocumentException e1) { e1.printStackTrace(); } return document; } Then I add some paragraphs to it. The paragraphs have variabel length. When I exceed the length of the page IText adds another page. The pages are 62 x 75 mm. I want to change the length based on the amount of text so I don't waste paper. I tried this: try { PdfReader reader = new PdfReader(MainActivity.FILE_URI); while (reader.getNumberOfPages() &gt; 1) { float pageHeight = document.getPageSize().getHeight(); float pageWidth = document.getPageSize().getWidth(); pageHeight += 50f; document.setPageSize(new Rectangle(pageWidth, pageHeight)); } } catch (IOException e) { e.printStackTrace(); } But it's not working. The pages aren't getting longer so the number of pages stays the same and causes a loop. Anyone knows a solution?
has comment: http://stackoverflow.com/comment/32684458
has answer: http://stackoverflow.com/a/21630964
type: Question
tagged with: resize
score: 0
tagged with: http://stackoverflow.com/tag/pdf
answer count: 1
has comment: http://stackoverflow.com/comment/32681639
has comment: http://stackoverflow.com/comment/32681807
accepted answer: http://stackoverflow.com/a/21630964
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32683435
has title: Resizing IText pdf so the text fits on one page

http://stackoverflow.com/a/21520619
has body: Palindrome in this case it not directly convertible to String. You need to override the toString method and call that on Palindrome to make it into a String. You can call the trim and toLowerCase functions on the string directly. Those functions are bound to the Palindrome class. isPalindrome should be made non-static. The temp or palindrome local variable in each of the functions should directly modify the palindrome member variable.
answers question: http://stackoverflow.com/q/21520509
type: Answer
score: 0

search-engine
type: Tag
tag name: search-engine
tags question: http://stackoverflow.com/q/21536599

jsp-tags
tags question: http://stackoverflow.com/q/21677984
tag name: jsp-tags
type: Tag

http://stackoverflow.com/comment/32497972
comment on: http://stackoverflow.com/a/21523782
type: Comment
score: 0
type: AnswerComment
has text: Evgeniy, i am using hibernate 4.0.2 version. But i dont see persistence jar in its pom.

http://stackoverflow.com/q/21522391
has comment: http://stackoverflow.com/comment/32495505
has comment: http://stackoverflow.com/comment/32495709
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21522592
tagged with: java
has answer: http://stackoverflow.com/a/21523536
type: Question
answer count: 2
tagged with: client-server
has title: My client can't read my server's response
upvote count: 1
has body: This is my code for my server String request=di.readLine(); System.out.print(request); switch (request){ case "/login": dout.writeBytes(request); } This is for my client String command = "/login \r\n"; try{ Socket s = new Socket ("localhost",8000); DataInputStream di = new DataInputStream(s.getInputStream()); DataOutputStream dout = new DataOutputStream(s.getOutputStream()); dout.writeBytes(command); System.out.println(di.readLine()); }catch(Exception e){ System.out.println("Log in error"); e.printStackTrace(); } The server can get my command but my client can't read my server's response I already try it in my telnet and it works. I think the problem is in my client program code
score: -2
has comment: http://stackoverflow.com/comment/32495681
favorite count: 0
has comment: http://stackoverflow.com/comment/32496107
downvote count: 3

http://stackoverflow.com/q/21531174
has title: Null Pointer exception in Arraylist
has comment: http://stackoverflow.com/comment/32511444
answer count: 2
possible better answer: http://stackoverflow.com/a/21531592
accepted answer: http://stackoverflow.com/a/21531213
tagged with: android
has body: I am getting null pointer exception even though I have placed the Null Check: @Override public ArrayList&lt;DataCache&gt; getData() { if(contentOf != null) { StoreData data = new StoreData(this); if(data!=null) { ArrayList&lt;DataCache&gt; cacheOf = null; System.out.println("Size of ContentOf"+contentOf.size()); for (int i=0;i&lt;contentOf.size();i++) { System.out.println("Value of ContentOf"+contentOf.get(i).mFeed); ArrayList&lt;DataCache&gt; cache = contentOf.get(i).mFeed.getData(); if (cache != null) cacheOf.add(cache.get(i)); } return cacheOf; } } } Exception: 02-03 10:19:18.770: E/AndroidRuntime(8680): FATAL EXCEPTION: main 02-03 10:19:18.770: E/AndroidRuntime(8680): java.lang.NullPointerException 02-03 10:19:18.770: E/AndroidRuntime(8680): at com.activity.MainFragmentActivity.getData(MainFragmentActivity.java:198)
has comment: http://stackoverflow.com/comment/56329429
type: AnsweredQuestion
score: 0
tagged with: java
has answer: http://stackoverflow.com/a/21531213
has comment: http://stackoverflow.com/comment/32511776
type: Question
linked to: http://stackoverflow.com/q/218384
has comment: http://stackoverflow.com/comment/32511559
has answer: http://stackoverflow.com/a/21531592
has comment: http://stackoverflow.com/comment/32511316
tagged with: arraylist

http://stackoverflow.com/a/21652775
answers question: http://stackoverflow.com/q/21652506
score: 1
type: AcceptedAnswer
has body: When you remove an element of an arraylist, all the following elements will be shifted. List content: 101, 102, 103, 104, 105 Calling remove(0) List content: 102, 103, 104, 105 Calling remove(2) List content: 102, 103, 105 Calling remove(4) Exception! There isn't index 4 anymore. Start with the highest index to work properly: list.remove(4); list.remove(2); list.remove(0); ... or choose another way to remove the elements.
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/21652506
upvote count: 1
has comment: http://stackoverflow.com/comment/32728145

http://stackoverflow.com/q/21677518
has title: Android User Session
type: Question
tagged with: session
answer count: 1
has answer: http://stackoverflow.com/a/21678882
score: 0
tagged with: android
has body: i'am just learning about Android Login and Registration with PHP, MySQL and SQLite from http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/but how to make a session function so i can make in my home screen(dashboard.xml) the name who login. like welcome "the name of user who get login". i'am still beginner for android, thank you so much for your help. this is my loginactivity.java package unai.skripsi.nexttry; import java.util.HashMap; import org.json.JSONException; import org.json.JSONObject; import unai.skripsi.nexttry.entity.DatabaseHandler; import unai.skripsi.nexttry.entity.UserFunctions; import android.app.Activity; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class LoginActivity extends Activity { Button btnLogin; Button btnLinkToRegister; EditText inputEmail; EditText inputPassword; TextView loginErrorMsg; // JSON Response node names private static String KEY_SUCCESS = "success"; private static String KEY_ERROR = "error"; private static String KEY_ERROR_MSG = "error_msg"; private static String KEY_UID = "uid"; private static String KEY_NAME = "name"; private static String KEY_EMAIL = "email"; private static String KEY_CREATED_AT = "created_at"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login); // Importing all assets like buttons, text fields inputEmail = (EditText) findViewById(R.id.loginEmail); inputPassword = (EditText) findViewById(R.id.loginPassword); btnLogin = (Button) findViewById(R.id.btnLogin); btnLinkToRegister = (Button) findViewById(R.id.btnLinkToRegisterScreen); loginErrorMsg = (TextView) findViewById(R.id.login_error); // Login button Click Event btnLogin.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { S…
type: UnansweredQuestion
tagged with: java
tagged with: authentication

http://stackoverflow.com/q/21533692
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32527092
has comment: http://stackoverflow.com/comment/32527019
has title: Breakout Game: JButton problems
tagged with: button
has answer: http://stackoverflow.com/a/22213865
tagged with: timer
type: Question
has body: I am a beginner programmer and I am trying to make a simple 2D game, Breakout. I have the logic for the game itself working but I am having trouble with getting the buttons to work with the game. I added a start and pause button to the top of the screen but whenever I pressed one of these buttons, the paddle at the bottom of the screen cannot move. When I take out the buttons the game runs perfectly. Any help would be greatly appreciated! Thank you in advance. Below is the code for my game. I only included the Breakout class because this was were I ran into trouoble. import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.TimerTask; public class Breakout extends JPanel implements KeyListener, ActionListener { boolean rightPressed; boolean leftPressed; boolean upPressed; boolean downPressed; boolean inGame; int width = 1450; int height = 900; Timer tm = new Timer(5, this); int numRows =5; int numCols = 8; int numBricks = 40; int mouseX; int mouseY; Paddle paddle = new Paddle(width/2, height-40); Ball ball = new Ball(); //BrickArray brick = new BrickArray(numRows, numCols, width/numCols, (height-100)/numRows); Brick[][] bricks = new Brick[8][5]; JButton start = new JButton("Start"); JButton pause = new JButton("Pause"); JButton reset = new JButton("Reset"); JButton exit = new JButton("Exit"); JButton help = new JButton("Help"); public Breakout() { setDoubleBuffered(true); //tm.start(); addKeyListener(this); setFocusable(true); add(start); start.addActionListener(new StartAction()); add(pause); pause.addActionListener(new PauseAction()); add(reset); add(exit); add(help); ball.setMaxX(width); ball.setMaxY(height); ball.setWidth(width); ball.setHeight(height); ball.setX(width/2); //width/2 ball.setY(height/2); //height paddle.setMaxX(width-paddle.getWidth()); int k=0; //row 1 for(int a=0; a&lt;bricks.length; a++) { bricks[a][0]=new Brick(120,40); bricks[a][0].setX(a*180); bricks[a][0].setY(50); //System.out.println(k + ": " + a*80); } //row 2 f…
has comment: http://stackoverflow.com/comment/32526848
score: 0
tagged with: java
tagged with: swing
answer count: 1
tagged with: jbutton
has comment: http://stackoverflow.com/comment/32526683
has comment: http://stackoverflow.com/comment/32526244

http://stackoverflow.com/comment/32736272
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21658971
has text: It needs to be 2d though

http://stackoverflow.com/comment/32655594
type: Comment
has text: Refer to : http://stackoverflow.com/questions/4432774/how-do-i-make-2-comparable-methods-in-only-one-class (same as your requirement)
type: QuestionComment
comment on: http://stackoverflow.com/q/21612621
score: 0

http://stackoverflow.com/q/21569486
has comment: http://stackoverflow.com/comment/32580279
has comment: http://stackoverflow.com/comment/32596040
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/32592383
type: AnsweredQuestion
tagged with: java
has body: I want to modify the following XML file : abcd yuio 20 6000 nmk bgtf wsxz 20 1000 uhb the edited XML file should look like this: That means the attribute TotalValue should be generated and added to the from this formula : TotalValue = Price * InStock and the Name and Model and InStock nodes should be attributes for Detail I have the following method for deleting elements : private static void deleteElement(Document doc) { NodeList TV = doc.getElementsByTagName("Detail"); Element emp = null; //loop for each for(int i=0; i<TV.getLength();i++){ emp = (Element) TV.item(i); Node DescriptionNode = emp.getElementsByTagName("Description").item(0); emp.removeChild(DescriptionNode); } } I need help for writing editElement method which is the hardest part!
accepted answer: http://stackoverflow.com/a/21578845
has title: How to edit xml file using DOM in java (really different)
type: Question
answer count: 1
has comment: http://stackoverflow.com/comment/32592938
favorite count: 0
has comment: http://stackoverflow.com/comment/32593578
score: 0
has answer: http://stackoverflow.com/a/21578845
tagged with: http://stackoverflow.com/tag/xml

http://stackoverflow.com/a/21549669
downvote count: 0
score: 4
type: AcceptedAnswer
type: Answer
has body: java.math.BigDecimal is your way to go BigDecimal.ONE.add(new BigDecimal(Math.sqrt(5))).divide(new BigDecimal(2)) represents the formula that you had posted and will return 1.6180339887498949025257388711906969547271728515625 That is, till 49 decimal places
answers question: http://stackoverflow.com/q/21549551
upvote count: 4
has comment: http://stackoverflow.com/comment/32545283
accepted answer of: http://stackoverflow.com/q/21549551

http://stackoverflow.com/comment/32762526
score: 0
type: AnswerComment
has text: that's what i did, but it still takes the background of my listview
type: Comment
comment on: http://stackoverflow.com/a/21674161

http://stackoverflow.com/q/21554530
score: 1
tagged with: java
favorite count: 0
type: Question
answer count: 2
tagged with: jtable
upvote count: 1
has comment: http://stackoverflow.com/comment/32551884
has answer: http://stackoverflow.com/a/48826043
has body: I'm using netbeans and i'm having trouble when deleting a row in a jTable. I want to delete a data using a textfield and a button. I've tried something like this but doesn't work: private void btnDelActionPerformed(java.awt.event.ActionEvent evt) { String text2 = (String)jTextField2.getText(); DefaultTableModel model = (DefaultTableModel)jTable2.getModel(); if (!text2.equals(model)){ do { String [] row = {text2}; while(!text2.equals(model)); model.removeRow(WIDTH); } } I also tried to make it like this one, but still doesn't work: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { String text = (String)jTextField1.getText(); DefaultTableModel model = (DefaultTableModel)jTable2.getModel(); for (int i = 0; i &lt; model.getRowCount(); i++) { for(int j = 0; j &lt; model.getColumnCount(); j++) { model.setValueAt(text, i, j); } } Any ideas? Please make it easy for me to understand. I'm really a beginner on java and I don't know if I'm using the right code.
tagged with: netbeans
has title: How to delete a row from a JTable based on a text field input
tagged with: swing
possible better answer: http://stackoverflow.com/a/48826043
has answer: http://stackoverflow.com/a/21554899
accepted answer: http://stackoverflow.com/a/21554899
type: AnsweredQuestion
downvote count: 0

http://stackoverflow.com/comment/32532613
score: 0
type: QuestionComment
type: Comment
has text: @user1589188 What exactly are you trying to do?
comment on: http://stackoverflow.com/q/21542793

http://stackoverflow.com/q/21560773
tagged with: console
has answer: http://stackoverflow.com/a/21561349
tagged with: exception
tagged with: java.util.scanner
has body: I'm trying to write a self-contained (i.e. no need to open/close resources externally) method to obtain input from the console but am running into problems using it more than once. I've tested it using both BufferedReader and Scanner: public class Test { public static void main(String[] args) { // String str1 = getConsoleInputSc("Enter the 1st string: "); String str1 = getConsoleInputBR("Enter the 1st string: "); System.out.println(str1); // String str2 = getConsoleInputSc("Enter the 2nd string: "); String str2 = getConsoleInputBR("Enter the 2nd string: "); System.out.println(str2); } public static String getConsoleInputBR(String prompt) { String input = ""; try (BufferedReader bufferRead = new BufferedReader( new InputStreamReader(System.in))) { System.out.print(prompt); input = bufferRead.readLine(); } catch (IOException e) { e.printStackTrace(); } return input; } public static String getConsoleInputSc(String prompt) { String input = ""; try (Scanner scanIn = new Scanner(System.in)) { System.out.print(prompt); input = scanIn.nextLine(); } catch (RuntimeException e) { e.printStackTrace(); } return input; } } I'm using the try-with-resources statement to handle closing the resources. Here's a sample run using the BufferedReader version: Enter the 1st string: efsd efsd Enter the 2nd string: java.io.IOException: Stream closed at java.io.BufferedInputStream.getBufIfOpen(Unknown Source) at java.io.BufferedInputStream.read(Unknown Source) at sun.nio.cs.StreamDecoder.readBytes(Unknown Source) at sun.nio.cs.StreamDecoder.implRead(Unknown Source) at sun.nio.cs.StreamDecoder.read(Unknown Source) at java.io.InputStreamReader.read(Unknown Source) at java.io.BufferedReader.fill(Unknown Source) at java.io.BufferedReader.readLine(Unknown Source) at java.io.BufferedReader.readLine(Unknown Source) at Test.getConsoleInputBR(Test.java:25) at Test.main(Test.java:16) Here's a sample run using the Scanner version: Enter the 1st string: sdfds sdfds Enter the 2nd string: java.util.NoSuchE…
has comment: http://stackoverflow.com/comment/32563509
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32563612
score: 0
has title: Self-contained Java console input method?
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21560858
answer count: 2
tagged with: bufferedreader

unicode
tags question: http://stackoverflow.com/q/21633109
tags question: http://stackoverflow.com/q/21522770
tag name: unicode
type: Tag
tags question: http://stackoverflow.com/q/21542462
tags question: http://stackoverflow.com/q/21653677
tags question: http://stackoverflow.com/q/21526200
tags question: http://stackoverflow.com/q/21536750

http://stackoverflow.com/q/21535066
accepted answer: http://stackoverflow.com/a/21535269
tagged with: rmi
upvote count: 3
tagged with: java
type: Question
has title: JMX : rmiPort and registryPort the same?
has answer: http://stackoverflow.com/a/21535269
answer count: 1
downvote count: 0
linked to: http://stackoverflow.com/q/21555710
favorite count: 0
has body: I'm trying to learn JMX as deep as possible. I've read many blog posts about how to explicitly set the port numbers used by the JMX server. As you may be aware there are actually two ports required: One for the Registry and one for RMI protocol traffic. Recently I discovered this blog post which suggests that the two ports can be set to the same so that you only have to punch one hole in the firewall. I must admit I thought it would never work. I was certain that it would create a "socket already bound" exception or something like that. But it does work! Questions: Why does it work? Why can the Registry live on the same port as is used rmi protocol traffic? Given that this works why would I ever want them to be on different ports. (assuming always using Java7 latest)
tagged with: jmx
type: AnsweredQuestion
score: 3

http://stackoverflow.com/q/21648724
tagged with: java
tagged with: base64
has comment: http://stackoverflow.com/comment/32741388
type: Question
score: 0
has title: Java android convert imageview image into base64 null pointer exception
answer count: 1
linked to: http://stackoverflow.com/q/10473823
tagged with: azure
tagged with: android
has body: I would like to ask if there is any way to convert image view image (the image is set from gallery / camera capture) to a base64 string? I have tried multiple ways but i have been getting null pointer exception. Does anyone have any ideas on fixing this? I am storing my base64 string into windows azure. I have tried putting this method into the. Please note that i removed my api key and the web url for the initmobileservice method so please understand and thank you in advance ImageView image; Bitmap bitmap; String baseUrl = ""; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.addramps); GetLatLon(); InitMobileService(); pref = getApplicationContext().getSharedPreferences("Account", 0); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); description = (EditText) findViewById(R.id.tb_Description); rbStairs = (RadioButton) findViewById(R.id.stairsRadioButton); rbRamps = (RadioButton) findViewById(R.id.rampssRadioButton); private void dataSave() { if (rbStairs.isChecked() || rbRamps.isChecked()) { //Error Here Bitmap bitmap=BitmapFactory.decodeResource(getResources(), R.id.stairsRampsPhoto); ByteArrayOutputStream stream=new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream); byte[] image=stream.toByteArray(); final String base64 = Base64.encodeToString(image, 0); final String lon = latlon.get(0), lat = latlon.get(1); String userType = GetData("userType"); final String id = GetData("id"); if (userType.equals("caretaker")) { mClient.getTable(careTakersProfile.class).where().field("id") .eq(id) .execute(new TableQueryCallback&lt;careTakersProfile&gt;() { @Override public void onCompleted( List&lt;careTakersProfile&gt; result, int arg1, Exception exception, ServiceFilterResponse response) { if (exception == null) { mClient.getTable(dataAnalysis.class) .insert(new dataAnalysis( base64, description.getText() .toString(), lat, lon, result.get(0).g…
has answer: http://stackoverflow.com/a/21648791
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32741736
has comment: http://stackoverflow.com/comment/32728733
tagged with: imageview

http://stackoverflow.com/a/21654145
has body: Generally searching for strings - you need to single quote the value - so replace with 'admin' and 'pass' in the where clause.
upvote count: 2
has comment: http://stackoverflow.com/comment/32745644
type: Answer
answers question: http://stackoverflow.com/q/21654091
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/32742263

http://stackoverflow.com/q/21602762
tagged with: java
tagged with: hibernate
tagged with: optimistic-locking
score: 0
answer count: 2
accepted answer: http://stackoverflow.com/a/21749974
possible better answer: http://stackoverflow.com/a/21645456
has answer: http://stackoverflow.com/a/21749974
tagged with: oracle-database
has answer: http://stackoverflow.com/a/21645456
has body: I have two hibernate entities: Order and its Items (one-to-many with save-update cascade, nothing special). Two users initiate an update of the same Order by adding a new Item at the same time which triggers Session.saveOrUpdate(order) operation in two concurrent threads. Both Order and Item have @Version column to support optimistic lock so this concurrent edit fails with OptimisticLockException as it supposed to be. Then I want to increase database consistency and add an unique constraint to the Item (on one of its columns). Repeating the case above I get constraint violation instead of OptimisticLockException! Looks like hibernate does this: INSERT new item into ITEM table (constraint voilation!) check optimistic lock UPDATE order table Is it possible to force Hibernate to check the optimistic lock BEFORE inserting the child items?
type: AnsweredQuestion
has title: Hibernate one-to-many sql execution order
type: Question

http://stackoverflow.com/comment/32515875
score: 1
has text: [link ](http://i.imgur.com/kv5jZ99.png?1?9723)
comment on: http://stackoverflow.com/q/21532709
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32754912
type: AnswerComment
comment on: http://stackoverflow.com/a/21669152
score: 0
type: Comment
has text: That is correct, but also consider start reading a good tutorial about GUI.

http://stackoverflow.com/comment/32703982
score: 1
has text: @jeff_kile great minds think alike! :D
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21640027

http://stackoverflow.com/a/21659307
answers question: http://stackoverflow.com/q/21659035
upvote count: 2
has comment: http://stackoverflow.com/comment/32758004
has comment: http://stackoverflow.com/comment/32738475
downvote count: 0
type: Answer
has body: If you want to make your user able to set a custom location in your Map, you can achieve it by doing the following: Your activity / fragment has to implement the OnMapClickListener interface Set your map listener like this: myMap.setOnMapClickListener(this); Implement public void onMapClick(LatLng point) which is the method you have to implement in step 1. Get the LatLong position from this method and place your marker in that point. Like this: MarkerOptions options=new MarkerOptions().snippet(getString(R.string.snippet)) .icon(BitmapDescriptorFactory.fromResource(R.drawable.mymarker)) .anchor(0.5f, 0.5f); options.position(point); myMap.addMarker(options);
score: 2

eclipse-plugin
tags question: http://stackoverflow.com/q/21587190
tags question: http://stackoverflow.com/q/21523451
tags question: http://stackoverflow.com/q/21628725
tags question: http://stackoverflow.com/q/21656481
tags question: http://stackoverflow.com/q/21657300
tags question: http://stackoverflow.com/q/21569981
type: Tag
tags question: http://stackoverflow.com/q/21627459
tags question: http://stackoverflow.com/q/21607537
tags question: http://stackoverflow.com/q/21537958
tags question: http://stackoverflow.com/q/21660136
tags question: http://stackoverflow.com/q/21620937
tags question: http://stackoverflow.com/q/21590108
tags question: http://stackoverflow.com/q/21569655
tags question: http://stackoverflow.com/q/21607480
tags question: http://stackoverflow.com/q/21582108
tags question: http://stackoverflow.com/q/21547717
tags question: http://stackoverflow.com/q/21659189
tags question: http://stackoverflow.com/q/21562408
tags question: http://stackoverflow.com/q/21614063
tags question: http://stackoverflow.com/q/21673330
tags question: http://stackoverflow.com/q/21663761
tags question: http://stackoverflow.com/q/21655669
tag name: eclipse-plugin
tags question: http://stackoverflow.com/q/21659911

http://stackoverflow.com/comment/78169692
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21655634
has text: DId you found solution for this issue?

http://stackoverflow.com/q/21524295
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/21524500
tagged with: validation
answer count: 1
score: 0
has body: Hi could any one help me out,How to validated the integer field using xml validation using struts1.3 here is my code. <arg0 key="PointFormBean.geozone" /> <!-- <arg1 key="${var:min}" resource="false"/> <arg2 key="${var:max}" resource="false"/> min 1 max 15 -->
has title: How to validate the integer field using xml validation using struts 1.3
has answer: http://stackoverflow.com/a/21524500
type: Question

http://stackoverflow.com/a/21544496
has comment: http://stackoverflow.com/comment/32534985
has body: A recursive method have two characteristics: It calls to itself to provide the solution It has a base case that contains where the recursive call must stop. Your asterisks method does not fulfill any of these. Since this looks like homework, I would only provide an explanation about how this method should be, the implementation will be yours: Since your method needs to return asterisks, it would be better returning a String instead of an Integer. This String will contain all the *s needed. Define a base case. This can be where number have a value of 1. If number is greater than 1, then you should return an asterisk and the result of calling to asterisks method using the rest of asterisks the whole result needs.
accepted answer of: http://stackoverflow.com/q/21544374
score: 3
answers question: http://stackoverflow.com/q/21544374
has comment: http://stackoverflow.com/comment/32534840
type: AcceptedAnswer
downvote count: 0
upvote count: 3
type: Answer

android-gridview
type: Tag
tags question: http://stackoverflow.com/q/21659190
tag name: android-gridview
tags question: http://stackoverflow.com/q/21575807

http://stackoverflow.com/comment/32712796
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21645368
has text: No. Not sure what the exact Java syntax is, but for example if the function that executes queries is execSQL(), you would do execSQL(query + " FROM Table"). This would not concatenate the from clause to the query string but would only add it to the string that the function receives.

http://stackoverflow.com/q/21664485
has comment: http://stackoverflow.com/comment/32746586
has comment: http://stackoverflow.com/comment/32746402
upvote count: 1
score: 1
tagged with: java
type: Question
answer count: 1
downvote count: 0
tagged with: compilation
tagged with: http://stackoverflow.com/tag/c
has comment: http://stackoverflow.com/comment/32746469
has comment: http://stackoverflow.com/comment/32746550
has answer: http://stackoverflow.com/a/21664637
tagged with: windows
has body: import java.io.*; public class chk { String className; String command,command1,command2; public String getMsg(String fileName,File Path1) { String dir; command = "tcc "+fileName; String output = executeCommand(command,Path1); if(output.compareTo("")==0) output = "Compilation Successfull!!"; return output; } private String executeCommand(String command,File Path1) { StringBuffer output = new StringBuffer(); Process p; try { p = Runtime.getRuntime().exec(command,null,Path1); p.waitFor(); BufferedReader reader1 = new BufferedReader(new InputStreamReader(p.getErrorStream())); BufferedReader reader2 = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = ""; while ((line = reader1.readLine())!= null) { output.append(line + "\n"); } while ((line = reader2.readLine())!= null) { output.append(line + "\n"); } } catch (Exception e) { e.printStackTrace(); } return output.toString(); } public static void main(String args[])throws IOException { String x; File dir=new File("D:\\test"); chk ob = new chk(); x = ob.getMsg("hello.c",dir); System.out.println("OUtput : "+x); } } ERROR I am trying to compile a C code from a java class. I am using Turbo C/C++ compiler and have also set its path i.e "C:/TC/bin" even my programs are compiling when i compile them directly from command prompt but when i am trying to compile it with a java file the following error message appears. HELP!!
favorite count: 0
has title: Compiling a C file from a java Class
type: UnansweredQuestion

http://stackoverflow.com/q/21671003
downvote count: 0
score: 1
favorite count: 0
has title: How do I allow a user to create a new .txt file of their choosing in Java
type: Question
tagged with: input
has answer: http://stackoverflow.com/a/21671330
tagged with: java
tagged with: file
has body: The code I'm attempting to write has a jTextField for a user to input a string. The user will then click the jButton to create the file. For the creation of the file, I had in mind: Taking the string input from the user, and appending it to .txt within a file creation method. The code below shows this unsuccessful attempt: String input; Scanner scan = new Scanner(System.in); input = scan; //This is totally wrong, but I'm not sure how to convert the scanner private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { final Formatter x; try{ x = new Formatter(input + ".txt"); } catch(Exception e) { System.out.println("Your code is bad. You should feel bad."); } } private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) { input = jTextField1.getText(); }
upvote count: 1
tagged with: formatter
answer count: 1
has comment: http://stackoverflow.com/comment/32757483
has comment: http://stackoverflow.com/comment/32757464
accepted answer: http://stackoverflow.com/a/21671330
type: AnsweredQuestion

http://stackoverflow.com/q/21635518
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/21635622
has answer: http://stackoverflow.com/a/21646564
possible better answer: http://stackoverflow.com/a/21635622
score: 0
tagged with: java
tagged with: jboss
accepted answer: http://stackoverflow.com/a/21646564
tagged with: servlets
type: AnsweredQuestion
has title: Managing requests between .jsps and servlets
tagged with: jsp
tagged with: jboss7.x
has body: I have a project that makes use of both .jsps and servlets. I'm having difficulties in forwarding requests between two files: a registration form(jsp) and a registration servlet. The servlet validates data received through the form and also handles user creation. The servlet should also notify the .jsp if any errors occur during registration. I am trying to use JSTL tags in order to do this, but upon registration the user is not redirected nor notified by the servlet. register.jsp &lt;%@ page language="java" session="true"contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%&gt; &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Register&lt;/title&gt; &lt;link href="style/style.css" rel="stylesheet" type="text/css" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="container"&gt; ... &lt;div class="content"&gt; &lt;h2 class="form"&gt;Register&lt;/h2&gt; &lt;form action="Register" method="post"&gt; &lt;p&gt; User name: &lt;br /&gt; &lt;input type="text" name="username" /&gt; &lt;b&gt; &lt;c:out value="${messages['userName']}" /&gt; &lt;/b&gt; &lt;br /&gt; First Name: &lt;br /&gt; &lt;input type="text" name="fist_name" /&gt; &lt;b&gt; &lt;c:out value="${messages['firstName']}" /&gt; &lt;/b&gt; &lt;br /&gt; Last Name: &lt;br /&gt; &lt;input type="text" name="last_name" /&gt; &lt;b&gt; &lt;c:out value="${messages['lastName']}" /&gt; &lt;/b&gt; &lt;br /&gt; Email Address: &lt;br /&gt; &lt;input type="text" name="email" /&gt; &lt;b&gt; &lt;c:out value="${messages['email']}" /&gt; &lt;/b&gt; &lt;br /&gt; Password: &lt;br /&gt; &lt;input type="password" name="password" /&gt; &lt;b&gt; &lt;c:out value="${messages['password']}" /&gt; &lt;/b&gt; &lt;br /&gt; Retype pass…

http://stackoverflow.com/q/21657691
has title: Spring data - modifying queries and ehcache (cache)
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/21673812
favorite count: 0
tagged with: ehcache
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21657866
tagged with: spring
score: 1
tagged with: java
tagged with: spring-data
upvote count: 1
tagged with: caching
type: Question
has body: Is it possible to make spring data modifying query such as: @Modifying @Query("update User u set u.firstname = ?1 where u.lastname = ?2") int setFixedFirstnameFor(String firstname, String lastname); Auto invalidate my ehcache of User entity? Thanks!

http://stackoverflow.com/comment/32638124
has text: Its not working its giving String formate like this.@88174c i need String values..
comment on: http://stackoverflow.com/a/21602574
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32603483
comment on: http://stackoverflow.com/q/21582936
score: 0
has text: @JesanFafon `since string is zero based`... What does this mean?
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32620733
type: Comment
has text: Do you want to move that to an answer? Because that solved it :)
comment on: http://stackoverflow.com/q/21585943
score: 0
type: QuestionComment

http://stackoverflow.com/comment/32528257
comment on: http://stackoverflow.com/q/21540319
score: 5
has text: `i *= -1;` is a valid one too ;)
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32621517
type: QuestionComment
comment on: http://stackoverflow.com/q/21592979
score: 0
has text: Yes, I can find POST data in the body of the request, but there is no method to get a specific key.., for example : "data1=mydata&name=pseudo"
type: Comment

http://stackoverflow.com/comment/32651708
score: 0
type: Comment
type: QuestionComment
has text: In chrome developer tools or firebug is the cookie being added under the sources?
comment on: http://stackoverflow.com/q/21604356

http://stackoverflow.com/a/21664609
downvote count: 1
upvote count: 0
answers question: http://stackoverflow.com/q/21664566
type: Answer
score: -1
has comment: http://stackoverflow.com/comment/32746474
has body: When you write to file, you acctualy write to file cache, try calling bufferedWriter.close() to save all changes.

http://stackoverflow.com/q/21533138
linked to: http://stackoverflow.com/q/14011492
has answer: http://stackoverflow.com/a/23681187
favorite count: 0
tagged with: antlrworks
tagged with: antlr4
type: UnansweredQuestion
tagged with: swing
score: 1
tagged with: java
upvote count: 1
has comment: http://stackoverflow.com/comment/32515457
type: Question
has body: ANTLRInputStream input = new ANTLRInputStream(System.in); CLexer lexer = new CLexer(input); CommonTokenStream tokens=new CommonTokenStream(lexer); CParser parser = new CParser(tokens); ParseTree tree=parser.translationUnit(0); System.out.println(tree.toStringTree(parser)); I already got the AST from ANTLR, I want to have a look at the AST in the GUI way. But how to do that in java swing? thank you guys.
has title: How to run ANTLR GUI in java swing?
tagged with: abstract-syntax-tree
answer count: 1
downvote count: 0

http://stackoverflow.com/comment/32592420
score: 0
type: Comment
has text: yes i tried <display:setProperty> but it's not working. I think you can also try see if u get it right
type: AnswerComment
comment on: http://stackoverflow.com/a/21576578

http://stackoverflow.com/comment/32634102
score: 0
type: QuestionComment
has text: @Gimby what it does is give client a web site, and client choose some tables to view, and in the back, data is provided and presented to client
type: Comment
comment on: http://stackoverflow.com/q/21599762

http://stackoverflow.com/comment/32497870
comment on: http://stackoverflow.com/a/21523724
type: Comment
has text: FYI… Daylight Saving Time (United States) 2013 began at 2:00 AM on Sunday, March 10 (so says The Google).
score: 0
type: AnswerComment

http://stackoverflow.com/q/21607406
has answer: http://stackoverflow.com/a/59705279
has comment: http://stackoverflow.com/comment/32645817
tagged with: data-structures
has body: I'm trying to understand about data structure and ADT. So far I've read numerous resources, yet I don't have a clear understanding what the difference is. So my understanding is stack, linkedlist and queue are data structures, and there are classes named Stack, Linkedlist as ADT to use those data structures in Java. But some books or resources say that stack is a collection, and the other resources say stack is data structure. I'm very confused all the differences, and am lost at how stack can be implemented with linkedlist. Could anybody explain to make it more clear to me? I know it would be very basic question, but I'm really in need to understand! Thank you so much!
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/21607796
downvote count: 2
upvote count: 1
has comment: http://stackoverflow.com/comment/32646678
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21607636
has answer: http://stackoverflow.com/a/21607636
tagged with: stack
tagged with: java
score: -1
has title: Understanding stack(data structure), stack class, linked list - java?
accepted answer: http://stackoverflow.com/a/21607796
type: Question
has answer: http://stackoverflow.com/a/21608099

http://stackoverflow.com/a/21567073
has body: That's most likely the use of a ternary operator, despite its cryptic appearance which is usually attributed to RegExps: l = ((z + lo) &lt;= lf) ? lo : (lf - z); This is another way of writing the following: if(z + lo &lt;= lf) l = lo; else l = lf - z; This doc covers the ternary operator: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/op2.html Related SO post: How does the ternary operator work? Edit: The code you posted can be used as a Regex: http://www.rubular.com/r/Svr9S7EaCP
type: Answer
accepted answer of: http://stackoverflow.com/q/21566956
answers question: http://stackoverflow.com/q/21566956
downvote count: 0
score: 1
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32575992

http://stackoverflow.com/q/21536320
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21609237
tagged with: jetty
upvote count: 1
tagged with: newrelic
score: 1
tagged with: java
has body: I have a Jetty server that clients connect to using WebSockets. I am monitoring the performance of the Jetty server using NewRelic. It only counts each new connection to server as one, but it does not provide: 1. any throughput information about the number of sent/received messages through the WebSockets. 2. any insight on how busy the server is Would it be possible to get these information through NewRelic?
type: Question
has title: NewRelic monitor Websockets application detalis
downvote count: 0
tagged with: websocket
tagged with: throughput
answer count: 1
favorite count: 0

http://stackoverflow.com/comment/32498259
score: 0
type: AnswerComment
has text: `&ndash;` is a named HTML entity. Try my edited answer instead.
type: Comment
comment on: http://stackoverflow.com/a/21523662

http://stackoverflow.com/comment/32701788
score: 0
type: Comment
type: QuestionComment
has text: What is "just a string" (but presumably not an "object") in Java?
comment on: http://stackoverflow.com/q/21638634

http://stackoverflow.com/comment/32690267
score: 0
comment on: http://stackoverflow.com/q/21630051
has text: Unrelated: please learn java naming conventions and stick to them.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32629968
type: QuestionComment
has text: if you need a new "page" which actually is just a scenegraph component like VBox or BorderPane just set a new value to `scene.setRoot()` or any subcomponents. See example here: http://stackoverflow.com/questions/8309802/how-can-i-implement-the-functionality-of-awt-cardlayout-in-my-javafx-2-0-applica/8310585#8310585
comment on: http://stackoverflow.com/q/21595303
score: 0
type: Comment

http://stackoverflow.com/comment/32762028
type: AnswerComment
has text: It was just a example. I saw it in "toArray(T[] a)" of a ArrayList where the zero length is fine.
comment on: http://stackoverflow.com/a/21673584
score: 0
type: Comment

http://stackoverflow.com/comment/32528600
comment on: http://stackoverflow.com/a/21540502
type: AnswerComment
has text: What I don't understand is the fact that i'm trying to make an arraylist that only holds integers. Wouldn't String[] create an array list that holds strings? Also, do you think you could help me with the Else function as it's not correctly functioning. I'm trying to make a list with integers from 2 to num. (num is the user input #) Thank you.
score: 0
type: Comment

http://stackoverflow.com/a/21828816
answers question: http://stackoverflow.com/q/21613376
type: Answer
has body: It's happen the same to me. [EL Warning]: weaver: 2014-02-17 12:59:36.897--ServerSession(285072714)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Weaver encountered an exception while trying to weave class net.xxx.MyEntity The exception was: java.lang.NoClassDefFoundError: org/eclipse/persistence/internal/jpa/weaving/ComputeClassWriter
score: 0
has comment: http://stackoverflow.com/comment/33038383

http://stackoverflow.com/comment/32566852
score: 5
type: AnswerComment
type: Comment
has text: Thanks. I feel like this guy has trouble finding the docs, not reading them. It can be hard for beginners to do a meaningful search without knowing the proper terminology. Kind of a vicious cycle really.
comment on: http://stackoverflow.com/a/21562519

http://stackoverflow.com/comment/32698042
score: 0
type: AnswerComment
type: Comment
has text: Not quite - `flag` would be true if any but the very last item failed. You could do something like `success = true` (at the top; "success" is the more descriptive name for "flag") ... `success &= catalog.sellProduct(id);`
comment on: http://stackoverflow.com/a/21636542

http://stackoverflow.com/comment/32643992
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21597531
has text: how would that show my starting activity when needed to be seen?\
score: 0

http://stackoverflow.com/comment/32700005
comment on: http://stackoverflow.com/a/21637751
score: 0
type: AnswerComment
has text: @kviiri Regardless of whether it was brought up by OP, it bears mentioning.
type: Comment

http://stackoverflow.com/a/21850382
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/21673420
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21673420
has body: For the 3rd exception that you'r getting, org.xml.sax.SAXException, Reason is you don't match the fields correctly in your web-app.xml file. You need to match the order of the fields according to the standard order. Order is given in the exception itself. (icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)

http://stackoverflow.com/a/21539304
answers question: http://stackoverflow.com/q/21538273
downvote count: 0
upvote count: 2
type: Answer
has body: This class seems (from a since tag) to be introduced in Spring 3.2.1. Try to change spring.version to 3.2.1.RELEASE (to upgrade also spring-beans.jar which holds this class).
score: 2

http://stackoverflow.com/comment/32690380
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21632841
has text: Indeed! Didn't even see what the objects were. I'll edit.
type: AnswerComment

http://stackoverflow.com/comment/102764764
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21581829
has text: In my version (2.3.26), simply `${myDate?c}` will suffice, assuming that `myDate` is already a long/int.

http://stackoverflow.com/q/21630363
possible better answer: http://stackoverflow.com/a/50697991
favorite count: 0
tagged with: http://stackoverflow.com/tag/xml
has answer: http://stackoverflow.com/a/50697991
tagged with: spring
tagged with: xsd
tagged with: spring-mvc
type: AnsweredQuestion
score: 3
has answer: http://stackoverflow.com/a/21630392
upvote count: 3
tagged with: java
accepted answer: http://stackoverflow.com/a/21630392
type: Question
has body: snippet from my xml file: &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/context/spring-context-3.1.xsd"&gt; &lt;!-- http://www.springframework.org/schema/aop --&gt; &lt;!-- http://www.springframework.org/schema/aop/spring-aop.xsd"&gt; --&gt; &lt;context:component-scan base-package="myPackage" /&gt; after execution I see following message: WARN [WrapperSimpleAppMain] [XmlBeanDefinitionReader] Ignored XML validation warning org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 80; SchemaLocation: schemaLocation value = 'http://www.springfr amework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.spri ngframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springfra mework.org/schema/context/spring-context-3.1.xsd' must have even number of URI's. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198) How to solve this problem right?
answer count: 2
has title: spring. "schemaLocation ... must have even number of URI's"
downvote count: 0

http://stackoverflow.com/comment/32770917
score: 0
comment on: http://stackoverflow.com/a/21658962
has text: Oh, thanks for sharing this, I will define your question as one of my favorites. Glad to have helped you a little. I hope you can finish your project. Good luck! :)
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32520098
type: Comment
comment on: http://stackoverflow.com/q/21535608
type: QuestionComment
has text: The idea is the multiple runnables with different globalVars will be fed into a thread pool. Once they are all done, it joins/stops at the end and the function evaluate is done
score: 0

http://stackoverflow.com/comment/102839019
score: 0
type: Comment
comment on: http://stackoverflow.com/a/40718162
type: AnswerComment
has text: Can you share the source code ? Am getting the following error "Cannot handle managed/back reference 'defaultReference': back reference type (java.util.List) not compatible with managed type "

http://stackoverflow.com/q/21554629
has comment: http://stackoverflow.com/comment/32553440
score: 0
answer count: 1
has title: Howto get size of a cell in JGoodies FormLayout
tagged with: jgoodies
has comment: http://stackoverflow.com/comment/32554350
has answer: http://stackoverflow.com/a/21573648
linked to: http://stackoverflow.com/q/12769656
tagged with: swing
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/21573648
has comment: http://stackoverflow.com/comment/32553085
has body: I want to resize an image inside a JGoodies form layout according to the size the cell has, i.e. so that the image fits perfectly in the cell. If I understand correctly, there is no real component for the cell, the size is known only implicitly by the layout manager, right? Any ideas?
type: Question

http://stackoverflow.com/comment/32630387
type: Comment
score: 1
comment on: http://stackoverflow.com/a/21597955
type: AnswerComment
has text: I should delete everything else I have said here. I confused AWT and Swing. Since AWT is heavyweight then the event loop would actually be recieving events corresponding to real native UI components. The `sun.awt.windows` package would be Windows specific code that interfaces with the Windows API. If you were on a different platform, there would be no `sun.awt.windows`.

http://stackoverflow.com/q/21519852
has body: I've looked around some other answers and found a few solutions, I'm using JTextArea.append(), however what's confusing me is that my implementation works in one method, but not another. In my frame class when I call "open()" and open a file it displays the output in the jTextArea1 using getjTextArea1() and getjTextArea1().append("\n"+"Writing data to file..." + "\n"+Controller.stats()); However, when I attempt to do the same (I think it's the same, but it doesn't work, so clearly it isn't) with the method "display()" it runs the method, but doesn't append the jTextArea. I'm quite the greenhorn to java and I've spent some time looking at other answers but just can't seem to see why my code doesn't work. I have the following code, which should compile and run as a minimum example. Main controller class: package forSO; import java.awt.EventQueue; import javax.swing.JFrame; public class Controller { public static Checkout till1; public static void main(String[] args) throws Exception { EventQueue.invokeLater(new Runnable() { public void run() { new Frame().setVisible(true); new Frame().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }); till1 = new Checkout(); till1.simulation(); } public static String stats() { String maxLength=till1.CalculateMaxLength(); String stats = "Max length = "+maxLength; return stats; } } Checkout class, where the simulation occurs: package forSO; import java.io.*; import java.text.DecimalFormat; import java.util.*; public class Checkout{ private static int nTimeSteps = Frame.getnTimeSteps(); private static Queue&lt;String&gt; tillQueue; private static int rndNumber; private static int currentLen; private static ArrayList &lt;Integer&gt; lengthList; private int maxLength; private static Random r; public Checkout(){ tillQueue = new LinkedList&lt;String&gt;(); currentLen = 0; lengthList = new ArrayList &lt;Integer&gt;(); r = new Random(); } public void simulation(){ System.out.println("Time"+"\t"+"Rnd"+"\t"+"Queue Status"); int t = 1; //contr…
type: AnsweredQuestion
tagged with: java
type: Question
tagged with: jtextarea
has title: Appending data to JTextArea for a running simulation
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/21519887
accepted answer: http://stackoverflow.com/a/21519887
tagged with: swing

http://stackoverflow.com/q/21576292
tagged with: algorithm
has answer: http://stackoverflow.com/a/21595395
possible better answer: http://stackoverflow.com/a/21576388
tagged with: sorting
has comment: http://stackoverflow.com/comment/32591338
has body: I'm interested in an efficient way to store pairs of numbers, and to sort them according to a value of one of the numbers. Say I have a list of numbers: (1, 2), (3, 5), (4, 3), (7, 8) These pairs need to be stored in some way, then sorted in descending order of the second number, such that the order of these pairs is (7, 8), (3, 5), (4, 3), (1, 2) What would be the Java code to achieve this? I'm aware of C++'s std::pair, but I was wondering about the procedure in Java.
type: AnsweredQuestion
downvote count: 0
has title: Sorting pairs of numbers according to one value - Java
favorite count: 0
has comment: http://stackoverflow.com/comment/32591286
accepted answer: http://stackoverflow.com/a/21595395
has comment: http://stackoverflow.com/comment/32591375
type: Question
linked to: http://stackoverflow.com/q/11647889
has comment: http://stackoverflow.com/comment/32599208
has comment: http://stackoverflow.com/comment/32591284
score: 4
linked to: http://stackoverflow.com/q/109383
has comment: http://stackoverflow.com/comment/32593818
tagged with: java
answer count: 3
has answer: http://stackoverflow.com/a/21576484
has answer: http://stackoverflow.com/a/21576388
upvote count: 4

http://stackoverflow.com/a/21623192
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/32673432
has body: There's no way a browser will let you clear its cache. It would be a huge security issue if that were possible. This could be very easily abused - the minute a browser supports such a "feature" will be the minute I uninstall it from my computer. What you can do is to tell it not to cache your page, by sending the appropriate headers or using these meta tags: &lt;meta http-equiv='cache-control' content='no-cache'&gt; &lt;meta http-equiv='expires' content='0'&gt; &lt;meta http-equiv='pragma' content='no-cache'&gt;
answers question: http://stackoverflow.com/q/21623066

http://stackoverflow.com/comment/111595547
comment on: http://stackoverflow.com/a/39465150
type: AnswerComment
has text: This is the best fix
type: Comment
score: 2

http://stackoverflow.com/q/21530153
type: Question
tagged with: java
score: 0
tagged with: intellij-idea
has body: I have a web application project and when I try to deploy my project to server I can't see my properties files(i18n). How can I deploy my project with all resources? EDIT: For example I have some classes and properties files under my src folder; src/login/login.properties and src/login/login.class. When I build and deploy this project I can't see my properties files.
has comment: http://stackoverflow.com/comment/32510919
has title: Intellij idea how to deploy project with all resources
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32519634

http://stackoverflow.com/a/21564506
upvote count: 5
type: Answer
has body: It's not just a matter of taste. If there isn't any extra logic in the setXXX() methods, the convention is to assign the attributes directly in the constructor: this.foreName = foreName; this.surName = surName; ... And so on. But if there is extra logic in the setXXX() methods, then you should use them as required. Say, a call to logging logic or similar: public void setForeName(String pForeName) { log.info("setting new foreName value: " + pForeName); this.foreName = pForeName; } See how the last line in setForeName() is the same as performing a direct assignment? Also notice that calling a setXXX() might have a very, very small cost in performance (most likely optimized away by the JIT compiler). Under normal circumstances you should optimize for readability and clarity above all, and IMHO using a direct assignment here is the preferred option.
downvote count: 0
score: 5
accepted answer of: http://stackoverflow.com/q/21564478
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21564478

http://stackoverflow.com/comment/32671217
has text: Here is a SO post which tell us how you do with a Joda - http://stackoverflow.com/questions/883060/how-can-i-determine-if-a-date-is-between-two-dates-in-java It is a very easy.
type: QuestionComment
comment on: http://stackoverflow.com/q/21621735
score: 0
type: Comment

http://stackoverflow.com/q/21648885
tagged with: jframe
tagged with: swing
tagged with: jsplitpane
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32719020
tagged with: java
accepted answer: http://stackoverflow.com/a/21649387
has title: Waiting for JFrame to be loaded before continuing?
type: Question
score: 0
has comment: http://stackoverflow.com/comment/32718913
answer count: 1
has comment: http://stackoverflow.com/comment/32719441
has comment: http://stackoverflow.com/comment/32719215
has answer: http://stackoverflow.com/a/21649387
has body: I have a JFrame that contains two nested JSplitPanes. I want them to be set to an exact proportion on startup. I can not use setDividerLocation(int) as I don't know the frame's size yet (I maximize it on startup). So, I use the proportional version, setDividerLocation(double). Code: // ... JSplitPane left = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); JSplitPane right = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); right.setResizeWeight(1); // So that I can move the dividers independently left.setLeftComponent(scrollPane1); right.setLeftComponent(scrollPane2); right.setRightComponent(scrollPane3); left.setRightComponent(right); add(left, BorderLayout.CENTER); add(statusLabel, BorderLayout.PAGE_END); setVisible(true); setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH); left.setDividerLocation(0.3); right.setDividerLocation(0.7); // ... Now, sometimes this works perfectly fine, but sometimes it doesn't change the dividers. I believe this is because the frame is not loaded on screen. From the setDividerLocation(double) docs: If the split pane is not correctly realized and on screen, this method will have no effect (new divider location will become (current size * proportionalLocation) which is 0). Is there a way to wait until the frame is "on screen"? This is probably about a few milliseconds, but it still breaks the layout on startup. I would not like to use Thread.sleep with a fixed value but some way that works with Swing. EDIT: I tried the hack Behe suggested. It did not work, so it might not be about the timing. EDIT 2: I debugged some more. It appears that this is caused by my resize weight being set to 1. However this is required by my layout.

http://stackoverflow.com/comment/32627819
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/21596008
type: Comment
has text: Can you add screenshots of your eclipse library sequence for your project?

http://stackoverflow.com/q/21601808
has answer: http://stackoverflow.com/a/21601862
tagged with: java
has answer: http://stackoverflow.com/a/21601850
type: Question
upvote count: 5
has answer: http://stackoverflow.com/a/21601837
has title: what does " |= "and " ^= " mean in java?
duplicate of: http://stackoverflow.com/q/20031217
score: 5
downvote count: 0
linked to: http://stackoverflow.com/q/20031217
has answer: http://stackoverflow.com/a/21601878
favorite count: 0
has comment: http://stackoverflow.com/comment/32635967
has body: this is a function for changing bit value of image. what does |= and ^= mean? private int setBitValue(int n,int location,int bit) { int toggle=(int)Math.pow(2,location),bv=getBitValue(n,location); if(bv==bit) return n; if(bv==0 &amp;&amp; bit==1) n|=toggle; // what does it do? else if(bv==1 &amp;&amp; bit==0) n^=toggle; // what does it do? return n; }
type: UnansweredQuestion
answer count: 4

http://stackoverflow.com/comment/32659090
type: Comment
comment on: http://stackoverflow.com/a/21614511
has text: That can be very useful.I Will def make that come into play somewhere in my code.
score: 0
type: AnswerComment

http://stackoverflow.com/a/21520911
has body: Start Eclipse (make sure eclipse has maven, I used eclipse KEPLER) Create a new eclipse project (Under the Maven folder select "Maven Project") Give the project a name / group-id / artifact-id Open pom.xml and then click on the actual pom.xml tab. Add the dependency shown on github, my pom file ended up looking like this. And finally write a class to do some stuff with the driver, the below creates a keyspace and a column family. import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Session; public class App { public static void main( String[] args ) { Cluster cluster = Cluster.builder() .addContactPoints("127.0.0.1") .build(); Session session = cluster.connect(); String cqlStatement = "CREATE KEYSPACE myfirstcassandradb WITH " + "replication = {'class':'SimpleStrategy','replication_factor':1}"; session.execute(cqlStatement); String cqlStatement2 = "CREATE TABLE myfirstcassandradb.users (" + " user_name varchar PRIMARY KEY," + " password varchar " + ");"; session.execute(cqlStatement2); System.out.println("Done"); System.exit(0); } } Also check this answer out for CRUD operations with the driver.
accepted answer of: http://stackoverflow.com/q/21517338
upvote count: 10
answers question: http://stackoverflow.com/q/21517338
has comment: http://stackoverflow.com/comment/79734302
score: 10
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/32518339

http://stackoverflow.com/comment/32685734
comment on: http://stackoverflow.com/q/21626543
has text: After a little research I went with a mediator pattern as suggested. It finally works and isn't as complicated as I made it out to be. Thanks all for the help!
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21531592
answers question: http://stackoverflow.com/q/21531174
score: 0
type: Answer
has body: Did you read the error? The key here is: com.activity.MainFragmentActivity.getData(MainFragmentActivity.java:198) What line is 198? I suspect it is either one of these: System.out.println("Value of ContentOf"+contentOf.get(i).mFeed); ArrayList&lt;DataCache&gt; cache = contentOf.get(i).mFeed.getData(); You have memory that is uninitialized.

http://stackoverflow.com/comment/131619030
has text: Does this answer your question? [Why doesn't string search work in DOCX and PDF files?](https://stackoverflow.com/questions/74562264/why-doesnt-string-search-work-in-docx-and-pdf-files)
score: 0
comment on: http://stackoverflow.com/q/21527232
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21579281
score: 1
tagged with: java
type: Question
answer count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/32596786
has answer: http://stackoverflow.com/a/21579395
favorite count: 0
possible better answer: http://stackoverflow.com/a/21579480
has answer: http://stackoverflow.com/a/21579480
tagged with: colors
has comment: http://stackoverflow.com/comment/32596842
tagged with: paintcomponent
has body: I would like to apologise in advance for writing this code in Estonian, not in English. I am beginner in Java(2-3hour experience so far). I am trying to write code for customizable chess table.(size customizable)So far I have been able to write code for the table but I have problem with coloring it. How do I color table according to the right colors of chess table ? package esimene; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Graphics; import java.awt.GridLayout; import java.awt.Label; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JCheckBox; import javax.swing.JColorChooser; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextField; public class Joonistame4 extends JComponent implements ActionListener{ int suurus = 10; int korgus = 10; int x = 50; int y = 50; JTextField tf = new JTextField(String.valueOf(suurus)); JTextField tf2 = new JTextField(String.valueOf(korgus)); JColorChooser varvivalik = new JColorChooser(); JPanel p = new JPanel(new GridLayout(3,2)); //rida , veerg JCheckBox cb = new JCheckBox(); public Joonistame4(){ setLayout(new BorderLayout()); p.add(new Label("suurus: ")); p.add(tf); add(p, BorderLayout.SOUTH); //add(varvivalik, BorderLayout.EAST); tf.addActionListener(this); cb.addActionListener(this); varvivalik.setPreviewPanel(new JPanel()); } public void paintComponent(Graphics g){ int suurus_kokku = 8*suurus; g.setColor(Color.BLUE); for(int x = suurus; x &lt; suurus_kokku; x = x+suurus) { for(int y = suurus; y &lt; suurus_kokku; y = y+suurus) { if(cb.isSelected()){ g.fillRect(50, 50, suurus, suurus); }else{ g.drawRect(50+y, 50+x, suurus, suurus); } } } } public static void main(String[] args) { JFrame aken = new JFrame("Esimene aken"); aken.setSize(600, 600); aken.getContentPane().add(new Joonistame4()); aken.setVisible(true); aken.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public void actionPerformed(ActionEvent …
has comment: http://stackoverflow.com/comment/32596714
accepted answer: http://stackoverflow.com/a/21579395
tagged with: jcomponent
upvote count: 1
tagged with: swing
type: AnsweredQuestion
has title: Java chess table

http://stackoverflow.com/comment/32493103
has text: hi camilo any specific system configuration need for tomcat 7 installation or my system configuration can support the tomcat 7 installation.. Could you please suggest how much memory will i change my jvm memory. or can you rewrite this code. -Xms512m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=1024m
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21520369

http://stackoverflow.com/a/21561349
answers question: http://stackoverflow.com/q/21560773
has comment: http://stackoverflow.com/comment/32564763
downvote count: 0
score: 1
type: Answer
upvote count: 1
has body: Instead of using try-with-resources like you are doing, just put the code in a simple try-catch block like this: public static String getConsoleInput(String prompt) { String input = ""; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print(prompt); try { input = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return input; } This method worked fine when called by your code in main(). By not using try with resources, the resource is not automatically closed.
has comment: http://stackoverflow.com/comment/32568789
has comment: http://stackoverflow.com/comment/32565732

http://stackoverflow.com/q/21596741
accepted answer: http://stackoverflow.com/a/21597188
type: Question
tagged with: java
tagged with: hibernate
answer count: 1
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/21597188
tagged with: cascade
score: 3
has title: Hibernate one to many cascade all Not saving child id in parent
type: AnsweredQuestion
has body: This might be duplicate. But I don't find a proper link to my problem. May be my searching is too bad. So hoping for a good answer or link to any useful solution. Here is my Configuration.java public class Configuration implements java.io.Serializable { private Integer configurationId; private String configurationName; private Set&lt;ConfigFields&gt; ConfigFieldses = new HashSet&lt;ConfigFields&gt;(0); //getter and setter @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="configuration") public Set&lt;ConfigFields&gt; getConfigFieldses() { return this.ConfigFieldses; } public void setConfigFieldses(Set&lt;ConfigFields&gt; ConfigFieldses) { this.ConfigFieldses = ConfigFieldses; } } ConfigFields.java public class ConfigFields implements java.io.Serializable { private Integer configFieldId; private Configuration configuration; private String configFieldName; //getter and setter @XmlTransient @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="ConfigurationId") public Configuration getConfiguration() { return this.configuration; } public void setConfiguration(Configuration configuration) { this.configuration = configuration; } } Here is my code to insert the configuration Configuration configuration=new Configuration(); configuration.setConfigurationName(configName); List&lt;ConfigFields&gt; configFieldsList=new ArrayList&lt;ConfigFields&gt;(); for(int i=0;i&lt;fieldLength;i++) { ConfigFields configField=new ConfigFields(); // configField.setConfiguration(configuration); String stringI=Integer.toString(i); if(i&lt;fieldLength-1) { configField.setConfigFieldName(ENGINE_FORM+stringI); } else { configField.setConfigFieldName(ENGINE_TABLE+stringI); } configFieldsList.add(configField); } Set&lt;ConfigFields&gt; configFields-new HashSet&lt;ConfigFields&gt;(configFieldsList); configuration.setConfigFieldses(configFields); configurationService.insert(configuration); I want to insert one configuration in Configuration table and a set of configFields in ConfigFiel…
upvote count: 3

http://stackoverflow.com/q/21668288
tagged with: arrays
has answer: http://stackoverflow.com/a/21668307
tagged with: inheritance
accepted answer: http://stackoverflow.com/a/21668307
has title: How do I make it so I can access this array from any class?
score: 0
has answer: http://stackoverflow.com/a/21668325
answer count: 3
possible better answer: http://stackoverflow.com/a/21668325
has comment: http://stackoverflow.com/comment/32752982
type: AnsweredQuestion
tagged with: java
type: Question
tagged with: boolean
has body: So i've been trying to get it so my array can be accessed by any class, and i'm not sure what i'm doing wrong. Anyone know why this isn't working and what I need to change ? class UnitBools { public static boolean[] anArray; public UnitBools(boolean[] anArray){ anArray = new boolean[10]; anArray[0] = false; } public boolean[] getArray(){ return anArray; } public UnitBools(){ UnitBools.anArray[0] = true; } public static void main(String[] args) { System.out.println("Element at index 0: "+ UnitBools.anArray[0]); } } Right now my Sysout is returning a thread exception. Thanks for any help.
has answer: http://stackoverflow.com/a/21668529

http://stackoverflow.com/comment/32591076
comment on: http://stackoverflow.com/q/21575959
score: 0
type: Comment
type: QuestionComment
has text: You really should try it, because Android blocks any http requests on MainThread and so you do not get any output => Nullpointer.

http://stackoverflow.com/a/21527511
score: 1
answers question: http://stackoverflow.com/q/21527487
has body: my_arr is ArrayList not array ArrayList my_arr = new ArrayList(); use my_arr.add() not as my_arr[counter_rs] = query_rs;
has comment: http://stackoverflow.com/comment/32504719
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/32504772
upvote count: 1

http://stackoverflow.com/comment/32687362
score: 0
type: AnswerComment
has text: @ Luiggi Mendoza - I hope my answer added some value to OP. Can you please explain more on reason ? It will be value addition for me.
type: Comment
comment on: http://stackoverflow.com/a/21630793

http://stackoverflow.com/a/21526626
upvote count: 1
type: AcceptedAnswer
has body: public final Result get () Added in API level 3 Waits if necessary for the computation to complete, and then retrieves its result. Returns The computed result. Throws CancellationException If the computation was cancelled. ExecutionException If the computation threw an exception. InterruptedException If the current thread was interrupted while waiting. get() throws InterrruptedException. Your log says you need to catch those. Also you should not call get() coz its blocks the ui thread waiting fro the result. You should not block the ui thread. Remove get() and invoke as new JSONFunctions().execute(). To get the result in the activity use a interface Example @ How do I return a boolean from AsyncTask?
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/21526538
accepted answer of: http://stackoverflow.com/q/21526538

http://stackoverflow.com/a/21620710
downvote count: 0
has comment: http://stackoverflow.com/comment/32672454
upvote count: 2
has body: Your logic is a little off, not to mention that you're trying to compare an array to an int... First, the logic... do for x = 0 to rainfallMonths.length -1 do ... get input... while value &lt; 0 The problem here is, you've already assigned the input to all the elements of the array in the for-next loop, but then you are trying to validate the value that was input outside of the for-next which is likely never to return a valid result...and it's too late... Instead, you want to reverse the logic... for x = 0 to rainfallMonths.length -1 do do value = get input from user while value &lt; 0 rainfallMonths[x] = value Next, rainfallMonths is a reference to an array, this isn't actually what you want to be checking against, you need to be checking against one it's values or elements, for example... while (rainfallMonths[x] &lt; 0); And if none of that made sense... public static double[] getRainFall() { double[] rainfallMonths = new double[12]; double[] rainfall = new double[12]; for(int x = 0; x &lt; rainfallMonths.length; x++) { double input = 0; System.out.print("What is the rainfall for month #" + (x + 1) + ": "); do { rainfallMonths[x] = keyboard.nextDouble(); rainfall[x] = rainfallMonths[x]; if(input &lt; 0) { System.out.println("Input is Invalid"); } } while (rainfallMonths[x] &lt; 0); } for(int count = 0; count &lt; rainfallMonths.length; count++) { System.out.println("Rainfall Month #" + (count + 1) + ": " + rainfall[count]); } return rainfall; } You might want to take a refresher on Arrays which should help ;)
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21620592
accepted answer of: http://stackoverflow.com/q/21620592
type: Answer
score: 2

http://stackoverflow.com/a/21540109
answers question: http://stackoverflow.com/q/21540063
has body: When you're working with IO in Java, most of the times you have to handle the IOException. It can occur when you're reading the input, in this case. Try like this: public static void main(String[] args) { char ch; try{ ch = (char)System.in.read(); } catch(IOException e){ e.printStackTrace(); } if(ch&lt;'K') System.out.println("This shit is less than K " + ch); else System.out.println("Thats that shit I don't like " + ch); }
score: 0
type: Answer

http://stackoverflow.com/q/21648397
tagged with: hamming-code
has body: I'm trying to write a method in java that will take an input of any number of 0 or 1 digits and output that line after being encoded with Hamming Code. I have managed to write the code when knowing the number of digits the input will have (in this case 16) because knowing the number of digits in the input, I immediately know the number of parity bits there have to be added (5 in this case) to a total of 21 digits in the final output. I am working with int arrays so I need to declare a size in the beginning and my code works based on those exact sizes. Can you guys think of any way/algorithm that can give me the number of digits the output will have (after adding the relevant parity digits to the number of input digits) based solely on the number of input digits? Or do I have to tackle this problem in a totally different way? Any suggestions? Thank you in advance! Cheers!
favorite count: 0
upvote count: 2
has answer: http://stackoverflow.com/a/21648484
has title: Hamming Code: Number of parity bits
type: AnsweredQuestion
score: 2
has answer: http://stackoverflow.com/a/21648596
has comment: http://stackoverflow.com/comment/32718018
possible better answer: http://stackoverflow.com/a/21648484
tagged with: algorithm
tagged with: java
has comment: http://stackoverflow.com/comment/32723921
accepted answer: http://stackoverflow.com/a/21648596
type: Question
answer count: 2
downvote count: 0

http://stackoverflow.com/comment/32501378
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21525487
score: 1
has text: Some more code would be useful.

http://stackoverflow.com/a/21605080
answers question: http://stackoverflow.com/q/21604985
has body: You're creating the .txt file as a directory. Rather than all that after dir.mkdirs(); you should have sdcard.mkdirs(); try { FileOutputStream fos = new FileOutputStream(dir); fos = openFileOutput("MyDiary",Context.MODE_APPEND); fos.write(Content.getBytes()); fos.close(); } catch (IOException e) { e.printStackTrace(); } Further, rather than File dir = new File(sdcard + "/" + Content +".txt"); you'd want to use File dir = new File( sdcard, Content + ".txt" ); to avoid the explicit use of the path separator. If you must use it, please use File.pathSeparatorChar.
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/32642001
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/32641838

http://stackoverflow.com/q/21664967
has comment: http://stackoverflow.com/comment/32764628
tagged with: aes
has comment: http://stackoverflow.com/comment/32764523
has answer: http://stackoverflow.com/a/21667008
has comment: http://stackoverflow.com/comment/32747204
tagged with: encryption
has body: My program sends a string encrypted (AES) with received session key to Client to prove the key is correct. Client should decrypt it, get the string and verify it with original one. Program works fine. It encrypts and decrypts the string. It prints the string I need, but gives me false when I do String.equals(string). I can figure out why. There is the encryption part of my code: // ----create a challenge for Client (to check if the session key is correct)-------- public void sessionKeyVer(String challenge, File out) throws Exception{ aesCipher.init(Cipher.ENCRYPT_MODE, aeskeySpec); // switching mode for encryption CipherOutputStream os = new CipherOutputStream(new FileOutputStream(out), aesCipher); //output stream to another file os.write(challenge.getBytes("UTF-8"));// function to copy String to outputstream os.close(); //close the stream } There is the decryption part: public boolean sessionKeyVer(File file) throws Exception{ aesCipher.init(Cipher.DECRYPT_MODE, aeskeySpec); // switching mode for decryption CipherInputStream is = new CipherInputStream(new FileInputStream(file), aesCipher); //output stream to another file ByteArrayOutputStream os = new ByteArrayOutputStream(); int i; byte[] b = new byte[1024]; while((i=is.read(b))!=-1) { os.write(b, 0, i); } is.close(); os.close(); String file_string = new String(b,"UTF-8"); System.out.print(file_string); return file_string.equals(challenge); //return false } Thank you.
upvote count: 1
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/21667008
type: Question
has title: A string encrypted (AES) after decryption prints the same value , but false on equals()
downvote count: 0
answer count: 1
favorite count: 0
tagged with: cryptography
score: 1

http://stackoverflow.com/comment/32585383
type: Comment
comment on: http://stackoverflow.com/q/21572793
type: QuestionComment
has text: What are you really trying to accomplish? Anyway, a first idea is just to sort the array (or list), then start replacing all the numbers since `1` by the non-gaps e.g. 1,1,5,7 => 1,1,2,3.
score: 4

http://stackoverflow.com/q/21636235
tagged with: console
linked to: http://stackoverflow.com/q/21785626
score: 0
accepted answer: http://stackoverflow.com/a/21636397
type: Question
has answer: http://stackoverflow.com/a/21636397
type: AnsweredQuestion
has body: import java.io.*; public class chk { String className; String command,command1,command2; public String getMsg(String fileName,String Path) { String dir; command1="cd "+Path; dir=Path.charAt(0)+Path.charAt(1)+""; command2=dir; command = "javac " + fileName; String a=executeCommand(command1); a=executeCommand(command2); String output = executeCommand(command); if(output.compareTo("")==0) output = "Compilation Successfull!!"; return output; } private String executeCommand(String command) { StringBuffer output = new StringBuffer(); Process p; try { p = Runtime.getRuntime().exec(command); p.waitFor(); BufferedReader reader1 = new BufferedReader(new InputStreamReader(p.getErrorStream())); BufferedReader reader2 = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = ""; while ((line = reader1.readLine())!= null) { output.append(line + "\n"); } while ((line = reader2.readLine())!= null) { output.append(line + "\n"); } } catch (Exception e) { e.printStackTrace(); } return output.toString(); } public static void main(String args[])throws IOException { String x; chk ob=new chk(); x=ob.getMsg("MyClass.java","D:\test"); System.out.println("OUtput : "+x); } } Error I am trying to run a bunch of commands in command prompt with the help of a java file so that later i can compile another java file named "MyClass.java" which is present at some other drive in my computer but i am getting the following error stating it cannot even execute my first command i.e "command1="cd "+Path;" this line . pls help!
tagged with: java
answer count: 1
has title: executing commands from a java file

http://stackoverflow.com/comment/32650959
type: Comment
comment on: http://stackoverflow.com/a/21610277
type: AnswerComment
score: 0
has text: @AlexWien that's true. But only for floating-point types, and here everything is an integer.

http://stackoverflow.com/q/21527335
upvote count: 2
tagged with: android
has answer: http://stackoverflow.com/a/21527379
tagged with: http://stackoverflow.com/tag/xml
score: 2
has body: I tried to run my app but I got a message "Unfortunately app has stopped". my logcat is below.The problem has been resolved 02-02 07:54:20.224: I/Process(1820): Sending signal. PID: 1820 SIG: 9 02-02 07:54:24.184: D/AndroidRuntime(1853): Shutting down VM 02-02 07:54:24.204: W/dalvikvm(1853): threadid=1: thread exiting with uncaught exception (group=0xb0cd1b08) 02-02 07:54:24.244: E/AndroidRuntime(1853): FATAL EXCEPTION: main 02-02 07:54:24.244: E/AndroidRuntime(1853): Process: com.example.judoapp, PID: 1853 02-02 07:54:24.244: E/AndroidRuntime(1853): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.judoapp/com.example.judoapp.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.judoapp.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.judoapp-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.judoapp-1, /system/lib]] 02-02 07:54:24.244: E/AndroidRuntime(1853): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2102) 02-02 07:54:24.244: E/AndroidRuntime(1853): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226) 02-02 07:54:24.244: E/AndroidRuntime(1853): at android.app.ActivityThread.access$700(ActivityThread.java:135) 02-02 07:54:24.244: E/AndroidRuntime(1853): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397) 02-02 07:54:24.244: E/AndroidRuntime(1853): at android.os.Handler.dispatchMessage(Handler.java:102) 02-02 07:54:24.244: E/AndroidRuntime(1853): at android.os.Looper.loop(Looper.java:137) 02-02 07:54:24.244: E/AndroidRuntime(1853): at android.app.ActivityThread.main(ActivityThread.java:4998) 02-02 07:54:24.244: E/AndroidRuntime(1853): at java.lang.reflect.Method.invokeNative(Native Method) 02-02 07:54:24.244: E/AndroidRuntime(1853): at java.lang.reflect.Method.invoke(Method.java:515) 02-02 07:54:24.244: E/AndroidRuntime(1853): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:77…
type: AnsweredQuestion
tagged with: java
tagged with: http://stackoverflow.com/tag/json
tagged with: mysql
type: Question
accepted answer: http://stackoverflow.com/a/21527379
possible better answer: http://stackoverflow.com/a/21527515
has answer: http://stackoverflow.com/a/21527515
has comment: http://stackoverflow.com/comment/32504177
answer count: 2
downvote count: 0
favorite count: 0
has title: Unfortunately app has stopped working android emulator

http://stackoverflow.com/q/21601465
type: Question
answer count: 2
possible better answer: http://stackoverflow.com/a/21603970
has answer: http://stackoverflow.com/a/21603970
tagged with: listview
score: 0
tagged with: android
has body: I would like to make a list of favorites in my app. I am using arrayadapter. I have a string, and a rating bar, of one star only! I want that if you press the star once, it lights the star (and make it favorite) and when you press it again, the star isnt filled... (and now its not favorite anymore) what should I write here? and is it even correct this if quesion? public class ChooseFavorites extends Activity implements OnItemClickListener { String[] stations; float[] rating; boolean[] ifCheacked; RatingAdapter ratingAdapter; ArrayAdapter&lt;String&gt; arr; ListView list; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_choose_favorites); stations = getResources().getStringArray(R.array.stations); rating = new float[stations.length]; ifCheacked = new boolean[stations.length]; Arrays.fill(ifCheacked, false); ratingAdapter = new RatingAdapter(this, R.layout.favorite_row, stations); list = (ListView)findViewById(R.id.stationsList1); list.setAdapter(ratingAdapter); list.setOnItemClickListener(this); } class RatingAdapter extends ArrayAdapter&lt;String&gt; { Context ctx; LayoutInflater inflater; TextView stationName; RatingBar star; public RatingAdapter(Context context, int textViewResourceId, String[] objects) { super(context, textViewResourceId, objects); ctx = context; inflater = LayoutInflater.from(context); } @Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; if(row==null) { // Object reuse inflater = getLayoutInflater(); row = inflater.inflate(R.layout.favorite_row, parent, false); } stationName = (TextView)row.findViewById(R.id.textFavoriteItemInRow); stationName.setText(stations[position]); star= (RatingBar)row.findViewById(R.id.ratingBar1); if (!ifCheacked[position]) //ifChecked is false { star.setRating(rating[position]); star.setTag(position); ifCheacked[position] = true; } else { } star.setOnRatingBarChangeListener(new Ratin…
has answer: http://stackoverflow.com/a/21640784
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21640784
tagged with: java
has title: a "List of Favorites" in android - re-change the rating bar
tagged with: eclipse

http://stackoverflow.com/comment/32485038
has text: I'm not sure how you can violate an if statement... Anyway, you run through the entire array in the outer loop, and then again in the inner one, unless you reach a count>=3.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21516135
type: AnswerComment

http://stackoverflow.com/comment/32755129
type: Comment
has text: Check out the media player's get methods. There's always a get method :P (ex.: mediaPlayer.get...)
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21667830

http://stackoverflow.com/comment/32579593
comment on: http://stackoverflow.com/a/21551801
type: AnswerComment
has text: Thanks for update. Notepad++ is very tough to use considering it doesn't give you desired environment for trouble free development. I would advise you to shift to any IDE for problem free so that you don't have to track your folders and all other unnecessary things. For detailed solution please provide your source here so that I can analyze your code better.
score: 0
type: Comment

http://stackoverflow.com/comment/32637950
type: AnswerComment
has text: I wish I hadn't run that :( on my machine it's only just above 100k/s. Silly work machine.
comment on: http://stackoverflow.com/a/21602212
type: Comment
score: 1

http://stackoverflow.com/q/21648851
score: 0
tagged with: runnable
answer count: 1
tagged with: android-handler
type: UnansweredQuestion
tagged with: android
tagged with: java
has title: handler on a recursive function
has answer: http://stackoverflow.com/a/21648925
type: Question
has body: In one activity I have this recursive method: private void startThread(final int i){ if(i &lt; length){ TaskCross taskCross = new TaskCross(); TaskScreenshot taskScreenshot = new TaskScreenshot(i); TaskNoise taskNoise = new TaskNoise(); TaskEditText taskEditText = new TaskEditText(); handler.postDelayed(taskCross, 1000); handler.postDelayed(taskScreenshot, 2000); handler.postDelayed(taskNoise, 2100); handler.postDelayed(taskEditText, 3000); myEditText.setOnKeyListener(new View.OnKeyListener(){ public boolean onKey(View v, int keyCode, KeyEvent event) { System.out.println("KEY ENTER!!!!!"); if((keyCode == KeyEvent.KEYCODE_ENTER)) { if(myEditText.getText().toString().equals("")){ Toast.makeText(getApplicationContext(), "Inserire un numero da 1 a 9", Toast.LENGTH_SHORT).show(); return false; } else if (Integer.parseInt(myEditText.getText().toString()) &gt;= 1 &amp;&amp; Integer.parseInt(myEditText.getText().toString()) &lt;= 9){ startThread(i+1); return true; } } return false; } }); } } And let's say the value of the variable length is 5; the order that results is: TaskCross TaskScreenshot(0) TaskNoise TaskEditText TaskCross TaskCross TaskScreenshot(1) TaskScreenshot(2) TaskNoise TaskNoise TaskEditText TaskEditText TaskCross TaskCross TaskScreenshot(3) TaskScreenshot(4) TaskNoise TaskNoise TaskEditText TaskEditText But the result that I want is this: TaskCross TaskScreenshot(0) TaskNoise TaskEditText TaskCross TaskScreenshot(1) TaskNoise TaskEditText TaskCross TaskScreenshot(2) TaskNoise TaskEditText TaskCross TaskScreenshot(3) TaskNoise TaskEditText TaskCross TaskScreenshot(4) TaskNoise TaskEditText TaskEditText is a class that extends Runnable; this class collapse an ImageView and shows an EditText. In this EditText when a user press the Enter key of the keyboard the method is called recursively. The first call of the method is startThread(0) So, my question is: what am I doing wrong in this method? Am I using the postDelayed method in the right way? Thanks!

http://stackoverflow.com/a/21633358
type: Answer
has body: Your switch should be on the operatorOpt and not on no1. You can use like this switch(operatorOpt) { case "+": result=no1+no2; break; case "-": result=no1-no2; break; case "*": result=no1*no2; break; case "/": result=no1/no2; break; default: result = 0 ; break; }
has comment: http://stackoverflow.com/comment/32691549
has comment: http://stackoverflow.com/comment/32698745
score: 0
answers question: http://stackoverflow.com/q/21632659

http://stackoverflow.com/a/21535673
has comment: http://stackoverflow.com/comment/32524241
has comment: http://stackoverflow.com/comment/32524090
answers question: http://stackoverflow.com/q/21534518
score: 0
type: Answer
has body: All CursorAdapters require a column _id in the cursor projection. You don't expose too much of your database code in the question, but the query here: Cursor c = db.query(true, DATABASE_TABLE, ALL_KEYS, where, null, null, null, null, null); should include an _id column in ALL_KEYS. An easy way to add the _id is to alias the rowid (which is itself an alias to the INTEGER PRIMARY KEY column if one exists): Add "rowid AS _id" to the ALL_KEYS projection.
has comment: http://stackoverflow.com/comment/32524892

http://stackoverflow.com/q/21547498
accepted answer: http://stackoverflow.com/a/21547550
type: Question
type: AnsweredQuestion
tagged with: java
tagged with: http://stackoverflow.com/tag/json
tagged with: gson
has comment: http://stackoverflow.com/comment/32539704
answer count: 1
has body: Gson gson = new GsonBuilder().disableHtmlEscaping().create(); String path = "/folder1/folder2".replaceAll("/","\\\\/");//for get \/folder1\/folder2 String result = gson.toJson(path); and the result is \\/folder1\\/folder2
has answer: http://stackoverflow.com/a/21547550
score: 0
has title: Gson serialize issue with backslashes java

http://stackoverflow.com/a/21651137
answers question: http://stackoverflow.com/q/21649366
type: AcceptedAnswer
downvote count: 0
score: 11
has comment: http://stackoverflow.com/comment/32723361
upvote count: 11
has comment: http://stackoverflow.com/comment/32724588
has comment: http://stackoverflow.com/comment/32723714
has comment: http://stackoverflow.com/comment/57765346
has body: The problem is, JFrame uses a BorderLayout, which will try and size the content to fit the parent container. While BorderLayout will try and use the preferred size as a hint, if the available space is greater or less then, it will automatically adjust to allow the center content (the default position) to fill the entire available space of the parent container. You could try using a FlowLayout or GridBagLayout which is more likely to honour the preferred size in more situations Take a look at How to layout components on containers for more details
type: Answer
has comment: http://stackoverflow.com/comment/57772973
accepted answer of: http://stackoverflow.com/q/21649366

http://stackoverflow.com/comment/32671165
comment on: http://stackoverflow.com/q/21621449
score: 0
type: Comment
type: QuestionComment
has text: It works fine. Is there any thing wrong with the grammar?

bufferedimage
tags question: http://stackoverflow.com/q/21554562
tags question: http://stackoverflow.com/q/21576096
tags question: http://stackoverflow.com/q/21633505
tags question: http://stackoverflow.com/q/21584962
tag name: bufferedimage
tags question: http://stackoverflow.com/q/21517825
tags question: http://stackoverflow.com/q/21568851
tags question: http://stackoverflow.com/q/21540378
type: Tag
tags question: http://stackoverflow.com/q/21539167
tags question: http://stackoverflow.com/q/21557521

http://stackoverflow.com/comment/32739797
type: Comment
comment on: http://stackoverflow.com/a/21660888
type: AnswerComment
has text: I'm not certain what Eclipse does. It's clear that the aspect code isn't woven into your code. How exactly do you run this in Eclipse?
score: 0

http://stackoverflow.com/comment/32665360
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21596080
has text: possible duplicate of [How to generate CDATA block using JAXB?](http://stackoverflow.com/questions/3136375/how-to-generate-cdata-block-using-jaxb)

http://stackoverflow.com/comment/32710458
comment on: http://stackoverflow.com/q/21633242
has text: I have edited the post don't hesitate to ask me questions on the code ;)
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21638330
answer count: 2
has comment: http://stackoverflow.com/comment/32702274
accepted answer: http://stackoverflow.com/a/21638568
tagged with: arrays
has answer: http://stackoverflow.com/a/21638448
tagged with: sorting
linked to: http://stackoverflow.com/q/21608646
score: 0
possible better answer: http://stackoverflow.com/a/21638448
has body: Suppose I have the following setup: double[] vectorUsedForSorting = new double[] { 5.8,6.2,1.5,5.4 } double[] vectorToBeSorted = new double[] {1.1,1.2,1.3,1.4} I would like to sort vectorToBeSorted based on the natural numerical ordering of vectorUsedForSorting. For example, the natural ordering would be [1.5,5.4,5.8,6.2] which corresponds to indices [2,3,0,1], which would mean I want the output of the sorting function to be [1.3,1.4,1.1,1.2]. How do I do this in the most absolute efficient/fast possible way? I am mostly concerned with time-complexity since I will be doing this for 1,000,000 length arrays. A large bonus will be awarded to a fast/efficient answer.
favorite count: 0
has comment: http://stackoverflow.com/comment/32701157
has answer: http://stackoverflow.com/a/21638568
type: AnsweredQuestion
tagged with: performance
upvote count: 3
tagged with: java
downvote count: 3
has title: How to efficiently sort one array by another
type: Question

http://stackoverflow.com/q/21665694
answer count: 0
type: UnansweredQuestion
tagged with: spring
tagged with: model-view-controller
has comment: http://stackoverflow.com/comment/32748697
has comment: http://stackoverflow.com/comment/32825616
tagged with: java
has body: I have 2 projects: The imported project from spring starting guides Another project which has the same directory structure and the same code The first one works but the second one gives me a 404 error. I have print screened the directory structure for both of them. Here is the PostController.java code: package Post; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class PostController { @RequestMapping("/post") public String index(Model model) { System.out.println("Template's fault"); return "index_posts"; } } Here is the GreetingController.java code: package hello; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @Controller public class GreetingController { @RequestMapping("/greeting") public static String index(@RequestParam(value="n1",required=false,defaultValue="1")String n1,@RequestParam(value="n2",required=false,defaultValue="2")String n2,Model mod) { MathApp mathapp = new MathApp(n1,n2); int result = mathapp.addNumbers(); mod.addAttribute("result", result); return "greeting"; } } Here is the code that both Application.java files share ( exception being the package): package demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.ComponentScan; @ComponentScan @EnableAutoConfiguration public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } The blog when run gives a 404 error while the gs-serving-web-content-inital when run works like a charm. The MathApp in GreetingController is simply a model and does not affect the app. The pom.xml is quite the same exception being that mysql dependencies are loaded int…
type: Question
score: 0
has comment: http://stackoverflow.com/comment/32749676
has title: Spring 404 failed routing?

http://stackoverflow.com/comment/32567423
score: 0
type: Comment
has text: Can I pass that to a `TransactionAwareContextSource`? From the JavaDoc it looks like I should be able to.
comment on: http://stackoverflow.com/a/21562567
type: AnswerComment

http://stackoverflow.com/q/21624137
answer count: 0
upvote count: 2
tagged with: wcf
type: UnansweredQuestion
score: 2
tagged with: c#
tagged with: java
has comment: http://stackoverflow.com/comment/32682846
type: Question
tagged with: duplex
tagged with: interop
has body: I want a pub/sub wcf service in C# and I want to connect to it with a android java app. If i make a WCF connection using webHttpBinding it can talk with my android device but webHttp is not duplex. If i use wsDualBinding or netTcpBinding I have a duplex connection but I can not use Java (android). Which binding do I need to use if I want duplex and interoperability?
downvote count: 0
has title: Which binding to use wcf duplex c# to java?
favorite count: 0

http://stackoverflow.com/comment/32655041
score: 0
type: Comment
has text: Thanks for you response, but I still can't find a 'project.properties' files in .idea. And in any of my classes there is zero reference to android.util.log. I have only created 1 class personally, the rest was created by Android Studio. I'm simply following this guide: https://developers.google.com/chrome/mobile/docs/webview/gettingstarted
comment on: http://stackoverflow.com/a/21612107
type: AnswerComment

http://stackoverflow.com/comment/32513481
score: 4
type: Comment
type: QuestionComment
has text: Use one of the overloaded constructors that accepts a charset name and provide an appropriate charset that contains Cyrillic characters.
comment on: http://stackoverflow.com/q/21532262

http://stackoverflow.com/q/21639254
has comment: http://stackoverflow.com/comment/32703352
answer count: 1
has answer: http://stackoverflow.com/a/21710610
tagged with: tomcat
score: 0
has title: IntelliJ Idea 12 CANNOT run/deploy web application
has body: I have a java application with web module set up in IntelliJ 12. I am trying to run my application from the IDE. However, everytime I hit the run button I get this error Application Server was not connected before run configuration stop, reason: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is: java.net.SocketException: Connection reset] I get the following output as well: [2014-02-07 05:42:22,126] Artifact arisk.dashboard:war: Server is not connected. Deploy is not available. Using CATALINA_BASE: "C:\.IntelliJIdea12\system\tomcat\Unnamed_AtlasRisk" Using CATALINA_HOME: "C:\apps\apache\jakarta\tomcat\" Using CATALINA_TMPDIR: "C:\apps\apache\jakarta\tomcat\temp" Using JRE_HOME: "C:\Program Files\Java\jdk1.7.0_07" Using CLASSPATH: "C:\apps\apache\jakarta\tomcat\\bin\bootstrap.jar" Usage: java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] (to execute a jar file) where options include: -d32 use a 32-bit data model if available -d64 use a 64-bit data model if available -client to select the "client" VM ... See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details. Disconnected from server I am using the following configuration Any idea why is this not running? THANKS
has comment: http://stackoverflow.com/comment/32706928
has comment: http://stackoverflow.com/comment/32707808
accepted answer: http://stackoverflow.com/a/21710610
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/32703493
type: Question
tagged with: intellij-idea

http://stackoverflow.com/q/21631510
tagged with: web-storage
score: 5
has comment: http://stackoverflow.com/comment/33311542
upvote count: 5
tagged with: javascript
has answer: http://stackoverflow.com/a/21979123
has answer: http://stackoverflow.com/a/21922194
answer count: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/32739598
favorite count: 0
has comment: http://stackoverflow.com/comment/32764801
has comment: http://stackoverflow.com/comment/33357689
has comment: http://stackoverflow.com/comment/32764475
has title: Android 4.0 -> 4.3 (included) - Web storage lost between webview pages
tagged with: android
has comment: http://stackoverflow.com/comment/33258928
linked to: http://stackoverflow.com/q/10556111
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21979123
has comment: http://stackoverflow.com/comment/33358832
tagged with: android-webview
has comment: http://stackoverflow.com/comment/32766869
has comment: http://stackoverflow.com/comment/33259001
has body: I'm working on an Android project which relies on the WebView to browse multiple HTML pages stored on the device and submit the inputs toward the webview when it's needed for storing them in a database. Each page contains controls that are bound with jQuery towards previous / next pages, each page contains inputs of differents types (checkboxes, textfields, etc.). The last page contains a Submit buttons that uses the JSInterface to save the results inside a SQLite DB. Another button (in a custom top navigation bar) offers the same system. Results can be modified by accessing the first page with all the saved inputs, a jQuery system will fill the corresponding inputs. For more details, I'm using the SDK 19 and compiling against 4.4.2, but I used to work with the SDK 15 and compiling against 4.2.2 where I didn't have the issue. If someone needs to see what is done, in a simplified system, check this JSBin. The issue I'm using SessionStorage to store the inputs between the pages, I used to work with cookies but they became unreliable when there was over 150 key/values pairs. My problem is that on some devices, the SessionStorage disappear between pages. Test protocol 1st case - Staying on the first page only If I stay on the first page only, fill the inputs then send the results, everything's fine. Coming back for modification offers me a fully filled first page. 2nd case - Moving between pages After filling page 1, I move to page 2 and fill the new inputs then move between pages to see if the inputs are lost on each individual pages. Everything is in place, but if I send the results, only the current page inputs are transmitted. Android versions test results 3.2 - Works 4.1.2 - Doesn't work 4.2.1 - Doesn't work 4.3 - Doesn't work 4.4.2 - Works Tested solutions Overriding the WebViewClient's shouldOverrideUrlLoading method to return False - Doesn't work Using LocalStorage instead of SessionStorage didn't change a thing Insights Switching from sessionStorage to localSto…
tagged with: java
has answer: http://stackoverflow.com/a/22009100
accepted answer: http://stackoverflow.com/a/22009100
type: Question

http://stackoverflow.com/comment/32633527
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21599833
has text: Well Zip4J is a great tool. But the problem is that it extracts the zipped file somewhere on my local drive. So it is not encrypted anymore. I don't see the point of zipping it, if Java needs to unzip it to reach the file..

http://stackoverflow.com/q/21536987
favorite count: 0
has comment: http://stackoverflow.com/comment/32522909
has comment: http://stackoverflow.com/comment/32523562
possible better answer: http://stackoverflow.com/a/56312839
tagged with: android
has answer: http://stackoverflow.com/a/56312839
has comment: http://stackoverflow.com/comment/32522391
has answer: http://stackoverflow.com/a/21537716
type: AnsweredQuestion
tagged with: java
tagged with: http://stackoverflow.com/tag/json
tagged with: gson
upvote count: 1
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/32523481
has comment: http://stackoverflow.com/comment/32522256
accepted answer: http://stackoverflow.com/a/21537716
score: 0
answer count: 2
has title: Parse JSON with Gson. Difficult JSON structure without keys
has comment: http://stackoverflow.com/comment/32523093
has body: How can I create the correct object for the following structure? JSON without any keys and with arrays in arrays in arrays: { "1": [ [ [1.111, 2.222] [1.111, 2.222] ... ], [ [1.111, 2.222] ... ] ], "2": [ [ [1.111, 2.222] ... ], [ [1.111, 2.222] ... ] ], ... }

http://stackoverflow.com/comment/32706033
type: Comment
has text: The more I think about it, the more this seems like the obvious fix. This was where my original approach was headed, but a developer at my workplace recommended just using the line objects. Thanks for your advice!
comment on: http://stackoverflow.com/a/21640717
score: 0
type: AnswerComment

http://stackoverflow.com/a/21586945
has comment: http://stackoverflow.com/comment/32611964
has comment: http://stackoverflow.com/comment/32611317
downvote count: 0
has comment: http://stackoverflow.com/comment/32611678
answers question: http://stackoverflow.com/q/21586765
type: Answer
has comment: http://stackoverflow.com/comment/32611180
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/32611229
has comment: http://stackoverflow.com/comment/32611323
has body: You never add panel2 to anything. A JPanel isn't like a JFrame where setVisible makes it magically appear. You need to add it to a container. Just add it to your Panel. Also avoid using null layouts. Learn to use Layout Managers Also see Initial Threads. You want to run your swing apps from the Event Dispatch Thread like this public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable(){ public void run() { new Frame(); } }); } This looks like a case where you may have been trying to do something along the lines of what a CardLayout achieves. See this example for a basic use. Also see How to Use Card Layout

http://stackoverflow.com/q/21563230
has answer: http://stackoverflow.com/a/21563325
type: Question
has comment: http://stackoverflow.com/comment/32568213
answer count: 7
has comment: http://stackoverflow.com/comment/32568211
has answer: http://stackoverflow.com/a/21563331
has answer: http://stackoverflow.com/a/21563354
score: 0
has body: import java.util.Scanner; public class Testing { public static void main(String[] args) { int i = 0, j = 0; while(i&gt;=0){ Scanner input=new Scanner(System.in); System.out.println("Enter a number:"); i = input.nextInt(); for(;i&gt;0;i--){ for (j=i; j&gt;0; j--){ System.out.print("*"); } System.out.println(" "); } } } } is the code, after I input the number and it prints the result, it should ask me if I want to try again or exit as choice 1.again 2.exit, I'm not sure how to make the code restart from the beginning. Any help would be good.
has answer: http://stackoverflow.com/a/21563706
has answer: http://stackoverflow.com/a/21563384
has title: How to restart the code after a loop
accepted answer: http://stackoverflow.com/a/21563354
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21563419
has answer: http://stackoverflow.com/a/21564069
has answer: http://stackoverflow.com/a/21563419
tagged with: java

http://stackoverflow.com/a/21604224
has comment: http://stackoverflow.com/comment/63287706
has comment: http://stackoverflow.com/comment/32654777
upvote count: 7
type: Answer
has comment: http://stackoverflow.com/comment/32646828
has body: To update UI elements from a background thread, you have to activate either push or polling. The documentation can be found in the vaadin book. https://vaadin.com/de/book/vaadin7/-/page/advanced.push.html In addition to enabling push, you also need to synchronize access to the UI elements as described in section "11.16.3. Accessing UI from Another Thread"
downvote count: 0
score: 7
has comment: http://stackoverflow.com/comment/32675079
has comment: http://stackoverflow.com/comment/32651224
accepted answer of: http://stackoverflow.com/q/21603492
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21603492

http://stackoverflow.com/comment/32508445
type: QuestionComment
comment on: http://stackoverflow.com/q/21520519
has text: how did you get this .xsd file btw - it's not the normal vcloud 1.5 common.xsd schema; that one doesn't have any jaxb: attributes on the schema.
score: 0
type: Comment

http://stackoverflow.com/a/21615948
upvote count: 2
has comment: http://stackoverflow.com/comment/32661666
type: Answer
answers question: http://stackoverflow.com/q/21615919
score: 2
has body: This is probably what you want to do. You're comparing two different things. You want to compare the size // Initalizes all to null while (counter &lt;= size)/ { table[count] = null; counter++; }
downvote count: 0

http://stackoverflow.com/a/21674282
accepted answer of: http://stackoverflow.com/q/21670360
has body: You're getting this error because your SQL statement (which is the result of this statement: insertUpdate = "INSERT INTO ip_discharge (DISCHARGE_ID,ADMISSION_NO , reg_no, DISCHARGE_TEXT , specialization_no , CRITICAL_FLAG , ENTERED_BY , COMPANY_NO, mode_of_discharge, referred_to " + ")values('"+ PK_NO+ "','"+ ADMISSION_NO+ "','"+ REG_NO+ "','" + DISCHARGE_TEXT + "'," + specialization_no + ",'" + CRITICAL_FLAG + "','" + ENTERED_BY + "','" + COMPANY_NO + "','" + mode_of_discharge + "','" + referred_to + "')"; } is getting too long. Building your SQL statement in this way (by concatenating variable values together) is a very bad idea because it negatively impacts performance (you force the database to parse a new statement every time) it allows SQL injection attacks it limits the amount of data you can insert because your SQL statement must not exceed 4000 characters in length Solution: use a Prepared Statement with bind variables instead
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/32842202
score: 1
answers question: http://stackoverflow.com/q/21670360
type: AcceptedAnswer
downvote count: 0

admob
tags question: http://stackoverflow.com/q/21615510
tags question: http://stackoverflow.com/q/21646129
tags question: http://stackoverflow.com/q/21647336
tags question: http://stackoverflow.com/q/21675814
tags question: http://stackoverflow.com/q/21639592
type: Tag
tag name: admob
tags question: http://stackoverflow.com/q/21661625

http://stackoverflow.com/comment/32618700
score: 0
has text: The layout was a little confusing, edits should make it more clear. The Main instance was to use the getTotal() method and such. I use startActivity() in Main to start Second, it's just not shown.
type: Comment
comment on: http://stackoverflow.com/a/21586177
type: AnswerComment

http://stackoverflow.com/comment/32752854
type: QuestionComment
comment on: http://stackoverflow.com/q/21611413
score: 0
has text: @MarcelHöll The server can associate data sockets with command/error sockets by their remote IP address:ports. It certainly should not just rely on accept order.
type: Comment

http://stackoverflow.com/a/21664519
type: Answer
accepted answer of: http://stackoverflow.com/q/21664094
has body: This is what I did to get it working: import java.util.Scanner; public class CalculateBill { public static void main( String[] args ) { double sum = 0; double cost = 0; int items=0; double unitPrice; Scanner scan = new Scanner(System.in); System.out.println("Please enter the name of the item (f to end):"); // changed to f as I don't want to have to type Finish every time String description = scan.next(); while( !description.equals("f") ) { // FIXED System.out.println("Please enter the quantity of " + description + ": " ); items = scan.nextInt(); System.out.println("Please enter the unit price of " + description + ": "); unitPrice = scan.nextDouble(); cost = items*unitPrice ; // FIXED System.out.printf("Cost of %d %s(s) is $%.2f%n", items, description, cost); sum += cost; // FIXED System.out.println("Please enter the name of the item (F to end):"); description = scan.next(); } System.out.printf("The total bill is $%.2f%n", sum); // FIXED } }
answers question: http://stackoverflow.com/q/21664094
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32801041
score: 0

http://stackoverflow.com/comment/32528023
has text: Not sure if I got the quesiotn right, but maybe you're looking for generics?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21540127

http://stackoverflow.com/comment/32490189
type: QuestionComment
has text: 15MB is not that big. Anyway, since line sizes are variable, you have no choice but to iterate through the whole file, counting newline characters.
score: 0
comment on: http://stackoverflow.com/q/21518998
type: Comment

http://stackoverflow.com/q/21552288
upvote count: 1
has answer: http://stackoverflow.com/a/21552643
accepted answer: http://stackoverflow.com/a/21552643
possible better answer: http://stackoverflow.com/a/21552431
favorite count: 0
has comment: http://stackoverflow.com/comment/32547787
tagged with: collections
answer count: 4
has body: I find myself sometimes doing this: List&lt;String&gt; keys = new ArrayList&lt;String&gt;(vii.slots.keySet()); Collections.sort(keys); for(String index : keys) { ... Is there a utlity method (in commons, Guava, wherever) that does this in one line, like: for(String index : sorted(vii.slots.keySet())) { ... Sorry if this is a FAQ but I failed to find this after a bit of web searching and I'm sure a Java guru will answer this in five seconds flat. Thanks
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/21552431
type: Question
has answer: http://stackoverflow.com/a/21552530
has title: Java: Utility function to create a new sorted list
has answer: http://stackoverflow.com/a/21552490
has comment: http://stackoverflow.com/comment/32547709

http://stackoverflow.com/comment/32561564
type: Comment
comment on: http://stackoverflow.com/a/21559186
has text: I'm not getting the input from user. I'm passing it
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32568030
has text: Im sorry, what? The size n*n is only 2^0, 2^1, 2^2... 2^n. It would be a lot harder to go outside of this, so we are allowed to create the code to only work with the power of 2.
type: Comment
comment on: http://stackoverflow.com/a/21562900
score: 0
type: AnswerComment

http://stackoverflow.com/a/21608969
downvote count: 0
answers question: http://stackoverflow.com/q/21606034
score: 1
has body: You just need to create one new Computer as: Computer c = new Computer(computer_name,ip_address,ip_address ,login, password ); and one Application as: Application a = new Application(app_name,vendor_name,license_required ); Then you will do: ComputerApp ca = new ComputerApp(a,c); and then you can persist it as Janus mentioned. Hibernate will take care of the foreign keys since you will pass computer c and application a as parameters in the constructor
upvote count: 1
type: Answer

http://stackoverflow.com/comment/32722800
score: 0
type: AnswerComment
has text: @KnowledgeGeek: see edit to answer. Remember garbage in == garbage out. The object will only hold the data you give it.
comment on: http://stackoverflow.com/a/21651285
type: Comment

http://stackoverflow.com/q/21540971
downvote count: 0
possible better answer: http://stackoverflow.com/a/21541038
favorite count: 0
has comment: http://stackoverflow.com/comment/32529416
has answer: http://stackoverflow.com/a/21541034
accepted answer: http://stackoverflow.com/a/21541034
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32529467
score: 1
tagged with: java
upvote count: 1
has answer: http://stackoverflow.com/a/21541038
type: Question
tagged with: recursion
tagged with: arrays
tagged with: sorting
has title: Sorting an array recursively in Java with even numbers appearing in front of array.
has body: I'm using a method to sort out an array with even numbers coming out in the front and odd numbers in the back of the array. My assignment dictates that i accomplish this using recursion. When I try to print the sorted out array it just prints out the array unsorted. What am i doing wrong? The left variable starts at index 0 and the right variable starts at the end of the index. They are then both compared, if left is an odd number and right is an even number then they swap values. If left turns out to be an even number then no swap takes place and it points at the next index in the array. If right turns out to be an odd number then no swap takes place and it points at the next index in the array. It does this until all the even numbers are on the right of the array. I'm getting a "Exception in thread "main" java.lang.StackOverflowError". import java.util.*; public class Problem2{ //i=left //j=right //first i tried to shift the whole thing //have all even numbers pop to the front of array when even public static int[] callme(int[] arry, int left, int right){ int temp; if(left&gt;=right) //base case, return array return arry; else if(arry[left]%2!=0 &amp;&amp; arry[right]%2==0){//if match, do the swap temp=arry[left]; arry[left]=arry[right]; arry[right]=temp; return callme(arry, left++, right--); } else{ if(arry[right]%2!=0){//if right side is on odd #, then decrease index return callme(arry, left, right--); } if(arry[left]%2==0){//if left side is on even #, then increase index return callme(arry, left++, right); } } return arry; } public static void main(String[] args){ //int index=0; int[] arry={3,5,6,8}; int[] newarry=callme(arry, 0, arry.length-1); System.out.print("The new sorted array is: "); for(int i=0; i&lt;newarry.length;i++){ System.out.print(newarry[i]+" "); } } }
answer count: 2

google-oauth
type: Tag
tags question: http://stackoverflow.com/q/21519758
tags question: http://stackoverflow.com/q/21556294
tag name: google-oauth

http://stackoverflow.com/comment/32534857
has text: Yes that is what I want since I am passing only 9787458451. That is for example. If I pass both 9787458451 & 9784548745 with % (like) in the input comparable value then it will return both. My question is how to do that like & in both in hibernate?
comment on: http://stackoverflow.com/q/21544311
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21525743
has comment: http://stackoverflow.com/comment/32502213
has comment: http://stackoverflow.com/comment/32502840
has comment: http://stackoverflow.com/comment/32501971
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32501913
score: 2
has title: How to show AlertDialog when application is relaunched which previously exited using home button
downvote count: 0
favorite count: 0
type: Question
upvote count: 2
tagged with: android
has body: I am new to Android I am developing an application in API level 2.2. In my application whenever I press Home button it forces my app to exit. When I relaunch that app by clicking on its icon, it starts from where it exited. I used CountDownTimer in my application and what i want is showing an Alert Dialog when relaunched. protected void onResume() { AlertDialog.Builder alertDialog = new AlertDialog.Builder(StartActivity.this); alertDialog.setMessage("Resume Current Excersize ?"); alertDialog.setPositiveButton("OK",new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog,int which) { startCounterTime();//my method .... } }); alertDialog.show(); }
tagged with: dialog
tagged with: java

http://stackoverflow.com/a/21652558
has comment: http://stackoverflow.com/comment/32725255
has body: Ok, so this is how I resolved this.. In my Mercedes class I created a method called calc. Inside the method I called: System.out.print(super.calcMPG(miles,gallons)); Back in my main method I called mCar.calc(); This way it successfully calculated all the data and printed it.
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/32725335
answers question: http://stackoverflow.com/q/21652465

http://stackoverflow.com/comment/32687346
type: Comment
has text: And if I remove the `assert` and throw an exception in the default branch, would you define your own Exception-class for that or would you choose a predefined one (if, which)? Additionally, would you handle the `Exception` somewhere or would you pass it to the JVM? Last, should the `assert` before the switch not be a good idea, because it really is an assertion to catch logic failure, because it is not possible, that the value differs from those checked by the assertion if the logic is correct, so it is just for development purposes and would not get activated in the build.
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/21631098

http://stackoverflow.com/comment/32586048
has text: listen to the _editValid_ property of the textfield as [outlined in a recent QA](http://stackoverflow.com/a/20906048/203657)
score: 1
comment on: http://stackoverflow.com/q/21572055
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21621466
has body: If you are not using libgdx at the moment it will be hard to port it to libgdx. May be a big part of your game has to be rewritten. But if you are allready using libgdx for the desktop version of your game you only have to handle the different input type (most times on android phones you use touch input instead of keyboard). If you are using libgdx but you are not using camera, you should definitly modify your game to use camera. By doing this you do not depend on screen aspect ration (One possible solution). Also you should then keep in mind, that on android the method pause() is called when call is incoming or homebutton is pressed and resume() is called when user returns to game. Hope this helps.
has comment: http://stackoverflow.com/comment/33690065
type: Answer
has comment: http://stackoverflow.com/comment/32701286
has comment: http://stackoverflow.com/comment/33712807
score: 0
has comment: http://stackoverflow.com/comment/33732332
has comment: http://stackoverflow.com/comment/32702263
answers question: http://stackoverflow.com/q/21609753

http://stackoverflow.com/q/21535882
has comment: http://stackoverflow.com/comment/32552917
has comment: http://stackoverflow.com/comment/32520750
upvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/32531732
score: 1
tagged with: java
tagged with: hibernate
has body: I'm having errors when invoking refresh method. I have the following tables: Ontology, Publication and ontology_by_publication. This is ontology's pk: ontology_id | auto-increment This is publication's pk: publication_id | auto-increment This is ontology_by_publication pk: publication_publication_id, ontology_ontology_id, ontology_by_publication_id The column ontology_by_publication_id has auto-increment set. My OntologyByPublication looks like this: @Entity @Table(name = "ontology_by_publication") public class OntologyByPublication implements Serializable { /** * */ private static final long serialVersionUID = -7427863218422284148L; @EmbeddedId private OntologyByPublicationId ontologyByPublicationId; @Column(name = "description") private String description; @Column(name = "current_price") private Double currentPrice; @MapsId(value = "ontologyId") @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "ontology_ontology_id") private Ontology ontology; @MapsId(value = "publicationId") @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "publication_publication_id") private Publication publication; getters - setters This is the @Embeddable Class: @Embeddable public class OntologyByPublicationId implements Serializable { /** * */ private static final long serialVersionUID = 1L; @Column(name = "ontology_by_publication_id") @GeneratedValue(strategy = GenerationType.IDENTITY) private Long ontologyByPubId; @Column(name = "publication_publication_id") private Long publicationId; @Column(name = "ontology_ontology_id") private Integer ontologyId; I invoke the method below for persisting an OntologyByPublication object: public OntologyByPublication saveOntologyByPublicationRefresh( OntologyByPublication ontologyByPublication) { try { em.persist(ontologyByPublication); em.flush(); em.refresh(ontologyByPublication); return ontologyByPublication; } catch (Exception ex) { return null; } } When the line containing em.refresh gets executed, this exception is thrown: javax.persisten…
tagged with: jpa
downvote count: 0
has comment: http://stackoverflow.com/comment/32520784
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32552674
has comment: http://stackoverflow.com/comment/32546200
tagged with: spring
has comment: http://stackoverflow.com/comment/32532828
answer count: 0
has title: Error with EmbeddedId when invoking refresh method (Spring + JPA 2 hibernate)

http://stackoverflow.com/q/21599762
tagged with: java
has comment: http://stackoverflow.com/comment/32642214
has title: Can I write a GWT application together with my normal Java application?
type: Question
has body: I already have an Java application running on client site. This application currently does not have any UI. What it does is just transforming data for the client behind the scene. We need to regularly upgrade the application. Now we would like to add a UI using GWT. My question is Can I include GWT directly into my current application, as a whole? I mean, my current Java application start from main(). On client side, we just execute java Application (simply say). After we have our GWT part, we really want everything still the same. On client side, we don't need to let client or we ourselves install many new things. So ideally, after we finish our GWT part, for client, still, our application is one application and the way to launch is only java Application We don't want to tell client that we need a TomCat server to be seperately installed. We don't want client feel troublesome and it seems now we need to maintain multiple packages, etc.
has answer: http://stackoverflow.com/a/21603696
has comment: http://stackoverflow.com/comment/32634102
answer count: 1
score: 0
type: UnansweredQuestion
tagged with: gwt
has comment: http://stackoverflow.com/comment/32633699

http://stackoverflow.com/q/21515341
answer count: 1
tagged with: rotation
has title: Rotate a Unit Vector by a Given Quaternion
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21515531
has comment: http://stackoverflow.com/comment/32483939
type: Question
has comment: http://stackoverflow.com/comment/32483800
accepted answer: http://stackoverflow.com/a/21515531
tagged with: opengl
score: 0
tagged with: quaternions
tagged with: math
tagged with: java
has body: I am attempting to calculate the unit vector which points out of my opengl camera. Given a rotation quaternion (w,x,y,z), how would I calculate the rotation of a unit vector around that quaternion? In this case, the unit vector can be limited to (0,0,-1). EDIT: Final solution For rotation of (0,0,1): vec.x=2*x*z - 2*y*w; vec.y=2*y*z + 2*x*w; vec.z=1 - 2*x*x - 2*y*y; Note that the matrix needs to be transposed for use with OpenGL.

http://stackoverflow.com/comment/32537446
type: AnswerComment
score: 0
has text: ^ makes it match only abc at the begining
type: Comment
comment on: http://stackoverflow.com/a/21546124

http://stackoverflow.com/comment/32550150
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21553562
has text: thx..i have missed one more line in my code..i will edit it and put some more details.

http://stackoverflow.com/comment/32598165
type: Comment
type: QuestionComment
score: 0
has text: I now return a List with `public List<DrawFile> getMyDrawsAsList();` but I got a new Exception: `org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property 'myDrawsAsList[0]' of bean class [com.entity.Order3d]: Getter for property 'myDrawsAsList' threw exception; nested exception is java.lang.reflect.InvocationTargetException `
comment on: http://stackoverflow.com/q/21579461

http://stackoverflow.com/comment/32667758
type: AnswerComment
score: 0
type: Comment
has text: it works, thank you. But why do you use final in the parameter and currentVal within the method, why is it better here?
comment on: http://stackoverflow.com/a/21619221

http://stackoverflow.com/q/21650664
has title: springframework.org is down
tagged with: glassfish
favorite count: 0
has comment: http://stackoverflow.com/comment/32722891
linked to: http://stackoverflow.com/q/12350673
has comment: http://stackoverflow.com/comment/32725164
answer count: 0
upvote count: 2
type: UnansweredQuestion
tagged with: spring
type: Question
score: 2
tagged with: java
has body: I have a Java EE application on Glassfish 4 which uses org.springframework in maven. After rebooting the server, glassfish won't start and give the following error: [2014-02-09T03:59:41.284+0900] [glassfish 4.0] [WARNING] [] [org.jboss.weld.Bootstrap] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1391885981284] [levelValue: 900] [[ WELD-001210 Warning when validating file: (some_directory)/glassfish4/glassfish/domains/domain1/applications/service-1.0/WEB-INF/beans.xml@29 against xsd. schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans-3.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not &lt;xsd:schema&gt;.]] [2014-02-09T03:59:41.820+0900] [glassfish 4.0] [WARNING] [] [org.jboss.weld.Bootstrap] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1391885981820] [levelValue: 900] WELD-001208 Error when validating file:(some_directory)/glassfish4/glassfish/domains/domain1/applications/service-1.0/WEB-INF/beans.xml@38 against xsd. src-resolve: Cannot resolve the name 'beans:identifiedType' to a(n) 'type definition' component. It turned out that http://springframework.org is offline, and as the result I am not able to boot glassfish because the following file is missing: http://www.springframework.org/schema/beans/spring-beans-3.0.xsd It seems that I have to wait springframework.org to come back until I can start my Glassfish server. I am wondering is there any way to prevent this from happening in the future? For example, is there any way to save all needed files from springframework.org to local directory so that my website will not be broken because springframework.org is down?
downvote count: 0

http://stackoverflow.com/q/21581474
linked to: http://stackoverflow.com/q/4260723
has answer: http://stackoverflow.com/a/21581554
has comment: http://stackoverflow.com/comment/32600768
type: UnansweredQuestion
score: 1
upvote count: 1
has answer: http://stackoverflow.com/a/21581751
type: Question
has answer: http://stackoverflow.com/a/21581511
tagged with: java
answer count: 6
tagged with: null
has answer: http://stackoverflow.com/a/21581499
downvote count: 0
has body: The following compiles: System.out.println("true" + null); which I assume is because the existence of a string, converts "null" to a string as well. However, since this works: System.out.println(true); It would seem that the following would also compile, since apparently "true" functions as a string. System.out.println(true + null); However, it doesn't compile. Can anyone explain?
has title: How come you can print: "true" + null but not: true + null?
favorite count: 0
has answer: http://stackoverflow.com/a/21581632
has answer: http://stackoverflow.com/a/21581593

http://stackoverflow.com/a/21614740
has body: Not all attachments have a filename. You need to handle that case. And you don't need to decode the filename.
has comment: http://stackoverflow.com/comment/32663110
type: Answer
score: 0
answers question: http://stackoverflow.com/q/21598172

http://stackoverflow.com/q/21609271
has answer: http://stackoverflow.com/a/21631388
tagged with: java
type: Question
tagged with: properties-file
has answer: http://stackoverflow.com/a/21609476
score: 10
has body: I have my colour.roperties file as rose = red lily = white jasmine = pink I need to get the value for colour as String flower = runTimeFlower; @Value("${flower}) String colour; where flower value we will get at runtime. How can I do this in java Spring. I need to get a single value (from among 50 values defined in the properties file )at runtime based on the user input. If i cannot use @Value , Could you tell me other ways to handle this please?
upvote count: 11
answer count: 3
has answer: http://stackoverflow.com/a/21609454
downvote count: 1
has title: Get the values from the properties file at runtime based on the input - java Spring
favorite count: 0
type: UnansweredQuestion
tagged with: spring

http://stackoverflow.com/q/21605665
has comment: http://stackoverflow.com/comment/32642916
has comment: http://stackoverflow.com/comment/32643493
has comment: http://stackoverflow.com/comment/32642971
has comment: http://stackoverflow.com/comment/32643609
has comment: http://stackoverflow.com/comment/32643311
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/32642818
favorite count: 0
has comment: http://stackoverflow.com/comment/32643398
has body: I have a small java application in which i want to put some data and it's columns inside an existing JTable. So here is my columns and data; String[][] data; // this object gets it's contents from another function String[] columns={"Name","Value"}; //these are the columns that should be added to JTable So what should i do to add and see the data inside "existing" JTable? I don't want to create a dynamic JTable. EDIT: I wrote this into the function that fills my variables above. How can i refresh my JTable after that? tblSonuc=new JTable(data,columns);
has comment: http://stackoverflow.com/comment/32643228
has answer: http://stackoverflow.com/a/21605879
upvote count: 1
possible better answer: http://stackoverflow.com/a/21605778
tagged with: swing
has answer: http://stackoverflow.com/a/21605778
has comment: http://stackoverflow.com/comment/32643692
type: AnsweredQuestion
tagged with: java
has title: Java - Adding columns and data into existing JTable
type: Question
has comment: http://stackoverflow.com/comment/32643129
answer count: 2
accepted answer: http://stackoverflow.com/a/21605879

http://stackoverflow.com/comment/32493540
has text: @ajb Only if the other top-level class is effectively private (it can't be referred to from outside the file, even in the same package).
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21520693
type: Comment

http://stackoverflow.com/a/21614028
downvote count: 0
score: 16
has body: In general, an access to an instance variable (of the this object) requires an aload_0 (to load this to the top of the stack) followed by getfield. Referencing a local variable requires only the aload_n to pull the value out of its assigned location in the stack. Further, getfield must reference the class definition to determine where in the class (what offset) the value is stored. This could be several additional hardware instructions. Even with a JITC it's unlikely that the local reference (which would normally be zero/one hardware operation) would ever be slower than the instance field reference (which would have to be at least one operation, maybe 2-3). (Not that this matters all that much -- the speed of both is quite good, and the difference could only become significant in very bizarre circumstances.)
upvote count: 16
type: Answer
answers question: http://stackoverflow.com/q/21613098

http://stackoverflow.com/a/21663792
type: Answer
answers question: http://stackoverflow.com/q/21657226
has body: So this is what I ended up doing to get the program to work import java.util.Scanner; public class Ch2PP11BinaryToDecimal { public static void main (String [] args) { System.out.println("Hello, I am so glad you stopped by my little place I call home."); System.out.println("I have been told I have many talents, but the one that I can do for you now."); System.out.println("What I would like you to do is enter a 4-byte binary number and I will convert it for you into decimal."); try { //thread to sleep for the specified number of milliseconds Thread.sleep(5000); } catch (java.lang.InterruptedException ie) { } System.out.println("..... Oh you don't know what a 4-byte binary number is?"); System.out.println("That is just a 4 digit number consisting of any combination of 1's and 0's."); System.out.println("i.e. 0001 or 1111 or 1010 etc..."); System.out.println("So go ahead and enter any 4 digit number in the space below and I will convert it to its binary counterpart."); String binaryNumber; int eights, fours, twos, ones, decimalNumber; // declaration of the integer variables Scanner keyboard = new Scanner(System.in); binaryNumber = keyboard.nextLine(); decimalNumber = 0; decimalNumber = decimalNumber+(binaryNumber.charAt(0)-'0')*8; decimalNumber = decimalNumber+(binaryNumber.charAt(1)-'0')*4; decimalNumber = decimalNumber+(binaryNumber.charAt(2)-'0')*2; decimalNumber = decimalNumber+(binaryNumber.charAt(3)-'0')*1; System.out.println("You entered " + binaryNumber); // confirmation of the input System.out.println("Abra-Cadabra"); System.out.println("Bippity Boppity"); System.out.println("Beep, Bop, Boop, eeerrrrr"); try { //thread to sleep for the specified number of milliseconds Thread.sleep(5000); } catch (java.lang.InterruptedException ie) { } System.out.println("Now that is done the results is "); System.out.println(decimalNumber); } }
score: 0

http://stackoverflow.com/q/21537025
tagged with: bufferedwriter
has comment: http://stackoverflow.com/comment/32522627
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/21537145
answer count: 2
has comment: http://stackoverflow.com/comment/32522896
has body: try { File file = new File(filePath+"usedcommands.txt"); if (!file.exists()) { file.createNewFile(); } FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); bw.write(input+"\n"); bw.close(); } catch(Exception e) { System.out.println("can't write to usedcommands.txt..."); } I'm writing to a txt file, but every time I run through the writing process it overrides what is already written there. How can I change my code so this part of the program doesn't override what is already there?
downvote count: 0
has comment: http://stackoverflow.com/comment/32522410
favorite count: 0
has comment: http://stackoverflow.com/comment/32524305
has comment: http://stackoverflow.com/comment/32522584
has comment: http://stackoverflow.com/comment/32522821
has comment: http://stackoverflow.com/comment/32522667
linked to: http://stackoverflow.com/q/1225146
possible better answer: http://stackoverflow.com/a/21537094
has answer: http://stackoverflow.com/a/21537145
has answer: http://stackoverflow.com/a/21537094
tagged with: text
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32522335
has comment: http://stackoverflow.com/comment/32522753
has comment: http://stackoverflow.com/comment/32522384
upvote count: 1
has title: File Writer overrides previous write Java
type: Question

http://stackoverflow.com/comment/32643712
type: Comment
type: QuestionComment
has text: With the code you posted, I don't get a compilation error.
score: 0
comment on: http://stackoverflow.com/q/21606163

http://stackoverflow.com/q/21532166
type: Question
answer count: 2
tagged with: stack-overflow
has answer: http://stackoverflow.com/a/21532516
favorite count: 0
tagged with: security
has answer: http://stackoverflow.com/a/21559286
upvote count: 3
has body: I develop the container-like application which can accept custom JARs and run some classes from these JAR archives. And I wanr to protect my application from this custom code. I've found SecurityManager and Policy classes there, but I still don't know how to protect my application from stack overflow attacks and so on. I've found Runtime class, but I cannot use the separate process because I need to have the instance of the custom class in my application. What instrument should I use? Or, maybe, I should change the architecture of my application?
has comment: http://stackoverflow.com/comment/32513362
type: UnansweredQuestion
has title: How to protect Java application from internally running custom code?
score: 3
downvote count: 0
tagged with: java
has comment: http://stackoverflow.com/comment/32513391

http://stackoverflow.com/q/21587389
tagged with: regex
duplicate of: http://stackoverflow.com/q/201323
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32612389
has answer: http://stackoverflow.com/a/21589205
type: Question
has answer: http://stackoverflow.com/a/21587439
tagged with: java
has title: Regular Expression To Validate Email Address
has comment: http://stackoverflow.com/comment/32612128
has comment: http://stackoverflow.com/comment/32611880
downvote count: 4
answer count: 3
upvote count: 0
has body: I'm trying to create a regular expression to check to see if a valid email address has been entered. There is something wrong with my regular expression. Here is the source code I'm using: if (!Pattern.matches("^[\\w-\\+]+(\\.[\\w]+)*@[\\w-]+(\\.[\\w]+)*(\\.[a-z]{2,})$", s)) { et.setError("Enter a valid Email Address"); } What am I doing wrong?
possible better answer: http://stackoverflow.com/a/21587425
accepted answer: http://stackoverflow.com/a/21589205
score: -4
has answer: http://stackoverflow.com/a/21587425
favorite count: 0
linked to: http://stackoverflow.com/q/201323
has comment: http://stackoverflow.com/comment/32611925
tagged with: android

http://stackoverflow.com/comment/32609774
type: QuestionComment
has text: I am not that familiar with Java to even know about Serializable row class or a proper TSV parser. Details would be helpful.
score: 0
comment on: http://stackoverflow.com/q/21585925
type: Comment

http://stackoverflow.com/comment/32698409
type: QuestionComment
comment on: http://stackoverflow.com/q/21637070
has text: Also, since it looks you want to execute performance and/or stress testing, you should read this: http://stackoverflow.com/q/504103/1065197.
score: 1
type: Comment

http://stackoverflow.com/a/21527204
has comment: http://stackoverflow.com/comment/32505756
has body: As per my understanding, you are showing the selected value twice. one time by appending ${order.fbMenuName} and another time by iterating the list. Instead of this populate all the values in the dropdown and set the required value as selected. Just write simple condition like the following. <c:forEach var="menu" items="${menu}"> ${menu.fbMenuName} <c:if test="${menu.fbMenuId == order.fbMenuId}"> selected </c:if> </c:forEach>
type: Answer
answers question: http://stackoverflow.com/q/21523751
upvote count: 2
score: 2
has comment: http://stackoverflow.com/comment/32507956
has comment: http://stackoverflow.com/comment/32507090
has comment: http://stackoverflow.com/comment/32506685
downvote count: 0

http://stackoverflow.com/a/21549302
has comment: http://stackoverflow.com/comment/32546663
upvote count: 3
has comment: http://stackoverflow.com/comment/32543646
has comment: http://stackoverflow.com/comment/32544798
has comment: http://stackoverflow.com/comment/32626364
has body: public void test1() { int MAX_VALUE = 1000; HashSet&lt;Integer&gt; hashCodes = new HashSet&lt;Integer&gt;(); int collisions = 0; for (int x = -MAX_VALUE; x &lt; MAX_VALUE; ++x) { for (int y = -MAX_VALUE; y &lt; MAX_VALUE; ++y) { final int hashCode = ((x+MAX_VALUE)&lt;&lt;16)|((y+MAX_VALUE)&amp;0xFFFF); if (hashCodes.contains(hashCode)) collisions++; hashCodes.add(hashCode); } } System.out.println("Collisions: " + collisions + " // Buckets: " + hashCodes.size()); } Prints: Collisions: 0 // Buckets: 4000000
downvote count: 0
has comment: http://stackoverflow.com/comment/32543299
answers question: http://stackoverflow.com/q/21548859
score: 3
type: Answer

http://stackoverflow.com/a/21666344
type: Answer
upvote count: 4
downvote count: 0
score: 4
has comment: http://stackoverflow.com/comment/32749762
has comment: http://stackoverflow.com/comment/32749747
answers question: http://stackoverflow.com/q/21666273
has body: Your method public void addCourse(String course, Double grade) { if(!courses.isEmpty()) { courses.put(course, grade); } } looks funny to me. Do you intend to only add a course if there is already at least one course in the map? This way, how will the first course enter the map? I think you tried to check for the map to exist, but that would be done differently, namely: if (courses == null){ ... } About the division problem look at the other answer from Saposhiente. I would only repeat it...

http://stackoverflow.com/comment/32725034
has text: [Graphics#drawString](http://docs.oracle.com/javase/7/docs/api/java/awt/Graphics.html#drawString(java.lang.String,%20int,%20int)), [Lesson: Getting Started with Graphics](http://docs.oracle.com/javase/tutorial/2d/basic2d/) and the rest of that tutorial wouldn't hurt either, [Performing Custom Painting](http://docs.oracle.com/javase/tutorial/uiswing/painting/) probably wouldn't hurt either
comment on: http://stackoverflow.com/a/21640605
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/21552969
favorite count: 0
tagged with: android
has answer: http://stackoverflow.com/a/23440055
has title: Add a Line/Image above ActionBar
tagged with: android-actionbar
upvote count: 1
linked to: http://stackoverflow.com/q/18736300
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/23440055
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/35398344
type: Question
downvote count: 0
answer count: 1
has body: I want to add a line above the action bar like in the "pocket"-app. How can i do this? Here is a picture for example: Thanks tomtom

http://stackoverflow.com/a/21544128
has comment: http://stackoverflow.com/comment/32534438
upvote count: 6
has comment: http://stackoverflow.com/comment/32534453
has body: List&lt;Integer&gt; values = new ArrayList&lt;&gt;(); for (Map.Entry&lt;Integer, Integer&gt; entry : map.entrySet()) { if (entry.getKey() % 5 == 0) { values.add(entry.getValue()); } } FWIW, a comparable Java 8 approach might look like map.entrySet().stream() .filter(entry -&gt; entry.getKey() % 5 == 0) .map(Entry&lt;Integer, Integer&gt;::getValue) .collect(toList());
score: 6
has comment: http://stackoverflow.com/comment/32534144
accepted answer of: http://stackoverflow.com/q/21544103
has comment: http://stackoverflow.com/comment/32534338
has comment: http://stackoverflow.com/comment/32534248
answers question: http://stackoverflow.com/q/21544103
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32534202
has comment: http://stackoverflow.com/comment/32534190
type: Answer
has comment: http://stackoverflow.com/comment/32534164

http://stackoverflow.com/comment/32491298
type: Comment
type: QuestionComment
has text: What does "dynamic" mean in this case? Does it mean allowing the underlying array to expand in size when full / as needed?
comment on: http://stackoverflow.com/q/21519706
score: 0

http://stackoverflow.com/a/21650207
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21537154
answers question: http://stackoverflow.com/q/21537154
type: AcceptedAnswer
upvote count: 13
type: Answer
has body: Your application is avalibale at http://localhost:8080/HelloWorld as you can see also in your log. entry "register web context: /HelloWorld"
has comment: http://stackoverflow.com/comment/63369722
score: 13

ondraw
type: Tag
tag name: ondraw
tags question: http://stackoverflow.com/q/21550695

http://stackoverflow.com/q/21589159
type: UnansweredQuestion
tagged with: performance
tagged with: java
has comment: http://stackoverflow.com/comment/32706385
has comment: http://stackoverflow.com/comment/32615524
has title: Idenfifying when a object is created using unsafe.allocateInstance()
has answer: http://stackoverflow.com/a/21589474
type: Question
upvote count: 4
downvote count: 0
score: 4
has comment: http://stackoverflow.com/comment/32706014
has body: Just trying to learn on sun.misc.Unsafe low-level java operations. I was reading this article however, my question is related to advantages of using Unsafe. In this example, Player p = (Player) unsafe.allocateInstance(Player.class); Where is the object created? On JVM heap or non-heap direct memory? Are all the operations that are explained in the article non-heap allocations? I ask this because, when you use “new” key-word, its supposed to create an instance on the heap. If it does, then what is the actual advantage, because then, it doesnt by-pass the GC.
has comment: http://stackoverflow.com/comment/32615622
has comment: http://stackoverflow.com/comment/32615615
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/32706440

http://stackoverflow.com/a/21662798
score: 4
type: Answer
answers question: http://stackoverflow.com/q/21662742
upvote count: 4
has comment: http://stackoverflow.com/comment/32743988
has body: You have to release the player OnPause or OnDestroy method. @Override public void onDestroy() { if (mp!= null) mp.release(); }
downvote count: 0
has comment: http://stackoverflow.com/comment/32744173

http://stackoverflow.com/comment/32570633
type: Comment
has text: The point was that no one should expect `final` to prevent the modification of the fields of an object. It should only be expected to prevent the reassignment of the variable to which `final` applies. Thus, your rhetoric on *"you still won't be able to change its address inside the method but its attributes can be changed."* doesn't add anything meaningful to the conversation.
comment on: http://stackoverflow.com/a/21564439
score: 0
type: AnswerComment

http://stackoverflow.com/a/23495979
accepted answer of: http://stackoverflow.com/q/21521756
answers question: http://stackoverflow.com/q/21521756
type: AcceptedAnswer
type: Answer
score: 0
has body: The problem can be corrected using SwingWorker. I is a really effective methood. Detailed help is available here and here

http://stackoverflow.com/a/21592533
score: 0
has body: CAVEAT: This is a bit outside my experience, but if I'm understanding your question correctly... If you have federated the servers as a single cluster, I believe the Intelligent Management tools can take care of copying an equivalent configuration out to all of them. Each would then read the configuration information from their own local copy.
type: Answer
answers question: http://stackoverflow.com/q/21591520
has comment: http://stackoverflow.com/comment/32729487

relative-path
type: Tag
tag name: relative-path
tags question: http://stackoverflow.com/q/21522399
tags question: http://stackoverflow.com/q/21677639

http://stackoverflow.com/comment/32578482
comment on: http://stackoverflow.com/q/21568476
score: 0
type: Comment
type: QuestionComment
has text: I think there is a little confusion here when you do "numList.set(j,0)". you see, j starts from the prime value, not the list index

http://stackoverflow.com/comment/32743842
has text: i have the META-INF folder all the requirement is done and correct , does the problem in version of java i installed in my desktop ?
type: AnswerComment
comment on: http://stackoverflow.com/a/21662374
score: 0
type: Comment

http://stackoverflow.com/comment/32709955
type: Comment
has text: But your both class name is name !! ?
type: QuestionComment
comment on: http://stackoverflow.com/q/21643817
score: 0

http://stackoverflow.com/comment/32760433
type: Comment
comment on: http://stackoverflow.com/a/21672832
score: 0
type: AnswerComment
has text: in general yes, but we do not know what the context is, it may be that "isIncluded" makes more sense ;)

http://stackoverflow.com/comment/32488930
type: Comment
has text: Congratulations you've been bitten by a chameleon question (as was I). Its changed while we were typing our answers
score: 1
comment on: http://stackoverflow.com/a/21518294
type: AnswerComment

iteration
tags question: http://stackoverflow.com/q/21641466
tags question: http://stackoverflow.com/q/21635989
type: Tag
tag name: iteration
tags question: http://stackoverflow.com/q/21592000

http://stackoverflow.com/a/21710387
type: AcceptedAnswer
has body: The easiest way, if performance is not a main concern, is probably XPath. With XPath, you can find nodes and attributes simply by specifying a path. XPathFactory xPathfactory = XPathFactory.newInstance(); XPath xpath = xPathfactory.newXPath(); XPathExpression expr = xpath.compile(&lt;xpath_expression&gt;); NodeList nl = (NodeList) expr.evaluate(doc, XPathConstants.NODESET); The xpath_expression could be as simple as "string(//member/observedProperty/@href)" For more information about XPath, XPath Tutorial from W3Schools is pretty good.
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21534340
score: 6
type: Answer
upvote count: 6
answers question: http://stackoverflow.com/q/21534340

http://stackoverflow.com/a/21548864
upvote count: 1
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/21546770
has body: I think that you ve got to use 5d private double[][][][][] gaborWavelet which is actually calculate the convolution between the image and mother wavelets. private double[] gaborWavelet(int[][] img, int x, int y, int m, int n) { double re = 0; double im = 0; for (int s = 0; s &lt; S; s++) { for (int t = 0; t &lt; T; t++) { re += img[x][y] * selfSimilarGaborWavelets[s][t][m][n][0]; im += img[x][y] * -selfSimilarGaborWavelets[s][t][m][n][1]; } } return new double[]{re, im}; } You have to choose M, N , S, T and the returned wavelets contains two matrices for re and im.

http://stackoverflow.com/comment/32698667
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21636515
has text: It seems so. You can try using http://www.regexplanet.com/advanced/java/index.html instead. It has regex engine used in Java.
type: AnswerComment

http://stackoverflow.com/q/21517025
tagged with: string
favorite count: 0
has comment: http://stackoverflow.com/comment/32486707
accepted answer: http://stackoverflow.com/a/21517059
has comment: http://stackoverflow.com/comment/32486742
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/32486722
has body: I am trying to convert Base64 encoded string (from image) [link to convertor]. Here is how I do this: First I convert the string, which is: String str = [binary] like this: byte[] imageString = str.getBytes("UTF-8"); and then I want to save the file on machine like this: public boolean uploadImage(byte[] imageString, String name, String extension) { BufferedImage image = null; String path = EVENT_FOLDER + name + "." + extension; try { image = ImageIO.read(new ByteArrayInputStream(imageString)); //null returned here ImageIO.write(image, extension, new File(path)); } catch (IOException e) { e.printStackTrace(); return false; } But I am getting null on this line: image = ImageIO.read(new ByteArrayInputStream(imageString)); What did I do wrong??
upvote count: 1
downvote count: 1
type: Question
tagged with: base64
has title: Null returned from ImageIO.read(new ByteArrayInputStream(bs));
tagged with: image
has comment: http://stackoverflow.com/comment/32486714
has comment: http://stackoverflow.com/comment/32486754
has answer: http://stackoverflow.com/a/21517059
score: 0
answer count: 1

http://stackoverflow.com/comment/104416252
score: 0
has text: As far as I can see, @Manoranjan's answer is the only correct one here, even though going via string serialization and back to a map via GSON doesn't seem ideal. It's unfortunate that JSONObject can take a Map as input but not produce one as output.
comment on: http://stackoverflow.com/a/21545023
type: Comment
type: AnswerComment

http://stackoverflow.com/q/21596670
has comment: http://stackoverflow.com/comment/32627649
tagged with: java
has answer: http://stackoverflow.com/a/78337148
has body: The situation: I have parent class PARENT. Several classes which extends PATENT. So question is: in memory is created as much copies of PARENT as there is CHILDS. Or in memory there is only one copy which is used by all CHILDS?
tagged with: memory
type: Question
answer count: 3
has comment: http://stackoverflow.com/comment/32627511
score: 2
downvote count: 0
has answer: http://stackoverflow.com/a/21596942
favorite count: 0
has title: JAVA memory use of extended class
has comment: http://stackoverflow.com/comment/32627570
tagged with: memory-management
upvote count: 2
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21596813
tagged with: extend

http://stackoverflow.com/a/21646722
has comment: http://stackoverflow.com/comment/115262844
answers question: http://stackoverflow.com/q/21613422
accepted answer of: http://stackoverflow.com/q/21613422
has body: You can use property expansion in policy files: For example, permission java.io.FilePermission "${user.home}", "read"; will expand "${user.home}" to use the value of the "user.home" system property. Could you set: permission java.io.FilePermission "${user.home}/AppData/Local/NetBeans/-", "write"; to get what you wanted?
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/32871006
upvote count: 2

http://stackoverflow.com/q/21592186
favorite count: 0
has comment: http://stackoverflow.com/comment/32620186
has answer: http://stackoverflow.com/a/21602800
answer count: 3
has comment: http://stackoverflow.com/comment/32620261
tagged with: recursion
accepted answer: http://stackoverflow.com/a/21592243
tagged with: call
upvote count: 3
has answer: http://stackoverflow.com/a/21592265
tagged with: java
linked to: http://stackoverflow.com/q/16095176
tagged with: methods
has body: public static int m(int i, int j) { if ( i &gt; j) return 0; else { i++; m(i++, j); } return i; } I had two questions. 1.) What is returned by out.print(m(3,8)); and 2.) How many times is the method m called? The answers should be 5 and 7 respectively. When I worked out question 1, I came out with 5 but the way I did it was incorrect because the method was not called 7 times, it was only called twice. The way I did this was I went straight to the else statement since (i &gt; j) was false at the start and method m was called again this time with (4, 8) I figured it was still false so I went back to the line where m is called and the variable i changed to 5 because of the i++ in m(i++, j). After that it would return 5 for the Value of i. That was obviously wrong so I added some out.prints for the values of i throughout the program to see how the value was changing and it went from 3 to 9 with an out.print(i); at the beginning of method m. An out.print(i); right before return i; showed the values started to go backwards from 10 to 5 and the method was called 7 times. How does this work? EDIT: After logging it, I was able to come up with some logic to it but I would like someone to clarify that it is correct. method m is called with 3,8 at the start. After, it calls itself with 4,8 then 5,8....until 9,8 where the if statement becomes true and the method returns 0. It called itself 6 times so it starts go backwards or decrement-ing 6 times so since m(i++, j) is post(the i) then i becomes 10 and 10 is returned, then 9, then 8, then 7, 6, and finally 5. When it returned 10 that was 1, 9 was 2, 8 was 3, 7 was 4, 6 was 5, and 5 was 6. So since it was 6 when i = 5, that was the value that was returned. Is this correct? And if it is, a more in depth explanation would be nice to have.
possible better answer: http://stackoverflow.com/a/21592265
downvote count: 0
type: Question
has answer: http://stackoverflow.com/a/21592243
type: AnsweredQuestion
score: 3
has title: Method calling itself.. recursive?
has comment: http://stackoverflow.com/comment/32620742

http://stackoverflow.com/a/21540623
type: AcceptedAnswer
type: Answer
score: 2
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21540567
answers question: http://stackoverflow.com/q/21540567
upvote count: 2
has body: Let's ignore that fact that you code is incomplete, so it's impossible to know what you are extending from or if you've actually added a KeyListener. KeyListener is notorious for being fickle about it's focus state. Basically, this means, KeyListener will only respond to keystrokes if the component it is registered to is focusable AND has keyboard focus... A better solution would be to use the Key Bindings API, which provides better control over the focus level that will trigger key events. You are also breaking the paint chain. Painting is a complex series of method calls, chaining together to produce the final result. By failing to call super.paint, you've broken this chain, introducing the possibility of paint artifacts. You should also avoid overriding paint generally, but especially of top level containers, like windows, as they are not double buffered. It is recommended that instead, you extend from something JPanel or JComponent and override it's paintComponent method instead. Take a look at Performing Custom Painting for more details. Updated based on seeing full source Avoid AWT based components (like Applet) the API is out of date and not many people use it any more, instead you should consider using a JApplet instead. But personally, I would avoid applets until you have a better understanding of the overall API. Don't call setSize within an applet, the size is determined by the html tag which describes the applet to the browser Your run method is pointless as it doesn't actually do anything useful and may actually be causing your application to "hang" Your update method is only painting the trafficLight BufferedImage, but because you fail to call super.update, nothing else is painted. It would be better to grid rid of it and do your painting in the paint method, but make sure you are calling super.paint. But as I already said, you'd be better of using something like JPanel and overriding it's paintComponent method. Take a look at Creating a GUI with Swing…

http://stackoverflow.com/a/23113441
score: 7
upvote count: 7
has body: I am surprised this question has still not been answered. And though this might not be the exact answer you are looking for, here is my take on things. I have found that using the second approach, MongoFactoryBean, is the best approach. Simply because there are more configuration options. For instance, if you want to set an Exception Translator, you can do so easily with MongoFactoryBean. If I remember correctly, and I may be wrong, the MongoFactoryBean is meant for convenience for MongoDbFactory. Meaning, it adds another layer of abstraction. All in all, go with the second approach.
answers question: http://stackoverflow.com/q/21629500
accepted answer of: http://stackoverflow.com/q/21629500
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/35569208
type: Answer

http://stackoverflow.com/comment/32698852
type: QuestionComment
comment on: http://stackoverflow.com/q/21631399
type: Comment
score: 0
has text: Also Struts2 has an anchor tag, where you can specify properties of the action mapping that would render accordingly the theme you use.

http://stackoverflow.com/comment/32522769
has text: I don't understand what etag values and nginx have to do with Scala enumerations. An etag is a server generated hash value that an HTTP client can use to detect if content has changed.
score: 1
comment on: http://stackoverflow.com/q/21537148
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21588939
type: Answer
answers question: http://stackoverflow.com/q/21588789
has comment: http://stackoverflow.com/comment/32621299
upvote count: 3
has body: This is a broad question, but using swing you could create a JList with your objects contained in them. For the button add new btn you would attach an ActionListener that would essentially have it create a new object and make sure you add this object to the JList. After this set up some behaviors that would allow you to click on the object in list view which would transition/open new swing JPanel which would have a editable textview for your description. Commit all these changes into a database. Of course it is easier said than done. Read up on java swing gui implementation. Here are some resources 1 2 Edit: changed listview to jlist (been working with android lately)
downvote count: 0
score: 3

http://stackoverflow.com/a/22396508
type: Answer
accepted answer of: http://stackoverflow.com/q/21657154
answers question: http://stackoverflow.com/q/21657154
score: 0
has body: Thank you all for all your suggestions! I have found my solution. I copied the entire eclipse and sdk folder to C: Drive inside Program Files and now everything is working fine for me.
type: AcceptedAnswer

http://stackoverflow.com/q/21616059
has comment: http://stackoverflow.com/comment/32661931
has answer: http://stackoverflow.com/a/21616216
downvote count: 0
has body: Well, I need a clarify of what is the importance of the "\n" new line in the String variable here import java.net.*; import java.io.*; public class Whois{ public static void main(String[] args){ try{ Socket soc = new Socket("whois.internic.net",43); InputStream in = soc.getInputStream(); OutputStream out = soc.getOutputStream(); String url = "http://www.infiniteskills.com\n"; byte[] buffer = url.getBytes(); out.write(buffer); int c; while((c = in.read()) != -1){ System.out.print((char)c); } in.close(); out.close(); }catch(IOException e){ System.out.println(e.getMessage()); } } } Note :- without the \n the program doesn't work correctly and no output.
favorite count: 0
tagged with: sockets
has comment: http://stackoverflow.com/comment/32661868
has comment: http://stackoverflow.com/comment/32662152
has comment: http://stackoverflow.com/comment/32661991
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32661918
has answer: http://stackoverflow.com/a/21616758
accepted answer: http://stackoverflow.com/a/21616758
upvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/32662105
tagged with: network-programming
has comment: http://stackoverflow.com/comment/32661947
score: 1
tagged with: java
possible better answer: http://stackoverflow.com/a/21616216
has title: Importance of the new line "\n" in Java networking
answer count: 2

http://stackoverflow.com/a/21674160
answers question: http://stackoverflow.com/q/21673375
type: Answer
has body: Take a look on implementation of getTime() that is located in super class of GregorianCalendar named Calendar: public final Date getTime() { return new Date(getTimeInMillis()); } This means that you should probably try to mock getTimeInMillis() instead: Mockito.when(gregorianCalendar.getTimeInMillis()).thenReturn(date.getTime());
score: 7
upvote count: 7
downvote count: 0

http://stackoverflow.com/comment/32750516
comment on: http://stackoverflow.com/q/21666778
score: 0
type: QuestionComment
type: Comment
has text: my question is that the validator is checking both the digits entered and blank input but if i put CA for state it doesnt move to the next question for my program which would be "Enter address"

http://stackoverflow.com/q/21620723
type: Question
score: 1
tagged with: java
has body: I have an HTTP producer that calls a remote HTTP Server. I need to read the response from the HTTP Server and convert it into json and do some further processing. I am experiencing some challenges dealing with big message bodies. I am not quite sure what the size threshold is. My code look <from uri="restlet:/foo"/> {{ConfigurableURL}}} <to uri="http://dymmyhost"/> ${bodyAs('java.lang.String')} org.json.simple.JSONValue.parse(request.body.trim()) When the size is small enough, this works without problem. When it is big, the body gets truncated in the last transformation. And if I remove org.json.simple.JSONValue.parse from this last transformation, I end up with a error message such as: org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body (expected: 2263; received: 2233 My digging suggested that there is a buffering issue going on. So, I added the parameter disableStreamCache=true to the URL. It did not help. I also replaced the JSON parsing line with a proper Camel unmarshaller: <unmarshal ref="json"/> Still it did not help. I get the exception: Premature end of Content-Length delimited message body. Any clue?
tagged with: apache-camel
has title: Truncated Response with Camel HTTP
downvote count: 0
answer count: 1
favorite count: 0
type: UnansweredQuestion
tagged with: spring
has answer: http://stackoverflow.com/a/21622962
upvote count: 1

http://stackoverflow.com/a/21556767
upvote count: 2
score: 2
has body: You can use Integer as return type and return null when stack is empty. Thanks to @LuiggiMendoza
downvote count: 0
answers question: http://stackoverflow.com/q/21556621
has comment: http://stackoverflow.com/comment/32597779
has comment: http://stackoverflow.com/comment/32556526
type: Answer

http://stackoverflow.com/comment/32537112
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21545734
has text: @RichardLeMesurier can u help me how to convert encoded string into real string/text

http://stackoverflow.com/a/21588536
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32614166
has body: Graphics/Java2D by default never returs reasonable Dimension, result is zero Dimension, you have to override getPreferredSize for JPanel, then getWidth/Height will return correct coordinates for JPanels' size. then to use JFrame.pack() instead of any sizing. override paintComponent for Swing JComponents, instead of paint(), inside paintComponent 1st. code line should be super.paintComponent, otherwise painting cumulated. never to use Thread.sleep(int) in Swing, nor for Custom painting or animations in Java7 and Swing, use Swing Timer instead endless loop stopped by Thread.sleep(int).
answers question: http://stackoverflow.com/q/21588060
type: Answer
accepted answer of: http://stackoverflow.com/q/21588060
score: 8
upvote count: 8

http://stackoverflow.com/a/21636542
has comment: http://stackoverflow.com/comment/32697264
has comment: http://stackoverflow.com/comment/32697973
has body: This is better: protected void makePurchase(int userId, Product item, int quantity) throws ItemNotBuyableException { int id = item.getId(); int count = 0; boolean flag = true; for (int i = 0; i &lt; quantity; i++) { if(!catalog.sellProduct(id)) { flag = false; continue; } count++; } orders.addOrder(new Purchase(new GregorianCalendar(), id, item, item.getPrice(), count, userId)); if (!flag) throw new ItemNotBuyableException(); }
has comment: http://stackoverflow.com/comment/32697604
has comment: http://stackoverflow.com/comment/32697865
has comment: http://stackoverflow.com/comment/32697304
has comment: http://stackoverflow.com/comment/32699071
has comment: http://stackoverflow.com/comment/32698586
score: 0
has comment: http://stackoverflow.com/comment/32697500
answers question: http://stackoverflow.com/q/21636404
type: Answer
has comment: http://stackoverflow.com/comment/32697653
has comment: http://stackoverflow.com/comment/32697659
upvote count: 1
has comment: http://stackoverflow.com/comment/32698419
has comment: http://stackoverflow.com/comment/32697834
has comment: http://stackoverflow.com/comment/32698042
has comment: http://stackoverflow.com/comment/32697809
downvote count: 1
has comment: http://stackoverflow.com/comment/32698642
has comment: http://stackoverflow.com/comment/32698313
has comment: http://stackoverflow.com/comment/32697894

http://stackoverflow.com/a/21588322
score: 0
has body: I agree that you shouldn't use a double to store a money value (although will probably work OK for smaller amounts). The general approach for doing this kind of rounding is double rounded = Math.round(d * 100) / 100.0;
answers question: http://stackoverflow.com/q/21588155
type: Answer

maven
tags question: http://stackoverflow.com/q/21628460
tags question: http://stackoverflow.com/q/21567497
tags question: http://stackoverflow.com/q/21576404
tags question: http://stackoverflow.com/q/21578522
tags question: http://stackoverflow.com/q/21541215
tags question: http://stackoverflow.com/q/21648938
tags question: http://stackoverflow.com/q/21538273
tags question: http://stackoverflow.com/q/21616339
tags question: http://stackoverflow.com/q/21641525
type: Tag
tags question: http://stackoverflow.com/q/21567388
tags question: http://stackoverflow.com/q/21576146
tags question: http://stackoverflow.com/q/21558795
tags question: http://stackoverflow.com/q/21627773
tags question: http://stackoverflow.com/q/21627654
tags question: http://stackoverflow.com/q/21582998
tags question: http://stackoverflow.com/q/21640062
tags question: http://stackoverflow.com/q/21544599
tags question: http://stackoverflow.com/q/21537405
tags question: http://stackoverflow.com/q/21633117
tags question: http://stackoverflow.com/q/21603085
tags question: http://stackoverflow.com/q/21627164
tags question: http://stackoverflow.com/q/21605382
tags question: http://stackoverflow.com/q/21533524
tags question: http://stackoverflow.com/q/21590367
tags question: http://stackoverflow.com/q/21527343
tags question: http://stackoverflow.com/q/21530826
tags question: http://stackoverflow.com/q/21655137
tags question: http://stackoverflow.com/q/21639603
tags question: http://stackoverflow.com/q/21517275
tags question: http://stackoverflow.com/q/21530411
tags question: http://stackoverflow.com/q/21632947
tags question: http://stackoverflow.com/q/21533869
tags question: http://stackoverflow.com/q/21579247
tags question: http://stackoverflow.com/q/21589436
tags question: http://stackoverflow.com/q/21562518
tags question: http://stackoverflow.com/q/21554350
tags question: http://stackoverflow.com/q/21552130
tags question: http://stackoverflow.com/q/21522660
tags question: http://stackoverflow.com/q/21586152
tags question: http://stackoverflow.com/q/21518111
tags question: http://stackoverflow.com/q/21596416
tags question: http://stackoverflow.com/q/21629718
tags question: http://stackoverflow.com/q/21549865
tags question: http://stackoverflow.com/q/21660552
tags question: http://stackoverflow.com/q/21522146
tags question: http://stackoverflow.com/q/21575612
tags question: http://stackoverflow.com/q/21640356
tags question: http://stackoverflow.com/q/21523736
tags question: http://stackoverflow.com/q/21615630
tags question: http://stackoverflow.com/q/21518797
tags question: http://stackoverflow.com/q/21522947
tags question: http://stackoverflow.com/q/21556492
tags question: http://stackoverflow.com/q/21637947
tags question: http://stackoverflow.com/q/21536220
tags question: http://stackoverflow.com/q/21656146
tags question: http://stackoverflow.com/q/21575692
tags question: http://stackoverflow.com/q/21534002
tags question: http://stackoverflow.com/q/21571959
tags question: http://stackoverflow.com/q/21640835
tags question: http://stackoverflow.com/q/21579845
tags question: http://stackoverflow.com/q/21628129
tags question: http://stackoverflow.com/q/21626843
tags question: http://stackoverflow.com/q/21584669
tags question: http://stackoverflow.com/q/21622540
tags question: http://stackoverflow.com/q/21524276
tags question: http://stackoverflow.com/q/21514980
tags question: http://stackoverflow.com/q/21573141
tags question: http://stackoverflow.com/q/21555921
tags question: http://stackoverflow.com/q/21523445
tags question: http://stackoverflow.com/q/21643952
tags question: http://stackoverflow.com/q/21585037
tags question: http://stackoverflow.com/q/21574583
tags question: http://stackoverflow.com/q/21605583
tags question: http://stackoverflow.com/q/21617417
tags question: http://stackoverflow.com/q/21536085
tags question: http://stackoverflow.com/q/21568922
tags question: http://stackoverflow.com/q/21567374
tags question: http://stackoverflow.com/q/21605298
tags question: http://stackoverflow.com/q/21527289

http://stackoverflow.com/q/21647947
has answer: http://stackoverflow.com/a/21648448
linked to: http://stackoverflow.com/q/4388486
accepted answer: http://stackoverflow.com/a/21648448
score: 11
type: AnsweredQuestion
downvote count: 0
has body: I have a problem with lazy loading property in JPA entity. I read many similar questions, but they are related to spring or hibernate and their answears are either not applicable or helpful. The application is JEE with JPA2.1 running on Wildfly application server. There are two entities, DAO session bean and servlet that puts it together: @Entity @Table(name = "base_user") public class User implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") int id; @OneToMany(fetch=FetchType.LAZY, mappedBy="user") List&lt;OAuthLogin&gt; oauthLogins; } @Entity @Table(name = "oauth_login") public class OAuthLogin implements Serializable { @ManyToOne @JoinColumn(name="user_id", nullable=false) User user; } @Stateless(name = "UserDAOEJB") public class UserDAO { @PersistenceContext(unitName="OAUTHDEMO") EntityManager em; public User findById(int id) { User entity; entity = em.find(User.class, id); return entity; } } public class SaveUserServlet extends HttpServlet { @EJB UserDAO userDAO; @Transactional protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { User user = new User(name); user.setEmail(email); System.out.println("Persisting user " + user); userDAO.persist(user); OAuthLogin fbLogin1 = new OAuthLogin(user, OAuthProvider.FACEBOOK, "1501791394"); loginDAO.persist(fbLogin1); User user2 = userDAO.findById(user.getId()); List&lt;OAuthLogin&gt; oauthLogins = user2.getOauthLogins(); When I run this code, it fails with: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: cz.literak.demo.oauth.model.entity.User.oauthLogins, could not initialize proxy - no Session org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:572) org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:212) org.hibe…
tagged with: java
tagged with: hibernate
has comment: http://stackoverflow.com/comment/32717276
type: Question
tagged with: jakarta-ee
possible better answer: http://stackoverflow.com/a/21648154
has answer: http://stackoverflow.com/a/21648154
has answer: http://stackoverflow.com/a/43874577
has title: JPA Lazy Loading
linked to: http://stackoverflow.com/q/12428085
tagged with: jpa
upvote count: 11
answer count: 3
favorite count: 0

http://stackoverflow.com/a/21671083
type: Answer
score: 0
has body: You may be making mistake in creating jar file. Some time it get exported properly but will throw error at runtime. While exporting project, don't forget to remove .project and .classpath option. Go to project explorer> Right Click on your project> Export. You can follow below blog for more information on creating libraries. Please look at step 4 of "Enhancing library feature"Tutorial: How to create java library Please let me know if does not work out.
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21616544
answers question: http://stackoverflow.com/q/21616544

http://stackoverflow.com/comment/32535498
type: Comment
has text: ya use this method setTitle(int titleId) pass in your string id like builder.setTitle(R.string.something);
comment on: http://stackoverflow.com/a/21544729
score: 0
type: AnswerComment

http://stackoverflow.com/a/21549230
upvote count: 1
has comment: http://stackoverflow.com/comment/32544107
score: 1
has comment: http://stackoverflow.com/comment/32544890
downvote count: 0
has comment: http://stackoverflow.com/comment/32544546
has comment: http://stackoverflow.com/comment/32543735
answers question: http://stackoverflow.com/q/21548511
has comment: http://stackoverflow.com/comment/32547312
has body: how does that apply to a thread rather than an object? A thread is not necessarily an object and I can't see what stops another thread from acquiring a reference to safe before the constructor finishes execution. A Thread is always an object in the java.lang.Thread sense, of course. The pattern should not be applied to a thread itself. Instead, it could be applied for cases where a new Thread has to be started "together" with the construction of an object. Starting the thread IN the constructor can allow the reference to the incompletely constructed object to escape. However, with this pattern, the newly constructed instance is trapped in the newInstance method until its construction is entirely complete. (Or to put it that way: I can't imagine how another thread should acquire a reference to the safe instance before its construction is complete. Maybe you can give an example how how you think this might happen.)
type: Answer

http://stackoverflow.com/comment/32654624
type: Comment
comment on: http://stackoverflow.com/a/21611969
type: AnswerComment
has text: Those Queues doesn't seem to have any key for their values.
score: 0

http://stackoverflow.com/comment/32504284
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21527379
score: 3
has text: Thank you, Ahmad. I'm still relatively new to SO and don't have the formatting down pact.

weka
tags question: http://stackoverflow.com/q/21582039
tags question: http://stackoverflow.com/q/21674522
tags question: http://stackoverflow.com/q/21525337
tag name: weka
tags question: http://stackoverflow.com/q/21560146
type: Tag

http://stackoverflow.com/q/21629975
type: Question
score: 3
has body: I'm making an application that uses the dex2jar library to convert a dex file (from an android application package) to a jar file. But the process takes quite long especially due to android.support.x classes. Is there a way to make dex2jar skip certain classes (that we specify) while decompiling ? This is the code that I'm currently using: DexFileReader reader = new DexFileReader(new File(PackageDir)); Dex2jar.from(reader) .reUseReg(reuseReg) .topoLogicalSort(topologicalSort || topologicalSort1) .skipDebug(!debugInfo) .optimizeSynchronized(optmizeSynchronized) .printIR(printIR) .verbose(verbose) .to(file);
tagged with: dex
answer count: 1
downvote count: 0
tagged with: jar
favorite count: 0
has answer: http://stackoverflow.com/a/21634724
has title: How to make dex2jar to skip certain classes while converting dex to jar?
tagged with: android
tagged with: dex2jar
type: AnsweredQuestion
upvote count: 3
tagged with: java
accepted answer: http://stackoverflow.com/a/21634724

http://stackoverflow.com/q/21606060
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32643593
has comment: http://stackoverflow.com/comment/32644016
favorite count: 0
has comment: http://stackoverflow.com/comment/32643980
type: Question
tagged with: android
tagged with: google-cloud-messaging
has comment: http://stackoverflow.com/comment/32643474
has comment: http://stackoverflow.com/comment/32643821
has answer: http://stackoverflow.com/a/21606238
accepted answer: http://stackoverflow.com/a/21606238
score: 0
has comment: http://stackoverflow.com/comment/32643661
upvote count: 1
answer count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/32643526
tagged with: java
has title: Simple way to send push notification using new GCM
has body: I was searched about this , But all tutorials i found is old. I want a simple ways to: Register device using Android &amp; Java and send registration id to my web site to save it. Create page to send messages to all registration ids. Thanks in advance.
has comment: http://stackoverflow.com/comment/32644341

http://stackoverflow.com/comment/32491345
has text: I think that basically what I'm being asked to do is to double the size of the underlying array whenever something is pushed onto the stack, then transfer the contents of the current array into the new one - it's a horrible solution but I am only a beginner in Java.
type: Comment
comment on: http://stackoverflow.com/q/21519706
type: QuestionComment
score: 0

http://stackoverflow.com/comment/32517822
type: QuestionComment
comment on: http://stackoverflow.com/q/21534316
has text: of course there is! :-) http://leonotepad.blogspot.com.br/2014/01/playing-with-antlr4-primefaces.html
score: 0
type: Comment

http://stackoverflow.com/comment/32873816
comment on: http://stackoverflow.com/a/21714396
has text: i will accept your answer as it works flawlessly. but i still dont understand why i saw the error.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/21597830
upvote count: 1
has body: You have a mess of badly indented if statements, so it is very hard to see what happens. Let's indent it properly and add { and } to make it clear what the structure of your code is. if (sentence.charAt(sentence.length()-1) == '?' ) { if (sentence.length( ) %2 == 0) { System.out.println("Yes."); } else if (sentence.charAt(sentence.length()-1) == '?' ) { if (sentence.length( ) %1 == 0) { System.out.println("No."); } else if (sentence.charAt(sentence.length()-1) == '!' ) { System.out.println("Wow."); } else { System.out.println("You always say \"" + sentence + "\"."); } } } Now you see what happens if the sentence does not have a ? at the end: the expression for the first if will evaluate to false and everything else will be skipped.
type: Answer
answers question: http://stackoverflow.com/q/21597735
downvote count: 0
score: 1

http://stackoverflow.com/q/21548404
score: 0
tagged with: java
type: Question
tagged with: rxtx
answer count: 1
has body: I have created application that sends/receives messages using com port. I use rxtx lib for this purpose. When application starts I open com port like: String comportidentifier = "/dev/ttyS0"; CommPortIdentifier portIdentifier = null; portIdentifier = CommPortIdentifier.getPortIdentifier(comportidentifier); if (portIdentifier.isCurrentlyOwned()) { JOptionPane.showMessageDialog(null, "port in use"); } else { SerialPort serialPort = (SerialPort) portIdentifier.open("ReadComPort", 200); } And I close it when programm finishes job. Unexpectedly I found that my comport (the one I have opened) transmits some strange command my code does't sends. I'm usig several libraryes in my code and I don't pass com port variable to them. The only description is that something in system is alsow has opened port and is sends command. But is this possible if I already have opened com port? I suppose that when I have opened port nobody can do that also until I close it. How to describe this situation? When I have change port to /dev/ttyS1 unexpected command was not transmitted.
type: UnansweredQuestion
has title: Is com port opened in exclusive mode
has answer: http://stackoverflow.com/a/21548605

http://stackoverflow.com/comment/32563594
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21529351
has text: http://stackoverflow.com/questions/21559984/retrieve-out-of-range-data-between-two-dates-android you can check my question now copy paste above link sir
type: Comment

http://stackoverflow.com/a/21654288
has body: You should only need to loop through the string once: public static void charCount(String b) { int upper = 0; int a = 0; for (int i = 0; i &lt; b.length(); i++) { char c = b.charAt(i); if (Character.isUpperCase(c)) upper++; if (c == 'a') a++; } System.out.println("There are " + upper + " upper case letters, and " + a + " lower case a's in the String"); }
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21654170

http://stackoverflow.com/q/21541243
tagged with: boolean
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/32529881
has comment: http://stackoverflow.com/comment/32530459
has title: boolean in GUI returns NPE?
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32529884
upvote count: 1
has body: Here is the code: final JRadioButton banking = new JRadioButton("Enable Banking"); banking.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ie) { fish.useBank = banking.isSelected() ? true : false; if(banking.isSelected()) { scroll2.setEnabled(true); } else { scroll2.setEnabled(false); } } }); fish is a reference to the main class, where there is just a simple boolean public boolean useBank; for some reason it always returns with an NPE when I try to use it in other classes. I'm kind of new to Java so any help would be appreciated, thanks.
type: Question
score: 1
tagged with: java

http://stackoverflow.com/a/21591051
answers question: http://stackoverflow.com/q/21590786
has comment: http://stackoverflow.com/comment/32618485
type: Answer
score: 1
has comment: http://stackoverflow.com/comment/32618552
has comment: http://stackoverflow.com/comment/32618600
upvote count: 1
has body: In this case I believe the newInstance method is just a static factory method for the empty constructor so has no effect (though without the source code available we cannot know for sure), i.e. it is probably something like: public static SupportMapFragment newInstance() { return new SupportMapFragment(); } So why does it exist? For consistency with the other newInstance(GoogleMap) method most likely In theory the method could return a sub-class of SupportMapFragment, perhaps one optimised for the device or platform In case any arguments need to be set (perhaps now or in the future) Because of the last point, it is generally a good practice to always use static factories when creating fragments, in the future it could be modified to: public static SupportMapFragment newInstance() { SupportMapFragment fragment = new SupportMapFragment(); Bundle args = new Bundle(); args.putBoolean("secretOptionNotEnabledWithNormalConstructor", true); fragment.setArguments(args); return fragment; }
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21590786

http://stackoverflow.com/comment/32619818
has text: It is weird but I just read that you are using AS. You should indicate that in your posts. I don't know your programming experience but if you are new I, along with many veteran developers and Google, would recommend you use a different IDE for now as it is still new, buggy, and in a pre-lease version. It has many bugs to work out still that you won't get with other IDE's and **if** you are new, it will be hard to tell what are your mistakes and what are bugs in the IDE
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21591422

http://stackoverflow.com/q/21677003
tagged with: java
has comment: http://stackoverflow.com/comment/32767490
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/32767380
has answer: http://stackoverflow.com/a/21677167
has title: different stack for different thread
score: 0
has answer: http://stackoverflow.com/a/21677502
favorite count: 0
has body: I was reading one of the question of multi threading and this question came into my mind,now we know that when one thread need to start an instance of thread class is made, then after we call start method,run method is loaded in class area, and then the other method are called so my question is, when one particular thread is not finishes,and the other thread is called ,its run method is loaded,whether it is loaded into the same class area? now what's the benefit of different stack for different threads? and can a same method be called using different thread concurrently?if yes,how it is possible?
type: UnansweredQuestion
tagged with: multithreading
upvote count: 1
answer count: 4
has answer: http://stackoverflow.com/a/21677140
has answer: http://stackoverflow.com/a/21677083

http://stackoverflow.com/comment/32518049
score: 0
type: Comment
type: QuestionComment
has text: which isn't working button or ZoomControl?
comment on: http://stackoverflow.com/q/21534734

http://stackoverflow.com/a/21589169
answers question: http://stackoverflow.com/q/21589139
has body: Calling toString() on an array object (in your case retString) doesn't print all array entries, instead it prints object address. You should print array entries by iterating over them.
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/32615807
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/32615236

http://stackoverflow.com/q/21652271
type: UnansweredQuestion
score: 0
tagged with: swing
tagged with: java
linked to: http://stackoverflow.com/q/3256269
type: Question
answer count: 1
linked to: http://stackoverflow.com/q/9798375
linked to: http://stackoverflow.com/q/7213178
has title: Java Graphics image refresh rate
has body: I am making a JFrame holding several images that refresh using repaint(). The problem, however, was that the more images I added (or as the area that was being rendered increased) the framerate drastically decreased. I was initially attempting to reduce the lag that Swing's unpredictable Timer experiences, but was unsuccessful. This time, I tried to call repaint() every 10 milliseconds based on system time. (To bypass the timer, desktop.screenPaint.drawWindow(); is called instead of repaint()) while(true) { long starttime = System.currentTimeMillis(); while(System.currentTimeMillis()-starttime &lt; 10) { } desktop.screenPaint.drawWindow(); desktop2.screenPaint.drawWindow(); } Each "desktop" is just one of the draggable windows that you see if you run the code below. I noticed that when only "desktop" is added to "frame," there is no flickering. However, when "desktop2" is also added, flickering does not go away until the time until each refresh is set to 20 or more milliseconds. It is extremely strange, because when I was still using the timer, even thought the wait was set to 10 milliseconds, the framerate would lower to a frame every 20 milliseconds! I tested a little and noticed a trend: you will get flickering until the wait time to the amount of time that the 10 millisecond timer lagged behind. My question: Why is this happening? And is there any way to prevent the flickering, other than going back to the timer? import javax.swing.JFrame; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import javax.swing.SwingUtilities.*; import static java.awt.GraphicsDevice.WindowTranslucency.*; import java.io.File; import java.io.IOException; public class Display extends JPanel { public static int width, height; public static JFrame frame = new JFrame(""); private static int rh = 10; public static Display desktop = new Display(); public static Display desktop2 = new Display(); public static void main(String[] args) { Dimension scree…
tagged with: timer
has answer: http://stackoverflow.com/a/21653145

http://stackoverflow.com/q/21651033
score: 2
has answer: http://stackoverflow.com/a/64541654
tagged with: java
tagged with: selenium
type: Question
answer count: 3
has answer: http://stackoverflow.com/a/21651144
downvote count: 0
favorite count: 0
has body: Im trying to locate an element by xpath using the following path but am receiving the below error. Is it possible for xpath to find this element? Or is this an issue with the driver itself? I want to be able to differentiate between the values in /p[4]/text()[1] and /p[4]/text()[2] .//*[@id='content']/p[4]/text()[1] org.openqa.selenium.InvalidSelectorException: The given selector .//*[@id='content']/p[4]/text()[1] is either invalid or does not result in a WebElement. The following error occurred: InvalidSelectorError: The result of the xpath expression ".//*[@id='content']/p[4]/text()[1]" is: [object XrayWrapper [object Text]]. It should be an element. This is the html for an example. Im trying to verify the text '(extra questions for session)' with /text(). Survey (extra questions for session)
tagged with: xpath
upvote count: 2
type: UnansweredQuestion
has title: WebDriver can't find - is [object XrayWrapper [object Text]
has answer: http://stackoverflow.com/a/21651173
tagged with: selenium-webdriver

http://stackoverflow.com/q/21577493
has title: Why not create an Object[] and cast to a generic type? What's the solution?
has comment: http://stackoverflow.com/comment/32593530
has comment: http://stackoverflow.com/comment/32593193
type: Question
upvote count: 4
answer count: 2
accepted answer: http://stackoverflow.com/a/21577494
linked to: http://stackoverflow.com/q/2927391
has comment: http://stackoverflow.com/comment/32598774
favorite count: 0
has body: Some developers create arrays of generic type by creating an Object[] and casting to the generic type as in this example code: public class ArrTest&lt;E&gt; { public void test(E a){ E[] b = (E[])new Object[1]; b[0] = a; System.out.println(b[0]); } public static void main(String[] args){ ArrTest&lt;String&gt; t = new ArrTest&lt;String&gt;(); t.test("Hello World"); } } That example will work and just has a warning: Type safety: Unchecked cast from Object[] to E[]. Is it discouraged? Is this the best way to create an array of a generic type? Can this cause unexpected results or exceptions if I use this object extensively in my software?
tagged with: generics
downvote count: 2
has answer: http://stackoverflow.com/a/21577494
possible better answer: http://stackoverflow.com/a/21579160
has answer: http://stackoverflow.com/a/21579160
score: 2
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/comment/32751796
comment on: http://stackoverflow.com/q/21667362
type: Comment
type: QuestionComment
has text: Yep, hash maps are very inefficient. Each element is at least three objects, the entry itself, its key, and its value. Even in the most compact JVM that's 48bytes (probably twice that), without even counting the hashtable array itself.
score: 0

http://stackoverflow.com/comment/32542576
score: 0
has text: @LutzHorn Pls have a look now.
type: Comment
comment on: http://stackoverflow.com/q/21548393
type: QuestionComment

http://stackoverflow.com/comment/32610697
has text: Auugh, JB Nizet's and AlexWien's take too much lines... is there some way I can do it with mapping or something?
score: 0
comment on: http://stackoverflow.com/q/21586710
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32735416
type: Comment
has text: @Whoppa If the return type of your method is `Object`. And then you call `get()` method for `MyList<String>`, you would expect it to return a `String`, and store the return value in `String` reference. That is where it will give you compiler error. Try it.
comment on: http://stackoverflow.com/a/21658200
score: 1
type: AnswerComment

http://stackoverflow.com/q/21571759
tagged with: android
tagged with: wizard
favorite count: 0
has answer: http://stackoverflow.com/a/21572008
has title: Android ViewPager guideline
type: UnansweredQuestion
upvote count: 1
downvote count: 1
has body: I'm working on a new application in which i want create a intro guideline or wizard or something like tha with a viewpager style. I need display this "Intro" part only the first time i open the application and then never more. In the last tab i want a button and when tapped it brings me to the real MainActivity in which execute the operations. I'm able to create the ViewPager following this example ViewPager tutorial but i can't understand how pass from those fragments to my MainActivity and never more display those tabs. I don't know if my question is clear. I can create a button in the last fragment and onClick open the New activity.. But what about never more display the "tutorial" intro? Thanks EDIT with button: startAppBtn.setOnClickListener(new OnClickListener() { public void onClick(View v){ Intent startApp = new Intent(getActivity(), MainActivity.class); startActivity(startApp); } });
tagged with: android-fragments
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32583703
tagged with: android-viewpager
answer count: 1
score: 0
has comment: http://stackoverflow.com/comment/32583864

http://stackoverflow.com/comment/32531425
type: Comment
type: AnswerComment
has text: I guess I missed the comment where you stated everything was now working. If you did get it sorted out, you should probably have an answer marked as accepted.
score: 0
comment on: http://stackoverflow.com/a/21539620

http://stackoverflow.com/comment/32505181
type: Comment
has text: @IanRoberts True. Nice point. So even if the *entire* construction hasn't completed, the chained one is at least guaranteed to.
type: AnswerComment
comment on: http://stackoverflow.com/a/21527767
score: 0

http://stackoverflow.com/comment/32708835
type: AnswerComment
type: Comment
has text: Can't i just keep it dynamic? the length is variable
comment on: http://stackoverflow.com/a/21643096
score: 0

http://stackoverflow.com/comment/32757564
comment on: http://stackoverflow.com/a/21583200
score: 0
type: AnswerComment
has text: Can you post `Test.class`?
type: Comment

http://stackoverflow.com/q/21566442
upvote count: 1
has answer: http://stackoverflow.com/a/21620119
tagged with: android-intent
has body: I'm new to Android development. I have used ; I type the number in the EditText, Now i want to get the contact number from my contact list. can someone pls help me to fix this? protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final EditText pnumber= (EditText) findViewById(R.id.editTextPnumber); final EditText gsms= (EditText) findViewById(R.id.editTextSMS); Button sendsms= (Button) findViewById(R.id.buttonSend); sendsms.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub String gPhone= pnumber.getText().toString(); String gSMS= gsms.getText().toString(); try { SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(gPhone, null, gSMS, null, null); Toast.makeText(getApplicationContext(), "SMS Sent ! ", Toast.LENGTH_LONG).show(); finish(); } catch (Exception e) { // TODO: handle exception Toast.makeText(getApplicationContext(), "PLS Enter Again ! ", Toast.LENGTH_LONG).show(); e.printStackTrace(); } } });
tagged with: android-layout
tagged with: java
answer count: 3
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21620119
downvote count: 0
favorite count: 0
type: Question
tagged with: android-listview
tagged with: android
score: 1
has answer: http://stackoverflow.com/a/21566580
has answer: http://stackoverflow.com/a/21568782
has title: (EditText)Android Contact list getting phone number
possible better answer: http://stackoverflow.com/a/21566580

http://stackoverflow.com/comment/105302788
type: AnswerComment
score: 0
type: Comment
has text: https://stackoverflow.com/questions/26995856/strange-behavior-in-sun-misc-unsafe-compareandswap-measurement-via-jmh is a good writeup of how to examine what's going on. Examples of the CAS function can be found at https://www.baeldung.com/java-unsafe and https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/share/classes/java/util/concurrent/atomic/AtomicInteger.java
comment on: http://stackoverflow.com/a/21544890

http://stackoverflow.com/a/21586648
answers question: http://stackoverflow.com/q/21586070
accepted answer of: http://stackoverflow.com/q/21586070
has body: So, I've come up with a solution that gets me around my problem and I'm leaving it here for posterity. The answer doesn't satisfy the "why" of it all, but it does get my application working and it's not really a munge. Instead of injecting UriInfo at the class level, I inject it at the method level. I got the idea from here. Their explanation is that if a method signature might get modified, inject it there. I guess Spring Security is doing that, but I don't understand why that would break something injected at the class level. Working code for posterity: @PreAuthorize("hasAnyRole('ROLE_ANALYST', 'ROLE_DEVELOPER')") @GET @Produces(MediaType.APPLICATION_JSON) public def list(@Context UriInfo ui) { ... }
has comment: http://stackoverflow.com/comment/48569578
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/51886782
downvote count: 0
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/a/42263843
upvote count: 13
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/21579247
score: 13
has body: You only need to delete one folder it is throwing error for. Just go to your M2 repo and org/apache/maven/plugins/maven-compiler-plugins and delete the folder 2.3.2
has comment: http://stackoverflow.com/comment/106885525

http://stackoverflow.com/a/21549507
downvote count: 0
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/21549379
has body: Move it outside the loop.Due to which new instance is created every line out = new PrintWriter(new FileWriter("D:\\outputfile.txt"));

heap-memory
tag name: heap-memory
tags question: http://stackoverflow.com/q/21671725
tags question: http://stackoverflow.com/q/21627177
tags question: http://stackoverflow.com/q/21671993
tags question: http://stackoverflow.com/q/21652280
tags question: http://stackoverflow.com/q/21604595
tags question: http://stackoverflow.com/q/21648822
tags question: http://stackoverflow.com/q/21675709
type: Tag
tags question: http://stackoverflow.com/q/21572564
tags question: http://stackoverflow.com/q/21631167

http://stackoverflow.com/q/21562345
downvote count: 0
score: 1
tagged with: polymorphism
favorite count: 0
type: Question
has comment: http://stackoverflow.com/comment/32566531
has comment: http://stackoverflow.com/comment/32566855
upvote count: 1
has comment: http://stackoverflow.com/comment/32566520
has answer: http://stackoverflow.com/a/21562616
has title: How can I calculate an equation represented by a series of nodes in this Polymorphism exercise?
tagged with: java
has answer: http://stackoverflow.com/a/21562411
linked to: http://stackoverflow.com/q/94361
has body: I'm trying to understand how the code in this Polymorphism exercise works. I think I understand the concept; however, I'm having trouble understanding how to apply it to the equation: 1 + 2 * 3 abstract class Node { abstract double evaluate(); } public class ValueNode extends Node { double value; double evaluate() { return value; } } public abstract class OpNode extends Node { Node left; Node right; abstract double evaluate(); } public class MultiplicationNode extends OpNode { double evaluate() { return left.evaluate() * right.evaluate(); } } public class AdditionNode extends OpNode { double evaluate() { return left.evaluate() + right.evaluate(); } }
possible better answer: http://stackoverflow.com/a/21562411
accepted answer: http://stackoverflow.com/a/21562616
has comment: http://stackoverflow.com/comment/32566567
answer count: 2
type: AnsweredQuestion

http://stackoverflow.com/comment/32566352
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21558798
has text: you are right. I was able to resolve it y'day by just sending the plain json. I wish you had given me this suggestion yday and saved me a lot of trouble
type: AnswerComment

osx-mavericks
type: Tag
tags question: http://stackoverflow.com/q/21547115
tag name: osx-mavericks
tags question: http://stackoverflow.com/q/21605298

http://stackoverflow.com/a/46402275
has body: The accepeted answer does not work with formula cells (in the result String you get the formula, not the result of the formula). Here is what worked for me in every case: final XSSFWorkbook workbook = new XSSFWorkbook(file); final DataFormatter dataFormatter = new DataFormatter(); final FormulaEvaluator objFormulaEvaluator = new XSSFFormulaEvaluator(workbook); final Cell cell = ...; objFormulaEvaluator.evaluate(cell); final String cellValue = dataFormatter.formatCellValue(cell, objFormulaEvaluator);
type: Answer
score: 2
answers question: http://stackoverflow.com/q/21538481
upvote count: 2
has comment: http://stackoverflow.com/comment/92686614
downvote count: 0

http://stackoverflow.com/a/21588750
upvote count: 2
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32614310
has comment: http://stackoverflow.com/comment/32614390
accepted answer of: http://stackoverflow.com/q/21588706
has body: Those characters aren't your random characters instead of random integers. That is the default output of the toString() method in Object, which arrays (which are objects too) don't override. [T]his method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode()) You probably saw something like this: [I@68111f9b The [I is Java's code for array ([) of int (I), and the 68111f9b is the hexadecimal output of the hash code for the array. Try System.out.println(Arrays.toString(myPermutation));
type: Answer
answers question: http://stackoverflow.com/q/21588706
has comment: http://stackoverflow.com/comment/32614667
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/32614512
has comment: http://stackoverflow.com/comment/32614408

http://stackoverflow.com/comment/32627904
has text: @Edgar No, you will have one copy of DO(), unless one or more subclasses override it, in which case, of course, each overriding subclass will needs it own copy.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21596813
type: Comment

http://stackoverflow.com/q/21617234
answer count: 1
accepted answer: http://stackoverflow.com/a/21617367
score: 0
has comment: http://stackoverflow.com/comment/32664108
has body: I was making a game for school, and it works all and stuff but now I have a big problem. I wanted to add doors, and keys. I finished the door part and wanted to test it. It didn't work. It's not about the code, everything is fine. I saw that my classes were not build in the bin folder. the bin folder of the program: http://speedcap.net/sharing/screen.php?id=files/37/bf/37bf1527e7a2028bfaf9188e9571c465.png The classes (in Eclipse): http://speedcap.net/sharing/screen.php?id=files/38/a0/38a0f0e0a3b376c40d7689bc0e6a23aa.png Also as you can see, in eclipse there is a "!" on top of the project. Now the problem is: How do I fix this? Any help would be appreciated. Greetings Carolien. EDIT: I got everything fixed now thanks for helping (feeling really dumb now -_-) it was something with order and export (still dont know what but i clicked select all and suddenly everything was fixed)
has answer: http://stackoverflow.com/a/21617367
type: AnsweredQuestion
has title: Eclipse doesn't place the classes in the bin folder anymore
tagged with: java
tagged with: eclipse
has comment: http://stackoverflow.com/comment/32664023
type: Question

http://stackoverflow.com/comment/32724201
type: QuestionComment
has text: This is wrong: `if(JToolBar.getCurrentTool()=="fill")`. You should never use `==` to compare Strings, but rather the `equals(...)` method. You are fixing the wrong thing by making bImg static. Make it non-static and fix the code so static is not needed. You will need to create and post a [minimal, runnable example program](http://stackoverflow.com/help/mcve) if we're to be able to help you, I think.
comment on: http://stackoverflow.com/q/21651537
score: 0
type: Comment

http://stackoverflow.com/comment/32706517
type: QuestionComment
comment on: http://stackoverflow.com/q/21641542
score: 0
has text: Fixed code formatting, edited to be peer reviewed
type: Comment

http://stackoverflow.com/comment/32699772
type: QuestionComment
comment on: http://stackoverflow.com/q/21637752
has text: Its definitely not for performance. Often its easier for programmers to think in terms of bits than numbers.
score: 0
type: Comment

http://stackoverflow.com/q/21536639
type: AnsweredQuestion
favorite count: 0
possible better answer: http://stackoverflow.com/a/21537144
has body: I am looking for a neat solution to get the time units in Java 7 ( or using Joda date time) Like, to 65 minutes, it should say 1 hour 5 minutes To 30 minutes, it should just say 30 minutes Thanks.
has comment: http://stackoverflow.com/comment/32521996
has answer: http://stackoverflow.com/a/21537144
type: Question
upvote count: 2
tagged with: datetime
has comment: http://stackoverflow.com/comment/32521664
has answer: http://stackoverflow.com/a/21537011
tagged with: java
answer count: 3
has title: Effectively getting time unit with Joda
has comment: http://stackoverflow.com/comment/32526393
tagged with: jodatime
has comment: http://stackoverflow.com/comment/32530392
downvote count: 0
has answer: http://stackoverflow.com/a/21536887
accepted answer: http://stackoverflow.com/a/21537011
score: 2

http://stackoverflow.com/comment/32796386
score: 0
type: AnswerComment
has text: In case of fredd or fred what does it return?
type: Comment
comment on: http://stackoverflow.com/a/21669242

http://stackoverflow.com/comment/32605444
comment on: http://stackoverflow.com/q/21583911
has text: @Mxyl OH! I have just the thing for you sir. Introducing BULK INSERT. http://msdn.microsoft.com/en-us/library/ms188365.aspx
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/q/21581109
tagged with: java
type: Question
has title: Works fine when I build it, outputs an error when I run it
has comment: http://stackoverflow.com/comment/32600416
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/21581567
has answer: http://stackoverflow.com/a/21581649
has answer: http://stackoverflow.com/a/21581503
accepted answer: http://stackoverflow.com/a/21581503
has body: The runtime error I keep getting is Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Scanner.java:840) at java.util.Scanner.next(Scanner.java:1461) at java.util.Scanner.nextInt(Scanner.java:2091) at java.util.Scanner.nextInt(Scanner.java:2050) at lab4b2.main(lab4b2.java:12) My code is import java.util.*; import java.io.*; public class lab4b2 { public static void main (String [] args) throws IOException { Scanner fileIN = new Scanner(new File("lab4b2.txt")); char unit; double amount,conv; unit = fileIN.next().charAt(0); amount = fileIN.nextInt(); switch (unit) { case 'p': conv = amount*4.9; System.out.printf("%.2f pounds = %.2f newtons",amount,conv); break; case 'P': conv = amount*4.9; System.out.printf("%f pounds = %f newtons",amount,conv); break; case 'f': conv = amount*0.30488; System.out.printf("%f feet = %f meters",amount,conv); break; case 'F': conv = amount*0.30488; System.out.printf("%f feet = %f meters",amount,conv); break; case 'm': conv = amount*1.61; System.out.printf("%f miles = %f kilometers",amount,conv); break; case 'M': conv = amount*1.61; System.out.printf("%f miles = %f kilometers",amount,conv); break; default: System.out.println("Please enter the possible units only."); break; } } } What is the problem? This is only happening after I click run. I'm using JCreator if that helps. I believe the problem is somewhere in the printf but I don't see any reasonable answers to the problem. My file input is M 3.106 P 125 F 120 P 7.2 F 56 M 100
possible better answer: http://stackoverflow.com/a/21581567
type: AnsweredQuestion

http://stackoverflow.com/comment/32536574
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21545224
has text: It was printing a whole lot of junk , i just wanted to know the use of -365 * 4 .

http://stackoverflow.com/comment/32703191
score: 0
type: Comment
comment on: http://stackoverflow.com/q/21638322
type: QuestionComment
has text: So what *does* it return? Can you *cast* that to the remote interface?

http://stackoverflow.com/a/21565237
has body: If it's only about the rotation, one can transform the vector (1,0) using the given matrix, and compute the angle between the resulting vector and the x-axis, as already mentioned in the comment to the original question import java.awt.Point; import java.awt.geom.AffineTransform; import java.awt.geom.Point2D; import java.util.Random; public class ExtractRotation { public static void main(String[] args) { for (int i=0; i&lt;=180; i++) { double angleRad = Math.toRadians(i); AffineTransform at = createRandomTransform(angleRad); double extractedAngleRad = extractAngle(at); System.out.println( "In: "+Math.toDegrees(angleRad)+ " " + "Out "+Math.toDegrees(extractedAngleRad)); } } private static double extractAngle(double m[]) { return extractAngle(new AffineTransform(m)); } private static double extractAngle(AffineTransform at) { Point2D p0 = new Point(); Point2D p1 = new Point(1,0); Point2D pp0 = at.transform(p0, null); Point2D pp1 = at.transform(p1, null); double dx = pp1.getX() - pp0.getX(); double dy = pp1.getY() - pp0.getY(); double angle = Math.atan2(dy, dx); return angle; } private static Random random = new Random(0); private static AffineTransform createRandomTransform(double angleRad) { AffineTransform at = new AffineTransform(); double scale = 1.0; at.translate(randomDouble(), randomDouble()); scale = Math.abs(randomDouble()); at.scale(scale, scale); at.rotate(angleRad); at.translate(randomDouble(), randomDouble()); scale = Math.abs(randomDouble()); at.scale(scale, scale); return at; } private static double randomDouble() { return -5.0 + random.nextDouble() * 10; } }
has comment: http://stackoverflow.com/comment/32630657
accepted answer of: http://stackoverflow.com/q/21561909
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/32620621
upvote count: 3
answers question: http://stackoverflow.com/q/21561909
score: 3

http://stackoverflow.com/q/21612335
answer count: 1
tagged with: while-loop
has title: For loop and while loop skipping Scanner
has answer: http://stackoverflow.com/a/21612704
type: AnsweredQuestion
tagged with: java.util.scanner
has body: Here is my code: for (i = 0; i &lt; numpc; i++){ System.out.println(i); pcdata[i] = nameinput.next(); //get unsorted data } I also tried using a while loop reiteration of the for loop. The program is meant to input multiple strings (the number of strings needed is denoted by numpc). The input/output is as follows: 0 // variable (i) counter Apple 1 2 3 //Input 1 2 3 4 As you can see, the for loop runs 4 more times after the scanner receives a single input. This should not be happening unless i am missing something obvious?
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32654698
accepted answer: http://stackoverflow.com/a/21612704
score: 0
tagged with: for-loop
has comment: http://stackoverflow.com/comment/32654785

http://stackoverflow.com/a/21631535
type: Answer
has comment: http://stackoverflow.com/comment/32688741
has comment: http://stackoverflow.com/comment/32688033
has body: Instead of looping all the numbers come up with an Algorithm that could determine required number of 1s, for such Algorithm you have to see and identify a pattern in the number series. For Example 1-100 First Number requires 1 Last Number requires 1 There is one 1 with every digit in 2nd row (11-19) There is one 1 for every row (already calculated ones for 2nd) (21,31,41,51,61,71,81,91) So 1+1+9+9 = 20 Check Your Answer then expend and test your logic. So for every Hundred Numbers we require at least ten 1s, now go upto 1000 and 100,000 After exploring the series to a little further you will eventually come up with a Algorithm to determine the required ones without looping all the numbers.
score: 0
answers question: http://stackoverflow.com/q/21631293

http://stackoverflow.com/a/27255439
has comment: http://stackoverflow.com/comment/106495607
downvote count: 0
has body: People from AndroidFFmpeg project implemented "jni://" protocol to stream data via JNI, see https://github.com/appunite/AndroidFFmpeg/blob/master/FFmpegLibrary/jni/jni-protocol.c I do not know how it's used, just I came across that file and saw your question. I think you could use the same solution. You may want to look at this post: https://stackoverflow.com/a/24747137/1028256 about passing FileDescriptor to JNI
score: 1
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/21596965

http://stackoverflow.com/comment/32671993
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21621845
has text: Tomcat doesn't have a JTA transaction manager. You'll need a more complex Java EE container like JBoss, Glassfish, etc. if you want JTA support. Or you'll have to integrate a JTA transaction manager by yourself like Bitronix.

http://stackoverflow.com/a/21625551
has comment: http://stackoverflow.com/comment/32678139
has comment: http://stackoverflow.com/comment/32677899
score: 0
has comment: http://stackoverflow.com/comment/32678371
answers question: http://stackoverflow.com/q/21624643
type: Answer
accepted answer of: http://stackoverflow.com/q/21624643
has comment: http://stackoverflow.com/comment/32678605
type: AcceptedAnswer
has body: You can always create your appClientReference instance using a spring bean. contextName/ejbName/remote or local // assuming you have not over ridden the default naming strategy. org.jnp.interfaces.NamingContextFactory jnp://localhost:1099 org.jboss.naming:org.jnp.interfaces
has comment: http://stackoverflow.com/comment/32678364

http://stackoverflow.com/comment/32691240
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21632431
has text: Lastly I have one more question for you... Runtime error occurs only when we run the program... after compilation, i.e javac <file_name> we get a class file and that is interpreted to native/machine code by using an interpreter (java <class_name>) isn't this stage called running..

http://stackoverflow.com/q/21615558
has comment: http://stackoverflow.com/comment/32660938
type: Question
answer count: 2
score: -2
has comment: http://stackoverflow.com/comment/32660948
has answer: http://stackoverflow.com/a/21615632
favorite count: 0
has comment: http://stackoverflow.com/comment/32661018
type: UnansweredQuestion
upvote count: 1
has body: I am making a constructor for UCSDStudent, and I found my constructor has no problems. Please point out some specific problems and help me to make my own resolution! class UCSDStudent extends Base { private String name; private long Studentnum; public UCSDStudent (String name, long number) { UCSDStudent s = new UCSDStudent(); s.setName(name); s.setStudentNum(number); } public void setName(String setName) { name = setName; } public void setStudentNum(long setStudentNum){ Studentnum = setStudentNum; } public String getName () { return this.name; } public long getStudentNum () { return this.Studentnum; } ....... // some more code, but I will put the instantiation in the main func. // create Student and place in symbol table if(!symtab.insert ( new UCSDStudent (buffer, number), 1)){ System.out.println("Couldn't insert " + "student!!!"); } ...... UCSDStudent stu = new UCSDStudent (buffer, 0); This is Base class. public abstract class Base { public String getName () { // identifier function return null; } }
has answer: http://stackoverflow.com/a/21615665
has comment: http://stackoverflow.com/comment/32661058
has title: Actual and formal argument lists differ in length
tagged with: java
downvote count: 3

http://stackoverflow.com/a/21621856
score: 7
has body: putIfAbsent() returns the previous value associated with the specified key, or null if there was no mapping for the key, and because key 3 is not present in the map so it returns null. You have added key 1 and key 2 in the map but key 3 is not associated with any value. So you get a null. Map key 3 with some value and putIfAbsent() will return previous value associated with that key. Like if map already contained key 3 associated with value A key 3 ---&gt; A Then on calling map.putIfAbsent("key 3","B") will return A
type: Answer
upvote count: 7
answers question: http://stackoverflow.com/q/21621803
downvote count: 0

http://stackoverflow.com/comment/32543036
comment on: http://stackoverflow.com/a/21549432
type: AnswerComment
type: Comment
has text: It seems running the 25 jobs in separate threads would have precisely the same problem, though.
score: 0

http://stackoverflow.com/comment/32566957
has text: let me test the xslt way. The JAXB way is way far for the app I am working. Its all legacy and Compex Schema failed several times to translate to Jaxb
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21558585

http://stackoverflow.com/q/21664306
tagged with: arrays
has title: square root of ArrayFieldVector<Complex>
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/21664347
has body: I am using ArrayFieldVector class of apache commons. ArrayFieldVector&lt;Complex&gt; a=new ArrayFieldVector&lt;&gt;; Now I want to create another ArrayFieldVector which elements is sqrt of a. I didn't find sqrt method in that class. So, how should I calculate sqrt?
type: UnansweredQuestion
tagged with: apache-commons
tagged with: java
type: Question

http://stackoverflow.com/comment/32549952
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/21546112
has text: The asker wants items to be comparable (by comparing their values).
type: Comment

http://stackoverflow.com/q/21592190
score: 0
has comment: http://stackoverflow.com/comment/32620540
has comment: http://stackoverflow.com/comment/32620479
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32826387
has comment: http://stackoverflow.com/comment/32620974
has comment: http://stackoverflow.com/comment/32620198
has body: The compiled .class file contains bytecodes corresponding to whole java class. However, during execution, some bytecodes are exectued multiple times while some are probably not executed at all, depending on the logic and the input. Is there a way that I could get a trace of only those bytecodes that are executed during the lifetime of the java program? Edit: Use case I think a use-case may help. After a sample run of the program, I would like to count the frequency of the bytecode instructions that were executed (e.g. areturn has been carried out 10 times). Is there a profiler or any other tool that I can use for this purpose?
type: Question
tagged with: debugging
tagged with: java
has answer: http://stackoverflow.com/a/21592586
has comment: http://stackoverflow.com/comment/32620583
tagged with: bytecode
answer count: 1
has comment: http://stackoverflow.com/comment/32620330
has title: How can I get the bytecodes that are executed at runtime for a Java program?

http://stackoverflow.com/q/21663579
has answer: http://stackoverflow.com/a/21663779
tagged with: static
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21663812
answer count: 4
tagged with: java
has comment: http://stackoverflow.com/comment/32744895
has title: Abstract class instantiate by own static method
has comment: http://stackoverflow.com/comment/32744705
type: Question
tagged with: class
has body: DocumentBuilderFactory f = DocumentBuilderFactory.newInstance(); // DocumentBuilderFactory is abstract class. newInstance is static method. Can't figure out how it works. What happens? I mean why it works... If I'm not mistaken we can't make instance of Abstract class.
has answer: http://stackoverflow.com/a/21663735
score: 0
tagged with: abstract
has comment: http://stackoverflow.com/comment/32744550
has answer: http://stackoverflow.com/a/21663704

http://stackoverflow.com/q/21521411
tagged with: spring
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/21521708
type: Question
has title: Getting XML from Spring Web Service Request
has body: We need to log all incoming SOAP requests, preferably by persisting to a DB as we have identifying properties that we'd like to associate with it. Is there any way of getting the raw XML data in Spring?
has comment: http://stackoverflow.com/comment/32494209
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/21521708
linked to: http://stackoverflow.com/q/14197918
tagged with: web-services

http://stackoverflow.com/a/21664948
answers question: http://stackoverflow.com/q/21664816
type: Answer
has body: You list two variables in this problem: First you want to manipulate the jar, second you want to manipulate an already running program. Modify a runnable jar By adding your own main class to the classpath and manipulate the main-class attribute in the manifest file, you are able to decide on when an how the vulnerable program is started. Easy! As an alternative, you could create an agent class and register it as premain-class in the manifest. Modify a running program I am certain that you need to manipulate the classloader to inject your malicious code to the running program.
score: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21664816

http://stackoverflow.com/q/21560828
has body: I'm just trying to test sending bytes over a TCP socket connection, I know it wasn't really meant for that but I'm just trying to figure out whether this is possible or not what i'm trying to do: get bytes from a string on client sent it as bytes to the server get the bytes on the server and decode it back to the original string Client: package ByteClientServer; import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; import java.net.*; public class Client { String hostAddress = "localhost"; int port = 1010; public Client() { try { Socket socket = new Socket(hostAddress, port); String test = "hello"; //dycrypt bytes from this string on server side byte[] byteArray = test.getBytes(); OutputStream out = socket.getOutputStream(); DataOutputStream dos = new DataOutputStream(out); dos.write(byteArray); } catch (UnknownHostException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public static void main(String[] args) { new Client(); } } Server: package ByteClientServer; import java.io.*; import java.net.*; public class Server { public static void main(String[] args) { try { ServerSocket server = new ServerSocket(1010); server.setSoTimeout(0); Socket connectionToClient = server.accept(); InputStream is = connectionToClient.getInputStream(); DataInputStream dis = new DataInputStream(is); byte[] data = dis.readUTF().getBytes(); //dis.readFully(data, 0, data.length); String s = new String(data); System.out.println(s); } catch(IOException e) { e.printStackTrace(); //System.err.println("Server was terminated."); } } } it doesn't like this line on server: byte[] data = dis.readUTF().getBytes(); and throws the exception: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(Unknown Source) at java.net.SocketInputStream.read(Unknown Source) at java.io.DataInputStream.readFully(Unknown Source) at java.io.DataInputStream.readUTF(Unknown Source) at java.io.DataInputStream.readUTF(Unknown Source) at…
tagged with: io
has answer: http://stackoverflow.com/a/21561003
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21935122
tagged with: socketexception
possible better answer: http://stackoverflow.com/a/21561003
has title: Is it possible to decode bytes on a server which were sent from a client as a byte array?
type: Question
has answer: http://stackoverflow.com/a/21561130
tagged with: java
accepted answer: http://stackoverflow.com/a/21935122
score: 0
answer count: 3

http://stackoverflow.com/comment/32687613
score: 0
type: Comment
type: AnswerComment
has text: Good to know, that they extend from `RuntimeException`, I really have near to no experience. Nevertheless one of your recommendations is to return `null`, shouldn't I avoid that, because it may make no sense to someone reading my code, as null has no meaning here, as it is just meat for the compiler to keep quiet?
comment on: http://stackoverflow.com/a/21631055

http://stackoverflow.com/comment/32503276
has text: Is there an id attached to these windows. Google login window is just one of the annoyance. There are other several that I would like to detect programatically and take actions "Click Cancel" or "Click OK" etc.
type: Comment
comment on: http://stackoverflow.com/a/21519432
score: 0
type: AnswerComment

http://stackoverflow.com/q/21616304
tagged with: hadoop
tagged with: cloudera
has title: cannot find JAVA_HOME Pseudo-Distributed Mode CDH3 single Node CENTOS 6
answer count: 1
score: 0
type: UnansweredQuestion
has body: I am trying to install CDH3 to setup a VM for accumulo prototyping. There are no issues in standalone mode and the test program works in both cases. I am using CDH3 because there are compatibility issues with accumulo 1.4.3 and CDH4. It is my limited understanding that in Pseudo-Distributed Mode both hadoop and zookeeper will start. I tried to run the following command and got the following error: for service in /etc/init.d/hadoop-0.20-* &gt; do &gt; sudo $service start &gt; done +======================================================================+ | Error: JAVA_HOME is not set and Java could not be found | +----------------------------------------------------------------------+ | Please download the latest Sun JDK from the Sun Java web site | | &gt; http://java.sun.com/javase/downloads/ &lt; | | | | Hadoop requires Java 1.6 or later. | | NOTE: This script will find Sun Java whether you install using the | | binary or the RPM based installer. | +======================================================================+ .... [root@localhost tmp]# cd .. [root@localhost /]# $JAVA_HOME $JAVA_HOME bash: /usr/lib/jvm/java-1.6.0-openjdk.x86_64: is a directory As you can see I have set JAVA_HOME. It is set in my /etc/profile as: export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk.x86_64 export PATH=$JAVA_HOME/bin:$PATH Please tell me what I am doing wrong. Please tell me if this mode runs zookeeper. thanks!
has answer: http://stackoverflow.com/a/21638095
type: Question
tagged with: java

http://stackoverflow.com/q/21665300
has answer: http://stackoverflow.com/a/21665643
has answer: http://stackoverflow.com/a/21665486
type: AnsweredQuestion
tagged with: architecture
possible better answer: http://stackoverflow.com/a/21665486
tagged with: jms
favorite count: 0
has comment: http://stackoverflow.com/comment/32747937
type: Question
upvote count: 2
has comment: http://stackoverflow.com/comment/32791446
has comment: http://stackoverflow.com/comment/32791553
has body: I would like to know if with RMI a server can remotely invoke a method from any of his clients, or just the clients can do this with their server.
has answer: http://stackoverflow.com/a/21689898
has comment: http://stackoverflow.com/comment/32791707
has title: Can I invoke a client´s method from a server with RMI
tagged with: rmi
tagged with: java
answer count: 3
score: 2
accepted answer: http://stackoverflow.com/a/21689898
downvote count: 0
tagged with: websocket

http://stackoverflow.com/q/21598089
has comment: http://stackoverflow.com/comment/32630100
has title: Clear properly a java arraylist
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32630005
tagged with: java
has comment: http://stackoverflow.com/comment/32630076
type: Question
has answer: http://stackoverflow.com/a/21598256
accepted answer: http://stackoverflow.com/a/21598256
tagged with: arraylist
score: 0
has body: I am trying to create a 2d ArrayList from a 2d array. Actually I ve got a temp ArrayListand I parse it to my 2d ArrayList in for loop. I am trying to find the correct way to clear this temp ArrayList in order to pass every time, the correct values to mags ArrayList. for (int m = 0; m &lt; M; m++) { for (int n = 0; n &lt; N; n++) { for (int i = 0; i &lt; gaborWavelet.length; i++) { temp.clear(); for (int j = 0; j &lt; gaborWavelet[0].length; j++) { sum = gaborWavelet[i][j][m][n][0] / (M * N); temp.add((int) (sum * 170)); } mags.add(temp); } } } In the above code only the final indexed-i it is passed in the temp m*n*i times. EDIT: for (int m = 0; m &lt; M; m++) { for (int n = 0; n &lt; N; n++) { for (int i = 0; i &lt; gaborWavelet.length; i++) { ArrayList&lt;Integer&gt; temp = new ArrayList&lt;Integer&gt;(); for (int j = 0; j &lt; gaborWavelet[0].length; j++) { sum = gaborWavelet[i][j][m][n][0] / (M * N); temp.add((int) (sum * 170)); } mags.add(temp); } } } System.out.println(mags.get(200)); System.out.println(mags.get(0)); If the above is what you mean, I am getting the same issue here.
answer count: 1
linked to: http://stackoverflow.com/q/157944
has comment: http://stackoverflow.com/comment/32630062

http://stackoverflow.com/a/21574438
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21573540
has body: You are using the wrong data structure for this really. What you need is a tree structure that looks like this (for this example lets use the words "Tree", "Three" and "Try" T H R R E Y E E E Now you can just walk down through the tree, if they have already typed T and R then you can just do a simple treewalk and determine that tree and try are the possible words. You should also abort the treewalk as soon as you know you are going to get too many results. This data structure is called a Trie: http://en.wikipedia.org/wiki/Trie

http://stackoverflow.com/comment/32496953
type: QuestionComment
comment on: http://stackoverflow.com/q/21523199
score: 1
type: Comment
has text: Description and bottom-line question are extremely unclear

http://stackoverflow.com/comment/32759472
comment on: http://stackoverflow.com/q/21672278
score: 1
type: Comment
has text: Where is the error ? Your code is probably buggy but we don't see enough.
type: QuestionComment

http://stackoverflow.com/comment/32814389
score: 0
type: Comment
type: QuestionComment
has text: yes. The array contains a minimum, average and a std dev. obtained from data.
comment on: http://stackoverflow.com/q/21674599

http://stackoverflow.com/comment/32688308
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21631760
type: Comment
has text: Log more information about the exception you get.

http://stackoverflow.com/a/21644011
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/21608891
has body: Use com.google.gwt.resources.client.ImageResource to provide images. progress.gif should be in the same folder of Resources class (relative path can also be used-change @source value) public interface Resources extends ClientBundle { @Source("progress.gif") ImageResource getPreloader(); } Resources resources = GWT.create(Resources.class); popup.setWidget(new Image(resources.getPreloader()));
has comment: http://stackoverflow.com/comment/32759723
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21608891
type: Answer

http://stackoverflow.com/a/21633575
score: 7
has comment: http://stackoverflow.com/comment/32691828
upvote count: 8
answers question: http://stackoverflow.com/q/21633521
has comment: http://stackoverflow.com/comment/32694791
has body: The Windows filesystem is case-insensitive. You cannot (sanely) find a case-sensitive file on a case-insensitive filesystem. If you run javac on Linux with a case-sensitive filesystem, it will be case-sensitive.
has comment: http://stackoverflow.com/comment/32691732
accepted answer of: http://stackoverflow.com/q/21633521
has comment: http://stackoverflow.com/comment/32691969
has comment: http://stackoverflow.com/comment/32691709
type: AcceptedAnswer
downvote count: 1
type: Answer

http://stackoverflow.com/q/21635989
has comment: http://stackoverflow.com/comment/32833105
has comment: http://stackoverflow.com/comment/32696225
has body: I have two lists : A : List&lt;MyCustomObject&gt; B. List&lt;MyCustomObject&gt; MyCustomObject has various fields. For instance a field id In my program, I need to check if same id exists in both lists. So currently I am doing nested iterations : for(int i=0;i&lt;a.size();i++) { MyCustomObject obj = a.get(i); for(int j=0;j&lt;b.size();j++) { if( obj.getId().equals(b.get(j).getId()) { //do something break; } } } As I frequently need to do this operation, it looks me unoptimized as I am frequently iterating over long lists. How can I optimize this operation ?
tagged with: performance
has comment: http://stackoverflow.com/comment/32696457
tagged with: nested-loops
tagged with: java
has comment: http://stackoverflow.com/comment/32698356
type: Question
has answer: http://stackoverflow.com/a/21636083
answer count: 2
tagged with: java-7
has comment: http://stackoverflow.com/comment/32696411
tagged with: iteration
has comment: http://stackoverflow.com/comment/32696595
score: 0
has comment: http://stackoverflow.com/comment/32763885
has comment: http://stackoverflow.com/comment/32696187
has answer: http://stackoverflow.com/a/21636024
has comment: http://stackoverflow.com/comment/32762979
has title: Optimized way to check for equality between value of Objects inside a List
type: UnansweredQuestion

http://stackoverflow.com/a/21612441
downvote count: 0
answers question: http://stackoverflow.com/q/21612365
type: Answer
score: 1
upvote count: 1
has body: Downcasts are illegal. An A is not a B and therefore you can't cast it to be one. You can cast B to be A, but not the other way round.

http://stackoverflow.com/comment/32614949
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21586948
score: 1
has text: Scala provides powerful abstractions for doing async processing. If you are trying to do the same thing in Java, you may end up wasting a lot of time. For setting up async connection in Java, you can refer to: http://stackoverflow.com/questions/3142915/how-do-you-create-an-asynchronous-http-request-in-java Since you are using Play! Framework, http://www.playframework.com/documentation/2.0.2/JavaWebSockets is useful.

http://stackoverflow.com/q/21580269
has title: Add Custom Declaration in xml using java
score: 2
has body: Is there any way that I can add custom declaration in xml using java. (i.e) I created xml using dom parser in Java. &lt;?xml version="1.0" encoding="UTF_8"?&gt; has been created by default. I want another declaration is also need to be added in my xml. &lt;?myxml version="10.0"?&gt; Is there any way I could achieve this in dom parser. Thanks in advance.
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/21580369
tagged with: dom
type: Question
accepted answer: http://stackoverflow.com/a/21580369
downvote count: 0
favorite count: 0
answer count: 1
tagged with: http://stackoverflow.com/tag/xml
upvote count: 2
has comment: http://stackoverflow.com/comment/32598562

http://stackoverflow.com/a/21575614
has body: You are using the same List object for all entries in the map. Instead you must check for each serverIP if there already is an entry in the map. If there is an entry, add to the existing list. If there is no entry, create a new List and add the filePath to that one. if (filesMap.get(serverIP) != null) { List&lt;String&gt; list = new ArrayList&lt;String&gt;(); list.add(filePath); filesMap.put(serverIP, list); } else { filesMap.get(serverIP).add(filePath); }
score: 0
answers question: http://stackoverflow.com/q/21575502
type: Answer

http://stackoverflow.com/comment/32577246
comment on: http://stackoverflow.com/q/21567823
score: 0
type: Comment
type: QuestionComment
has text: What is your purpose to do that?

http://stackoverflow.com/q/21520818
has comment: http://stackoverflow.com/comment/32496184
tagged with: stanford-nlp
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32509400
has answer: http://stackoverflow.com/a/21526142
tagged with: nlp
has title: How to tag field specific nouns using Parts-of-Speech Taggers?
has body: I want to tag a field specific such as technical and scientific nouns in a sentence using Part-of-speech technique . Example Consider the sentences: 1) Computers need keyboard , moniter , CPU to work. 2) Automobile uses gears and clutch . Now my objective is , the example sentences have to be tagged as 1st sentence Computer/technical need/noun keyboard/technical CPU / technical to /preposition work /verb 2nd sentence Automobile / mechanical uses / verb gears / mechanical and / conjunction clutch / mechanical My need I want to implement above mentions objective in java, that is to tag nouns by it related field such as technical , mechanical , electrical etc. My Previous Works I already used Stanford NLP , Open NLP , but they are tagging POS , but not satisfying what is need. Please tell me how to do this ?
type: Question
answer count: 2
tagged with: opennlp
has answer: http://stackoverflow.com/a/21541733
score: 0
tagged with: java
tagged with: information-retrieval

http://stackoverflow.com/comment/32663339
has text: You did not write Eclipse, the Java compiler, the Android build tools, etc. Hence, they are all "third-party programs". Where are you drawing the line?
comment on: http://stackoverflow.com/q/21616544
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21616295
has body: Since the map isn't updated while being used, use a HashMap, which gives excellent O(1) lookup performance (at the sacrifice of thread safety). When it's time to refresh, build a new map and swap references. Consider using an AtomicReference to make the swap thread safe: private final AtomicReference&lt;Map&lt;K, V&gt;&gt; mapRef = new AtomicReference&lt;&gt;(); To use: mapRef.get().get(key); To initialize or swap in a new map: Map&lt;K, V&gt; newMap = new HashMap&lt;&gt;(); // populate map mapRef.set(newMap); // all threads will see this change
type: Answer
score: 21
upvote count: 21
accepted answer of: http://stackoverflow.com/q/21616234
answers question: http://stackoverflow.com/q/21616234
downvote count: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/140103207
has comment: http://stackoverflow.com/comment/32662382

http://stackoverflow.com/q/21554956
tagged with: coords
has body: I am currently in the progress of using WritableRaster and it's setPixed method, and I need it to not set only one pixel, but a 'circle' with the radius of r. What I am thinking about is something like this: for(int y = -r; y &lt; r; y++) { for(int x = -r; x &lt; r; x++) { raster.setPixel(x,y,color); }} The question is, would this work to make a circle, if so, how would I make it go through all the pixels inside? Thanks in advance! EDIT: Sorry I did not make this clear- I am making a rubber tool on a transparent canvas, thus, if I draw a circle with transparent color, it won't delete what was there before... This is why I am using setPixel. EDIT EDIT: This is what the output of the code is (on g2d, using drawLine with same values so it only fills one pixel as in the method setPixel): https://i.sstatic.net/9ONWe.png EDIT EDIT EDIT: If anyone wants to use this code for the same reason, I recommend using BufferedImage.setRGB() because it's much quicker. If you don't know what to do with the color (last parameter), use something like: ... buffImg.setRGB(x,y,new Color(r,g,b,a).getRGB()); ...
score: 2
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32552900
has comment: http://stackoverflow.com/comment/32553569
downvote count: 0
tagged with: java
type: Question
upvote count: 2
tagged with: graph
tagged with: raster
has comment: http://stackoverflow.com/comment/32553415
has comment: http://stackoverflow.com/comment/32557401
has comment: http://stackoverflow.com/comment/32557497
has answer: http://stackoverflow.com/a/21558113
accepted answer: http://stackoverflow.com/a/21558113
answer count: 1
favorite count: 0
tagged with: geometry
has title: Plot circles with centre and radius

http://stackoverflow.com/q/21631328
type: Question
downvote count: 0
tagged with: spring-aop
has title: Using spring AOP aspect to intercept the methods?
has body: I am using spring AOP to intercept the methods. I have below configuration in my spring config file. &lt;aop:aspectj-autoproxy /&gt; Aspect class: @Aspect public class MyAspect{ @Around("execution(public * *(..))") public Object doAction(ProceedingJoinPoint call) throws Throwable { //somelogic } Above method does not intercept private methods ? what should i do to ask the aspect to intercept both private and public methods?
answer count: 1
favorite count: 0
upvote count: 2
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21631369
tagged with: spring
score: 2
tagged with: java

http://stackoverflow.com/a/21676426
downvote count: 1
score: -1
has body: The string stack will be in the heap, the string overflow is in the constant pool, the third string as the result of concatenation stackoverflow in the constant pool.
upvote count: 0
has comment: http://stackoverflow.com/comment/32767139
answers question: http://stackoverflow.com/q/21676143
type: Answer
has comment: http://stackoverflow.com/comment/32766511

http://stackoverflow.com/comment/32546668
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21519424
score: 0
has text: Hey! I just restart our weblogic server :) then it worked. anyway thank you :) God bless

http://stackoverflow.com/a/52533121
score: 1
has comment: http://stackoverflow.com/comment/116304760
type: Answer
answers question: http://stackoverflow.com/q/21535023
upvote count: 3
downvote count: 2
has body: In Eclipse: File>Import>General>Existing projects in Workspace Browse until get the netbeans project folder > Finish

http://stackoverflow.com/q/21636163
type: AnsweredQuestion
score: 7
tagged with: java
has comment: http://stackoverflow.com/comment/32697091
tagged with: gson
type: Question
answer count: 1
has comment: http://stackoverflow.com/comment/32696900
downvote count: 0
accepted answer: http://stackoverflow.com/a/21636237
favorite count: 0
has comment: http://stackoverflow.com/comment/32697022
has title: How to get a value from gson object by key
has body: I have been trying to follow along with this solution How to find specified name and its value in JSON-string from Java? However it does not seem to make sense. I define a new gson object from a string: Example of string here: http://api.soundrop.fm/spaces/XJTt3mXTOZpvgmOc public void convertToJson() { Gson gson = new Gson(); Object gsonContent = gson.fromJson( stringContent, RadioContent.class ); } And then try and return a value: public Object getValue( String find ) { return gsonContent.find; } Finally its called with: public static void print( String find = "title" ) { Object value = radioContent.getValue( find ); System.out.println( value ); } However I am getting an error: java: cannot find symbol symbol: variable find location: variable gsonContent of type java.lang.Object Full classes: Main class: http://pastebin.com/v4LrZm6k Radio class: http://pastebin.com/2BWwb6eD
has comment: http://stackoverflow.com/comment/32697201
upvote count: 7
has comment: http://stackoverflow.com/comment/32699412
has answer: http://stackoverflow.com/a/21636237
has comment: http://stackoverflow.com/comment/32699236
linked to: http://stackoverflow.com/q/6153176
has comment: http://stackoverflow.com/comment/32699969

http://stackoverflow.com/comment/32713468
type: Comment
type: QuestionComment
has text: I'm initializing emaili at the bottom of the DatabaseHandler class, am I doing that wrong?
comment on: http://stackoverflow.com/q/21645838
score: 0

http://stackoverflow.com/comment/32691039
type: Comment
has text: Also - I assumed that the if (backPressed) section you specified should come at the end of the yes and no OnClickListeners and that if I'm using that strategy, I don't need two separate builders for alertSave and alertBack. Am I right?
comment on: http://stackoverflow.com/a/21615747
score: 0
type: AnswerComment

http://stackoverflow.com/q/21646113
type: Question
tagged with: deadlock
accepted answer: http://stackoverflow.com/a/21646185
answer count: 1
has title: Confusion on Deadlock
tagged with: multithreading
has body: public class SimpleDeadlock implements Runnable{ static SimpleDeadlock sc1=null; static SimpleDeadlock sc2=null; void access(SimpleDeadlock sc){ if(Thread.currentThread().getName().equals("Thread1")) threadMethod1(sc); if(Thread.currentThread().getName().equals("Thread2")) threadMethod2(sc); } public synchronized void threadMethod1(SimpleDeadlock sc) { System.out.println(Thread.currentThread().getName()+": threadMethod1"); try{ Thread.sleep(1000); } catch(InterruptedException ie){} sc.deadlock(); } public synchronized void threadMethod2(SimpleDeadlock sc) { System.out.println(Thread.currentThread().getName()+": threadMethod2"); try{ Thread.sleep(1000); } catch(InterruptedException ie){} sc.deadlock(); } synchronized void deadlock() { System.out.println("In deadlock..."); } public void run(){ if(Thread.currentThread().getName().equals("Thread1")) access(sc1); if(Thread.currentThread().getName().equals("Thread2")) access(sc2); } public static void main(String[] args) throws InterruptedException{ sc1=new SimpleDeadlock(); sc2=new SimpleDeadlock(); Thread thread1=new Thread(sc1); Thread thread2=new Thread(sc2); thread1.setName("Thread1"); thread2.setName("Thread2"); thread1.start(); thread2.start(); Thread.sleep(10000); System.out.println(thread1.getName()+":"+thread1.getState()); System.out.println(thread2.getName()+":"+thread2.getState()); } } When I am interchanging the object in access method which is in run method this example occurs in deadlock as Thread1 waits for Thread2 to finish and vice versa. But when it is in given state it doesn't go in deadlock. WHY? When thread1 calls synchronized method threadMethod1(), the object sc1 is locked. Then how in that method the locked object sc1 calls another synchronized method.
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21646185
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/32714206

http://stackoverflow.com/a/21596816
score: 6
type: Answer
has comment: http://stackoverflow.com/comment/32629817
downvote count: 0
upvote count: 6
has comment: http://stackoverflow.com/comment/32630150
has body: try regex Matcher m = Pattern.compile("(?&lt;=/image)\\d{3}").matcher(str); StringBuffer sb = new StringBuffer(); while(m.find()) { m.appendReplacement(sb, String.format("%03d", Integer.parseInt(m.group()) - 1)); } m.appendTail(sb);
answers question: http://stackoverflow.com/q/21596566
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32629975
accepted answer of: http://stackoverflow.com/q/21596566

http://stackoverflow.com/q/21614621
answer count: 1
tagged with: string
has answer: http://stackoverflow.com/a/21614646
type: UnansweredQuestion
has title: How to check for the same word in a string?
score: 0
tagged with: java
type: Question
has body: My code takes a String input, separates them and locates the ones with a specific letter in them, then prints them. Now, i want to make sure the same word only prints once. For instance, if the input was " she looks nice, she is kind." then the output would be "she \n nice" This is my current code: Scanner kybd = new Scanner(System.in); String s = kybd.nextLine(); String[] arr = s.split(" "); for ( String ss : arr) { String []ary = {ss}; for(int i = 0; i &lt; ary.length; i++){ int numindex = ss.indexOf("e"); int numindex2 = ss.indexOf("E"); if (numindex != -1){ System.out.println(ary[i]); } else if(numindex2 != -1){ System.out.println(ary[i]); } } } Any suggestions on how to do this would be appreciated.

http://stackoverflow.com/a/21642288
accepted answer of: http://stackoverflow.com/q/21551998
answers question: http://stackoverflow.com/q/21551998
upvote count: 3
type: AcceptedAnswer
has body: You need to learn java before you try to make bukkit plugins. I tried making plugins before I learned java, and it was much harder than I expected. Read this, and get a basic understanding of java before you start. Also java books are a great resource. Once you learn java, Pogostick29Dev and SGTCaze (Youtube channels) are a perfect place to start making Bukkit plugins.
type: Answer
score: 3
downvote count: 0

http://stackoverflow.com/a/71201107
has comment: http://stackoverflow.com/comment/134031997
upvote count: 1
score: 1
downvote count: 0
has body: JDK Proxy At JDK11 Add this to before you aop code System.getProperties().put("jdk.proxy.ProxyGenerator.saveGeneratedFiles", "true"); Or,add VM options:-Djdk.proxy.ProxyGenerator.saveGeneratedFiles=true In ProxyGenerator.generateProxyClass(), there's a part of code to decide whether output class file to your location. Cglib Proxy At present, I only can output files while I'm debugging. But I think to do it once then you can understand how they complete interceptor. Add breakpoints at DefaultGeneratorStrategy.generate(ClassGenerator cg).While the program runs to this line: return this.transform(cw.toByteArray()); you can use FileOutputStream to write cw.toByteArray().It's the cglib proxy class and you can decompile it with tools like IDEA、jd gui、bytecode-viewer.
type: Answer
answers question: http://stackoverflow.com/q/21556647

http://stackoverflow.com/comment/32618570
comment on: http://stackoverflow.com/q/21589983
has text: You've shown partial code that parses the xml input, and no code that produces output. We need to see more in order to help. Please consider making a [Short, Self Contained, Correct Example](http://sscce.org/).
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21612890
downvote count: 0
has comment: http://stackoverflow.com/comment/92734159
has title: Junit @Before not working properly
tagged with: junit
has answer: http://stackoverflow.com/a/68797831
favorite count: 0
has answer: http://stackoverflow.com/a/21612968
possible better answer: http://stackoverflow.com/a/61594494
has answer: http://stackoverflow.com/a/61594494
answer count: 4
type: AnsweredQuestion
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/21612968
score: 5
has body: @Before public void setup(){ Ground ground = new Ground(100, 100); } @Test public void getDimX(){ String msg = "For a newly created Ground(100, 100), ground.getDimensionX() should return 100"; assertEquals(100, ground.getDimensionX()); } The above code returns a NullPointerException. If I move the Ground ground = new Ground(4, 4); into the getDimX() method, the test runs just fine. I have a number of tests that will use the same ground, so I would prefer not to make a new one with each test case. Also, if I get rid of the @Begin block entirely and just leave the ground instantiation, it also works fine. What then is the point of the @Before?
has answer: http://stackoverflow.com/a/63038500
upvote count: 5

http://stackoverflow.com/a/51167207
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/21631089
downvote count: 0
has body: To explain it further from the first answer, the auto-generated comments for the serialVersionUID is simply a comment template generation that applies to all fields, including this one. It runs when you generate element comment (Alt+Shift+J) for that field from the Source section of the Toolbar. The important fact is that the generation of field comments also runs automatically when you quick-fix The serializable class [ClassName] does not declare a static final serialVersionUID field of type long" Disabling/changing generated comments for all fields You can prevent the generation of comments for all fields by clicking edit and blanking the comment after performing what the original answerer @slim answered, as in Toolbar -&gt; Window -&gt; Preferences -&gt; Java -&gt; Code Style -&gt; Code Templates -&gt; Comments -&gt; Fields After quick-fixing the serializable warning, note that the comment is no longer auto-generated. Disabling/changing the automatic generation of the comment just for SerialVersionUID Unfortunately, there is no option to prevent the auto-generation of comments for the SerialVersionUID through quick-fixing without blanking the comment generation template for all fields. There is no such option when searching for "Comment" or "Serial" in Preferences. Fortunately, it doesn't matter much since for other fields, it generates only when you generate element comment for that field. And you can also prefer to comment or Javadoc fields manually. Example This code excerpt (only fields shown) shows that warning about serialization. public class SomePanel extends JPanel { private String name; /* ... */ } You quick-fix this warning, and you generate element comment the name field. Without blanking the template, you get this, which you do not want for serialVersionUID: public class SomePanel extends JPanel { /** * */ private static final long serialVersionUID = -5173652620102412871L; /** * */ private String name; /* ... */ } After blanking the template for comm…

http://stackoverflow.com/q/21675512
type: AnsweredQuestion
score: 1
has body: I have a follofing situation int "super-context.xml": &lt;bean id="conf" class="ee.Conf"/&gt; &lt;bean id="service" class="ee.Serivce"&gt; &lt;property name="conf" ref="conf"&gt; &lt;/bean&gt; Now I want to use this "super-context.xml" in various different projects. Say "sub-context.xml" has: &lt;import resource="super-context.xml"/&gt; &lt;bean id="subConf1" class="ee.SubConf"&gt; &lt;property name="confloc" value="classpath:ee/customconf1.sss" /&gt; &lt;/bean&gt; &lt;bean id="subConf2" class="ee.SubConf"&gt; &lt;property name="confloc" value="classpath:ee/customconf2.sss" /&gt; &lt;/bean&gt; ... &lt;bean id="subConfn" class="ee.SubConf"&gt; &lt;property name="confloc" value="classpath:ee/customconfn.sss" /&gt; &lt;/bean&gt; ee.Conf is something as follows: public class Conf ... { ... public void addSubConf(Resource res) { //configuration resolving from res } ... } ee.SubConf is something as follows: public class SubConf ... { ... @Autowired ee.Conf superConf; ... public void setConfloc(Resource res) { superConf.addSubConf(res); } ... } The problem aries on context load. Beans are initialized in following order (due to ordering in context file): conf, service, subConf1, subConf2, ... subConfn But service bean actually depends on all the subConf beans (although this can't be deducted from the context definition itself). It loads OK when import in "sub-context.xml" is added after subConf bean definitions. Reason behind this is implementing modularity. Is it possible to force a bean to load as late as possible ("service" bean in the example) or make beans of certain type load as soon as possible ("subConf" beans in the example), since fixed ordering of beans in "sub-context.xml" partly kills the wished modularity Or is theree a more pure way to achieve this type of modularity?
upvote count: 1
has answer: http://stackoverflow.com/a/21675806
type: Question
tagged with: java
answer count: 2
accepted answer: http://stackoverflow.com/a/21675806
downvote count: 0
has title: Initialize Spring Bean as late as possible
favorite count: 0
possible better answer: http://stackoverflow.com/a/21675634
tagged with: spring
has answer: http://stackoverflow.com/a/21675634
tagged with: http://stackoverflow.com/tag/xml

http://stackoverflow.com/comment/32584053
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21568886
score: 0
has text: Tips: 1) Add @MadProgrammer (or whoever - the @ is important) to *notify* them of a new comment. 2) Noting you took my advice, read carefully. *The only reason I did not **also** tell you to create the GUI on the EDT was that it had already been said. **Don't ignore advice.***

http://stackoverflow.com/comment/32683315
comment on: http://stackoverflow.com/q/21628599
type: QuestionComment
has text: Why do you need to pass `A` as a parameter? I don't get what you're trying to do.
type: Comment
score: 0

http://stackoverflow.com/q/21570813
has body: My web application is on following address: http://localhost:8080/MyProject/page-obj.html I am calling Mule Project, from a Web Application(deployed on glassfish), having following URL in page: `&lt;form action="http://localhost:28146/CallObject" method="post" id="objform"&gt;` Mule project is executing something on remote server and returning Success. I want to redirect success to another page say http://localhost:8080/MyProject/page-sucess.html When redirect, i see http://localhost:28146/CallObject on address bar, instead of http://localhost:8080/MyProject/page-sucess.html. Secondly, i am unable to load CSS and JS properly. I think i am not handling this properly Following is Mule Flow in use: ` &lt;http:endpoint exchange-pattern="request-response" address="http://localhost:8080/MyProject/page-sucess.html" name="page" method="POST"/&gt; &lt;flow name="Create_Work_Flow" doc:name="Create_Work_Flow"&gt; &lt;http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:28146/CallObject" contentType="text/html" doc:name="Request"&gt; &lt;http:body-to-parameter-map-transformer doc:name="HTMLForm-Parameters-To-Mule"/&gt; &lt;/http:inbound-endpoint&gt; &lt;logger level="INFO" doc:name="Form-Parameters" message="#[payload]" /&gt; &lt;http:outbound-endpoint exchange-pattern="request-response" method="POST" doc:name="HTTP" ref="Page"&gt; &lt;custom-transformer class="com.ExecuteWorkflow" doc:name="Call-CreateWorkflow"/&gt; &lt;/http:outbound-endpoint&gt; &lt;/flow&gt;`
score: 0
has title: Mule - Communication between Web application and Mule ESB
type: UnansweredQuestion
tagged with: java
tagged with: mule
type: Question
has answer: http://stackoverflow.com/a/21571058
answer count: 1

http://stackoverflow.com/q/21585069
has comment: http://stackoverflow.com/comment/32611803
favorite count: 0
has comment: http://stackoverflow.com/comment/32608140
has title: GLSL shader using multiple sampler2Ds
type: AnsweredQuestion
downvote count: 0
has body: I'm trying to develop a GLSL shader that uses two sampler2Ds, but I'm having some issues. Fragment shader: varying vec4 v_color; varying vec2 v_texCoord0; uniform sampler2D u_texture; uniform sampler2D my_second_texture; void main() { vec4 original_color = texture2D(u_texture, v_texCoord0); gl_FragColor = original_color; } This shader should output an unaltered u_texture. Drawing code: spritebatch.begin(); spritebatch.setShader(my_shader); my_shader.setUniformi("my_second_texture", 1); Gdx.gl20.glActiveTexture(1); my_second_texture.bind(1); //Around here is where things go wrong, I think... Gdx.gl20.glActiveTexture(0); Gdx.gl.glClearColor(bg_color.r, bg_color.g, bg_color.b, bg_color.a); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); spritebatch.setTransformMatrix(new Matrix4()); spritebatch.setColor(1, 1, 1, 1); spritebatch.draw(my_first_texture, -960, -540, 1920, 1080, 0, 0, 1920, 1080, false, true); spritebatch.end(); The result on the screen is my_second_texture stretched across the whole screen. The expected result is an unaltered my_first_texture on the screen. (For the curious: The ultimate goal is a palette swap shader.) How can I make a shader that properly uses two sampler2Ds, using GLSL and LibGDX?
accepted answer: http://stackoverflow.com/a/21588202
tagged with: opengl
tagged with: glsl
score: 1
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21588202
tagged with: libgdx
has comment: http://stackoverflow.com/comment/32609298
upvote count: 1
answer count: 1
has comment: http://stackoverflow.com/comment/32611026

http://stackoverflow.com/a/21591945
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/21583170
accepted answer of: http://stackoverflow.com/q/21583170
has body: Here it is, approximately. I'm sure I've screwed something up. scaleFactor would presumably be 327.68, to reverse the scaling above. The above code appears to be big endian. Whether you want fullNormalize is up to you. public byte[] doubleArrayToByteArray(double[] input, int bytesPerSample, double scaleFactor, boolean fullNormalize, boolean bigEndian) { byte[] result = new byte[input.length * bytesPerSample]; performNormalization(input, scaleFactor, fullNormalize); for (int i = 0; i &lt; input.length; i++) { long sourceVal = (long)(input[i] * scaleFactor); sourceVal = sourceVal &gt;&gt; 8 * (8 - bytesPerSample); for (int j = 0; j &lt; bytesPerSample; j++) { int index = i * bytesPerSample; if (bigEndian) { index += (bytesPerSample - j); } else { index += j; } result[index] = (byte) sourceVal; sourceVal = sourceVal &gt;&gt; 8; } } return result; } public void performNormalization(double[] input, double scaleFactor, boolean fullNormalize) { double maxVal = 0.0; for (int i = 0; i &lt; input.length; i++) { double val = Math.abs(input[i]) * scaleFactor; if (val &gt; maxVal) { maxVal = val; } } if (fullNormalize || maxVal &gt; Long.MAX_VALUE) { double normalizeFactor = (double)(Long.MAX_VALUE) / maxVal; for (int i = 0; i &lt; input.length; i++) { input[i] *= normalizeFactor; } } } Updated: Realized that I needed to account for scaleFactor in normalization. And you'd not normally specify both a scaleFactor that was not 1.0 and fullNormalize = true.
upvote count: 2
type: AcceptedAnswer
type: Answer

http://stackoverflow.com/a/21521161
score: 1
type: Answer
has body: That's because you're overwriting the row created at index 1 in this for loop. for(int i=1;i&lt;7;i++){ // when i = 1 Cell c3=ws.createRow(i).createCell(0); // it recreates a row at that index c3.setCellValue(i); // and re-writes it here in the loop. } You need to change the loop to start creating rows from the index 2. for(int i=2; i&lt;7; i++) { // now it starts from row index 2 and doesn't overwrite your previous row created at index 1 Cell c3=ws.createRow(i).createCell(0); c3.setCellValue(i); }
upvote count: 1
answers question: http://stackoverflow.com/q/21521123
downvote count: 0

http://stackoverflow.com/comment/54034448
type: Comment
has text: You set a ten minute timeout and you got a timeout after ten minutes. Why are you surprised? This is not making any sense.
type: AnswerComment
comment on: http://stackoverflow.com/a/21615005
score: 0

dependency-injection
tags question: http://stackoverflow.com/q/21655720
tags question: http://stackoverflow.com/q/21661645
type: Tag
tags question: http://stackoverflow.com/q/21561109
tags question: http://stackoverflow.com/q/21523736
tags question: http://stackoverflow.com/q/21591780
tags question: http://stackoverflow.com/q/21534723
tags question: http://stackoverflow.com/q/21575365
tags question: http://stackoverflow.com/q/21661108
tags question: http://stackoverflow.com/q/21522485
tags question: http://stackoverflow.com/q/21640022
tag name: dependency-injection
tags question: http://stackoverflow.com/q/21651732

http://stackoverflow.com/q/21654808
score: -1
has comment: http://stackoverflow.com/comment/32730180
type: Question
has comment: http://stackoverflow.com/comment/32729491
has body: This is an example i am working with to LEARN java, i am trying to make one of the boxes a .png file, I have on my computer, but as you can probably already guess it doesn't work. I was thinking that it had to do with my class being string text. My questions are: 1) Would i have to make a new class for an image?, but i think all arguments were still passed along as string anyway? 2) Should i try to use another method such as "repainting the canvas"? 3) Should i use ImageIcon(s) instead? on ImangePanel? Here is my source code: import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.awt.Toolkit; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Image; public class DragButton extends JButton{ private volatile int draggedAtX, draggedAtY; public DragButton(String text){ super(text); setDoubleBuffered(false); setMargin(new Insets(0, 0, 0, 0)); setSize(100, 100); setPreferredSize(new Dimension(25, 25)); addMouseListener(new MouseAdapter(){ public void mousePressed(MouseEvent e){ draggedAtX = e.getX(); draggedAtY = e.getY(); } }); addMouseMotionListener(new MouseMotionAdapter(){ public void mouseDragged(MouseEvent e){ setLocation(e.getX() - draggedAtX + getLocation().x, e.getY() - draggedAtY + getLocation().y); } }); } public static void main(String[] args){ JFrame frame = new JFrame("DragButton"); frame.setLayout(null); frame.getContentPane().add(new DragButton("1")).setLocation(300, 500); frame.getContentPane().add(new DragButton("2")).setLocation(100, 100); frame.getContentPane().add(new DragButton("3")).setLocation(75, 75); frame.getContentPane().add(new DragButton("yo")).setLocation(310, 310); ImagePanel panel = new ImagePanel( new ImageIcon("C:\\Users\\Donnie\\Desktop\\gtav.jpg").getImage()); frame.getContentPane().add(panel); Toolkit tk = Toolkit.getDefaultToolkit(); int xSize = ((int) tk.getScreenSize().getWidth()); int ySize = ((int) tk.getSc…
has comment: http://stackoverflow.com/comment/32729362
has comment: http://stackoverflow.com/comment/32729271
answer count: 1
downvote count: 1
linked to: http://stackoverflow.com/q/9864267
favorite count: 0
upvote count: 0
has comment: http://stackoverflow.com/comment/32729440
type: UnansweredQuestion
tagged with: swing
has answer: http://stackoverflow.com/a/21655057
has title: java image won't load in .contentpane?
tagged with: java

http://stackoverflow.com/a/21549952
answers question: http://stackoverflow.com/q/21549371
has body: http://docs.spring.io/spring/docs/4.0.1.RELEASE/spring-framework-reference/htmlsingle/#aop-introduction-defn Under 8.1.1, item weaving, it says: Weaving: linking aspects with other application types or objects to create an advised object. This can be done at compile time (using the AspectJ compiler, for example), load time, or at runtime. Spring AOP, like other pure Java AOP frameworks, performs weaving at runtime. Spring doesn't do the same type of load-time weaving as AspectJ, but works on proxies, as described in another part of the documentation: http://docs.spring.io/spring/docs/4.0.1.RELEASE/spring-framework-reference/htmlsingle/#aop-understanding-aop-proxies Edit: Just saw your comment, you are correct in that assumption. The documentation gives a rather complete explanation of how it works exactly. :)
accepted answer of: http://stackoverflow.com/q/21549371
score: 16
type: AcceptedAnswer
downvote count: 0
upvote count: 16
type: Answer

http://stackoverflow.com/q/21604243
accepted answer: http://stackoverflow.com/a/21605183
tagged with: java
score: 17
tagged with: concurrency
has answer: http://stackoverflow.com/a/21604858
upvote count: 17
type: Question
has answer: http://stackoverflow.com/a/21604808
has body: I have got two versions of "Initialization-on-demand holder idiom": http://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom http://en.wikipedia.org/wiki/Singleton_pattern#The_solution_of_Bill_Pugh The major difference between above is that the first one declared INSTANCE as private, but the second one declared INSTANCE as public. Please tell me which one should I use. Sorry, I have not found the difference between using private and public in my application: public class Singleton { private int x; public int getX() { return x; } private Singleton () {} private static class LazyHolder { //both private and public works private static final Singleton INSTANCE = new Singleton(); } public static Singleton getInstance() { return LazyHolder.INSTANCE; } } The only thing I do is to call something like Singleton.getInsance().getX(), so both versions works. Thus I want to know the situations for using them.
possible better answer: http://stackoverflow.com/a/21604808
has title: Correct implementation of initialization-on-demand holder idiom
answer count: 3
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/21605183
tagged with: design-patterns
type: AnsweredQuestion

http://stackoverflow.com/q/21617928
downvote count: 0
answer count: 1
has body: I am making a Bluetooth app which connects to a Bluetooth transmitter/receiver which is transmitting serial data. The Bluetooth device will eventually be connected to sensors and these sensors will provide data which needs to be displayed on my phone. As of now am using the simulation software CoolTerm to send data back and forth between my app and the external Bluetooth device. Currently I have successfully made the app detect and connect to devices. But I am running into some problems: Firstly does any one know how to install CoolTerm( its available on Mac and windows technically speaking), but when I try to install it on Ubuntu it gives no executable file like it did on windows. Anyone who knows how to install this on ubuntu please provide me the steps I have already downloaded the Linux version tar ball from there website and unziped it. Although on successful connection my app sends a string which is received by the Bluetooth device I am not able to receive data back. The way I have things currently set up I expect a toast message to pop-up telling me I have received data when the external Bluetooth device transmits to me. The CoolTerm software allows you to send data but this is for some reason not being displayed on my app. Any ideas? Lastly anyone know a good text box widget or something I can use in my app to send data to the external Bluetooth device. Right now I have the app send a string as soon as it connects. Here is a YouTube link: I have made some minor changes to this as the code will suggest. Click [here](http://www.youtube.com/watch?v=r55C77_ohi8"youtube video of app")! Click [here](https://drive.google.com/?tab=mo&amp;authuser=0#folders/0BwRY4KO_k7sUSGpLX0o4TDFCOFk"cleaner code formmatt")! Here is the code package com.example.intellicyclemobileside; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.HashSet; import java.util.Set; import java.util.UUID; import android.o…
favorite count: 0
type: UnansweredQuestion
tagged with: android
tagged with: serial-port
score: 1
tagged with: java
upvote count: 1
has answer: http://stackoverflow.com/a/21631023
tagged with: youtube
type: Question
has title: Android Application communication serial data
tagged with: bluetooth

http://stackoverflow.com/q/21576726
favorite count: 0
has comment: http://stackoverflow.com/comment/32592316
has comment: http://stackoverflow.com/comment/32592354
has answer: http://stackoverflow.com/a/21576898
type: UnansweredQuestion
upvote count: 1
has comment: http://stackoverflow.com/comment/32592044
tagged with: object
has title: Should a default implementation of an interface with stub methods be abstract?
score: 1
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21576791
downvote count: 0
has comment: http://stackoverflow.com/comment/32592067
has answer: http://stackoverflow.com/a/21576799
has answer: http://stackoverflow.com/a/21576914
has comment: http://stackoverflow.com/comment/32592078
has body: Suppose I have an interface interface MyInterface { void doSomething(); void doSomethingElse(); /* way more methods */ } and maybe a default implementation like this: class StubbedMyInterface implements MyInterace { void doSomething() { throw new UnsupportedOperationException(); } void doSomethingElse() { throw new UnsupportedOperationException(); } /* all the other methods */ } The stubbed class simply exists so that implementers of the interface don't need to implement all the methods they do not care about. Should the class StubbedMyInterface be declared abstract? Or should it have a protected default constructor (so that e.g. a unit test for StubbedMyInterface which checks that all methods throw the desired exception can instantiate the class without creating a needless subclass)? Or should the class just be a normal public class? UPDATE: OK, I see I should provide more context. This problem occured while implementing a visitor pattern for an Abstract Syntax Tree. The interface defines one method per node type in the tree and these are quite a lot of types. I have several of these Stub implementation: One like the one above which is useful e.g. when processing the children of a certain node - in this case I know that only node type A,B and C can possibly be a child of the node whose children I process. And if I got this wrong I want some error message to point me to the problem. One which just has empty implementations for each method - which is useful if I want to process only nodes I know what to do with and ignore the others. One which by default traverses the children of each node which is useful if I want to traverse a full tree but care only about certain node types.
answer count: 4

http://stackoverflow.com/a/21561248
has comment: http://stackoverflow.com/comment/32565820
has comment: http://stackoverflow.com/comment/32564738
has comment: http://stackoverflow.com/comment/32564553
answers question: http://stackoverflow.com/q/21561004
downvote count: 0
has comment: http://stackoverflow.com/comment/32564683
has body: I've got a game using the same libraries running just fine. Here's the library information (using 'file') for the libraries that work: libs/armeabi/libgdx-freetype.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, stripped libs/armeabi-v7a/libgdx-freetype.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, stripped Check that you've got the proper libs and it should work just fine. FWIW, I'm running the nightlies (1.0-SNAPSHOT). You might also want to check that you are running on ARM Android, since that is what those libraries are for. If you're running on x86 Android I am not sure that the freetype extension is supported.
has comment: http://stackoverflow.com/comment/32566121
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/q/21522491
has comment: http://stackoverflow.com/comment/32496166
score: 0
has answer: http://stackoverflow.com/a/21522656
answer count: 1
has comment: http://stackoverflow.com/comment/32496701
has body: i build an desktop application java using NetBeans IDE 7.4 ,add CSS file from file->new file->other->Cascading Style Sheet . iam write a css : JPanel{ background: red ; } but there is no effect on JPanel background , where is the problem ?
linked to: http://stackoverflow.com/q/5956934
tagged with: css
tagged with: netbeans
type: UnansweredQuestion
type: Question
tagged with: java
has comment: http://stackoverflow.com/comment/32496819
has title: CSS using with java application in NetBeans

http://stackoverflow.com/a/21648395
has body: static void insertInOrder( int[] arr, int count, int newVal ) { arr[count] = newVal; //This appends the number for( count = 1; count&lt;arr.length; count++) Here you are mixing to different variables called count. One is the input parameter and the other is the variable local to for loop. Change your for loop to: for( int i = 1; i&lt;count; i++) // you need to loop only till the newest index just added. As for converting from descending to ascending, then provided your descending algorithm works, you just need to change your comparison operator: while((leftVal &gt; 0) &amp;&amp; (arr[leftVal-1]&gt;newVal)) ^
accepted answer of: http://stackoverflow.com/q/21648170
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/21648170
type: AcceptedAnswer
upvote count: 1
type: Answer

http://stackoverflow.com/a/63142630
answers question: http://stackoverflow.com/q/21673618
type: Answer
has comment: http://stackoverflow.com/comment/120186137
has body: I also faced the same issue, but after adding dependency in pom error got removed. commons-io commons-io 2.6 you can also refer URL http://zetcode.com/java/fileutils/
upvote count: 5
score: 5
downvote count: 0

http://stackoverflow.com/q/21647744
accepted answer: http://stackoverflow.com/a/23902948
upvote count: 1
has comment: http://stackoverflow.com/comment/32717136
type: Question
type: AnsweredQuestion
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32716683
has body: I have a search view in my activity. When I am trying to attach an OnQueryTextListener, it gives me a NullPointerException. Its Java code is as follows @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.allpurpose, menu); MenuItem searchItem = menu.findItem(R.id.apmenu_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() { public boolean onQueryTextChange(String newText) {return true;} public boolean onQueryTextSubmit(String query) {return true;} }; searchView.setOnQueryTextListener(queryTextListener); return super.onCreateOptionsMenu(menu); } XML Code: &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" &gt; &lt;item android:id="@+id/apmenu_search" android:icon="@android:drawable/ic_menu_search" android:title="@string/srch" android:showAsAction="ifRoom" android:actionViewClass="android.support.v7.widget.SearchView" /&gt; &lt;/menu&gt;
has answer: http://stackoverflow.com/a/23902948
has title: Attaching OnQueryTextListener to SearchView gives NullPointerException
downvote count: 0
answer count: 1
tagged with: android-menu
favorite count: 0
tagged with: searchview
tagged with: android
linked to: http://stackoverflow.com/q/18438890

http://stackoverflow.com/a/21619221
has body: Basically, you shouldn't use List#add if you want to replace elements (and not add them). You could do the following: private static void reverse(final List&lt;Integer&gt; list, final int index) { if (index &gt;= list.size()) { return; } final int currentVal = list.get(index); reverse(list, index + 1); list.set(list.size() - 1 - index, currentVal); } Although not being efficient for LinkedLists, it will work. :) On the other hand, if you really want your method to work by add-ing elements to a new List, then it'll have to return that List and thus, its signature should be: private static List&lt;Integer&gt; reverse(final List&lt;Integer&gt; list, final int index) Basically, in that case, you would: create and return a new List when there is nothing left to reverse, then recursively reverse the rest of the given List and finally add the current element at the end of the new List before returning it. For example: private static List&lt;Integer&gt; reverse(final List&lt;Integer&gt; list, final int index) { if (index &gt;= list.size()) { return new LinkedList&lt;&gt;(); } final List&lt;Integer&gt; res = reverse(list, index + 1); res.add(list.get(index)); return res; } (if you do that, don't forget to iterate over reverse(list, 0) and not directly list in your main method) Just a final point, as @Sundeep pointed out, in this case, using a simple loop would be more efficient - but we believe you actually want to play around with recursion... :)
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21619114
has comment: http://stackoverflow.com/comment/32667758
answers question: http://stackoverflow.com/q/21619114
type: Answer
upvote count: 2
score: 2
has comment: http://stackoverflow.com/comment/32667922

http://stackoverflow.com/comment/32643592
comment on: http://stackoverflow.com/q/21606112
score: 0
type: QuestionComment
type: Comment
has text: If it's static why would it take any time to load?

http://stackoverflow.com/q/21540021
has title: MapReduce-Cassandra wordcount compilation error: ConfigHelper not found
score: 0
answer count: 1
tagged with: cassandra
has body: I am trying to run WordCount MapReduce program to read and count data stored in Cassandra table (Column Family) but, when I compile my program I got the same error repeated times. Below is my source code and error I got. Can anyone help me to solve this issue? Thanks in advance. import java.io.IOException; import java.nio.ByteBuffer; import java.util.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configured; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.Text; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.Mapper; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; import org.apache.cassandra.db.IColumn; import org.apache.cassandra.hadoop.*; import org.apache.cassandra.hadoop.ColumnFamilyInputFormat; import org.apache.cassandra.hadoop.ConfigHelper; import org.apache.cassandra.thrift.*; import org.apache.cassandra.utils.ByteBufferUtil; /** * This sums the word count stored in the input_words_count ColumnFamily for the key "key-if-verse1". * * Output is written to a text file. */ public class WordCountCounters extends Configured implements Tool { private static final Logger logger = LoggerFactory.getLogger(WordCountCounters.class); static final String COUNTER_COLUMN_FAMILY = "input_words"; private static final String OUTPUT_PATH_PREFIX = "/Users/Deepu/Documents/dse-3.2.4/dse-data/word_count_counters"; public static void main(String[] args) throws Exception { // Let ToolRunner handle generic command-line options ToolRunner.run(new Configuration(), new WordCountCounters(), args); System.exit(0); } public static class SumMapper extends Mapper&lt;ByteBuffer, SortedMap&lt;ByteBuffer, IColumn&gt;, Text, LongWritable&gt; { public void map(ByteBuffer key, SortedMap&lt;ByteBuffer, IColumn&gt; columns, Context context) …
type: UnansweredQuestion
tagged with: datastax-enterprise
tagged with: java
has answer: http://stackoverflow.com/a/21540112
tagged with: mapreduce
type: Question
tagged with: hadoop

http://stackoverflow.com/comment/32843317
type: Comment
comment on: http://stackoverflow.com/a/21618875
score: 0
type: AnswerComment
has text: That process always confuses me... http://chat.stackoverflow.com/rooms/47281/visual-custom-grid

http://stackoverflow.com/q/21644970
has comment: http://stackoverflow.com/comment/32711834
has answer: http://stackoverflow.com/a/21644992
answer count: 5
has answer: http://stackoverflow.com/a/21644985
has answer: http://stackoverflow.com/a/21644987
has title: Split function doesn't work
downvote count: 0
has comment: http://stackoverflow.com/comment/32712715
type: UnansweredQuestion
tagged with: java
has body: Here is a function which take a long String and return a string divided in paragraph. The problem is that k is empty. Why split() function doesn't work? private String ConvertSentenceToParaGraph(String sen) { String nS = ""; String k[] = sen.split("."); for (int i = 0; i &lt; k.length - 1; i++) { nS = nS + k[i] + "."; Double ran = Math.floor((Math.random() * 2) + 4); if (i &gt; 0 &amp;&amp; i % ran == 0) { nS = nS + "\n\n"; } } return nS; }
type: Question
tagged with: split
score: 3
has answer: http://stackoverflow.com/a/21645052
has answer: http://stackoverflow.com/a/21644986
linked to: http://stackoverflow.com/q/7935858
upvote count: 3
tagged with: string
favorite count: 0

http://stackoverflow.com/q/21647650
has answer: http://stackoverflow.com/a/21657772
type: Question
has comment: http://stackoverflow.com/comment/32717650
score: 0
answer count: 2
has body: I am new to java programming and I have created a program which integrates selenium, apachepoi and java swing. While compiling the program I was able to compile it successfully and the program does run right; however when I tried making a jar file for my program it shows java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Row error. Below is my program's folder structure c:\users\userid\documents\java\crazyrunner The java file is with name CrazyRunner.java within crazyrunner folder The program is within a package with name crazyrunner (first line of the program starts with package crazyrunner) Command used to compile (not sure whether it is relevant) javac -encoding UTF8 crazyrunner\CrazyRunner.java Compilation resulted in creation of .class files in both parent (java) and child (crazyrunner) folders Command used to run java crazyrunner.CrazyRunner (This worked just fine) Command used generate the jar jar cvfm CrazyRunner.jar manifest.mf *.class crazyrunner\*.class The result of the jar command is successfull and all class files within crazyrunner and outside crazyrunner (within the parent folder 'Java') are added to the jar (CrazyRunner.jar) The manifest.mf file has data as below Manifest-Version: 1.0 Created-By: Eric Stanley Main-Class: crazyrunner.CrazyRunner Class-Path: "C:\poi-3.10-beta2\poi-3.10-beta2-20130904.jar" "C:\poi-3.10-beta2\poi-examples-3.10-beta2-20130904.jar" "C:\poi-3.10-beta2\poi-excelant-3.10-beta2-20130904.jar" .. Ends with 2 new lines Not sure about what am I missing :-( and I have spent a whole damn day fixing this and left without choice but to post this q!! and yes I did tried all options that stackoverflow already has and nothing worked out :-( Option 1: Open the Control Panel Go to System Go to Advanced Systems Properties Then Environment Variables In System Variables, click Add New Variable Name: _JAVA_OPTIONS New Variable Value: -Xmx512M (tried -Xmx1024M too) Click OK Option 2: Reinstall Java Option 3: Open the Run box Enter msc…
tagged with: classpath
has comment: http://stackoverflow.com/comment/32716844
has comment: http://stackoverflow.com/comment/32717272
tagged with: java
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32717553
has answer: http://stackoverflow.com/a/21648580
has title: java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Row Error during runtime
tagged with: classnotfound
tagged with: jar

http://stackoverflow.com/comment/32739308
type: Comment
comment on: http://stackoverflow.com/a/21651334
type: AnswerComment
has text: I did, but nothing would happen. The JFrame is not popping up.
score: 0

http://stackoverflow.com/q/21638562
has comment: http://stackoverflow.com/comment/32701275
has comment: http://stackoverflow.com/comment/32701242
type: Question
has answer: http://stackoverflow.com/a/21638828
has comment: http://stackoverflow.com/comment/32701429
score: 0
answer count: 2
has body: I have an issue with a generic class in Java and I am not sure how to solve it. I started programming with java and generics a few days ago so it could be a very well known issue. My class definition is something like this: public Class LocalAuthCommand&lt;T extends LocalAuth&gt; { public LocalAuthCommand() { ... } public String execute() throws CustomException { String result = super.execute(); T obj = T.unMarshall(result); } } unMarshall is a static method that is implemented in all subclasses of LocalAuth. All T classes implement this method, but I don't know how to make Java know that unMarshall does exist as static method in T. Any ideas how to solve this? Thanks!
has title: Invoking a static method from a generic
tagged with: generics
linked to: http://stackoverflow.com/q/5191459
accepted answer: http://stackoverflow.com/a/21638828
possible better answer: http://stackoverflow.com/a/21638718
has answer: http://stackoverflow.com/a/21638718
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32701558
has comment: http://stackoverflow.com/comment/32701396
tagged with: java

http://stackoverflow.com/comment/32561588
has text: Use a stack. It looks suitable.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21559607

http://stackoverflow.com/comment/32751148
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21666689
score: 0
has text: You sir have helped out tremendously. Thank you.

http://stackoverflow.com/comment/32672430
comment on: http://stackoverflow.com/a/21620731
type: AnswerComment
score: 0
type: Comment
has text: @JackSparrow: Seems that so many things are done by framework and not under your control. What about generating a token(UUID e.g.) every time when a user is trying to login, and then store the token in both cookie and user session. Next time, when the logged in user is trying to re-login from another browser, you could found the token in session, but from the browser cookie. Then you can discover it is a login request from a different browser.

http://stackoverflow.com/q/21514447
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/21537649
has body: I am trying to create a tag cloud in GWT but should be in circular shape and the tags should be randomly arranged. So I wanted to know if it is possible to make a circular panel? till now, I couldn't find any relevant information about tag clouds in GWT except this link. Thanks in advance.
tagged with: panel
favorite count: 0
upvote count: 2
type: UnansweredQuestion
has title: GWT: Is it possible to draw a circular panel?
tagged with: gwt
score: 2
tagged with: java
has answer: http://stackoverflow.com/a/21514841
type: Question

http://stackoverflow.com/a/21590089
answers question: http://stackoverflow.com/q/21589521
downvote count: 0
score: 4
has comment: http://stackoverflow.com/comment/32616976
has body: Since your confirm dialog has two possible outcomes you can write a simple if-else block like this: int confirmDialog = JOptionPane.showConfirmDialog(null, "You selected quit! \nAre you sure you want to quit?", "Selected Quit", JOptionPane.YES_NO_OPTION); if(confirmDialog == JOptionPane.YES_OPTION) { System.exit(0); //focus under this comment here } else { game.reset(); displayBoard(); } Note the use of static field JOptionPane.YES_OPTION makes your code more robust. I can see the board reseting. But the optionPane does not go away and i want the OptionPane to go away so they can play. Check if something in game.reset() is blocking the Event Dispatch Thread (a.k.a. EDT). The EDT is a single and special thread where Swing components creation and update take place. If there's some time consuming task blocking the EDT your GUI may become unresponsive. See more in Concurrency in Swing trail. Off-topic About this line: System.exit(0); This method terminates the currently running JVM as stated in System.exit(int status) javadoc. This is actually a bad practice. When working with Swing you should call dispose() on your JFrame and that should terminate the JVM if there's no pending threads working.
has comment: http://stackoverflow.com/comment/32616843
type: Answer
upvote count: 4

imageicon
tags question: http://stackoverflow.com/q/21633505
tags question: http://stackoverflow.com/q/21550916
tags question: http://stackoverflow.com/q/21577360
tags question: http://stackoverflow.com/q/21568535
tag name: imageicon
tags question: http://stackoverflow.com/q/21548411
tags question: http://stackoverflow.com/q/21593321
tags question: http://stackoverflow.com/q/21616900
type: Tag
tags question: http://stackoverflow.com/q/21533356

http://stackoverflow.com/comment/65920971
type: AnswerComment
comment on: http://stackoverflow.com/a/21873055
type: Comment
has text: @D-Klotz +1 for "whether this is thread safe is asking if a hammer is a hammer"
score: 0

http://stackoverflow.com/comment/32685234
comment on: http://stackoverflow.com/q/21623697
has text: @Augusto thank you for your reply. Well this is what i have done until now but i thought maybe there is a better way that i do not know about. I aslo do an automatic restart of the program after i update all references to make sure hibernate references no old objects.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/28186549
downvote count: 1
has body: If you can use Guava library: Iterables.all(input, Predicates.isNull()); With static import it will become even more readable: import static com.google.common.base.Predicates.isNull; import static com.google.common.collect.Iterables.all; Iterable&lt;?&gt; input = ... all(input, isNull())
type: Answer
score: 2
answers question: http://stackoverflow.com/q/21592835
upvote count: 3

http://stackoverflow.com/comment/32730915
comment on: http://stackoverflow.com/q/21655753
score: 0
type: QuestionComment
type: Comment
has text: This statement, `"Unfortunately because of my poor project design i'm keeping the final JFrame in to switch out my frames when needed,..."`, seems to assume that we understand things not yet explained to us. If you don't get a decent answer soon, please explain the details of your problem.

http://stackoverflow.com/comment/32640171
score: 0
comment on: http://stackoverflow.com/q/21603291
type: Comment
type: QuestionComment
has text: Stack traces would definitely help. Have you tried using `jstack <pid>` to see what is happening in the thread?

http://stackoverflow.com/q/21515184
has body: I created a TimerTask with the following code: Screen_Timer_Task = new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { @Override public void run() { // Do my stuff } }); } }; Then, I start that TimerTask with that: Screen_Timer.scheduleAtFixedRate(Screen_Timer_Task, 1, 1); This is working fine. But after calling Screen_Timer.cancel(); Screen_Timer.purge(); it will not restart with Screen_Timer.scheduleAtFixedRate(Screen_Timer_Task, 1, 1); The app is just crashing!!
downvote count: 0
favorite count: 0
tagged with: timer
tagged with: android
has answer: http://stackoverflow.com/a/21515203
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21515336
upvote count: 3
tagged with: java
possible better answer: http://stackoverflow.com/a/21515203
tagged with: timertask
type: Question
tagged with: eclipse
has title: Android: Restart Timer
accepted answer: http://stackoverflow.com/a/21515336
answer count: 2
score: 3

embeddedwebserver
tags question: http://stackoverflow.com/q/21633162
tag name: embeddedwebserver
type: Tag

http://stackoverflow.com/q/21580564
has title: Periodic check if status from file change RCP
score: 1
tagged with: java
has body: What is concept of method which will periodic check book status from XML file and if status changed it will alert, with RCP ? I want to create task which will do this. Main class I have in JFrame. Here is XmlFile and POJO. package net.kxyz; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import xyz.libary.Book; import xyz.libary.DataInterface; /** * * @author kuman */ public class XmlDataInterfaceImpl implements DataInterface { File fXmlFile = new File("baza.xml"); ArrayList&lt;Book&gt; book = new ArrayList&lt;&gt;(); @Override public void updateBook(Book book2) { int index = book2.getId(); this.book.get(index).setTitle(book2.getTitle()); this.book.get(index).setAuthor(book2.getAuthor()); this.book.get(index).setYear(book2.getYear()); this.book.get(index).setState(book2.isState()); } @Override public ArrayList&lt;Book&gt; getAllBooks() { //code return book; } public void addBook(Book book2) { //code } @Override public void deleteBook(Book book) { //code } private void toFile() { //code } } POJO /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package xyz.libary; /** * * @author kuman */ public class Book { int id; String title; String author; int year; Boolean state; public Book() {}; public Book(int id, String title, String author, …
type: Question
upvote count: 1
accepted answer: http://stackoverflow.com/a/21580765
answer count: 1
favorite count: 0
tagged with: eclipse-rcp
has answer: http://stackoverflow.com/a/21580765
downvote count: 0
tagged with: task
type: AnsweredQuestion

http://stackoverflow.com/q/21596664
has body: please help me with this.. anyone please tell me how to send an arraylist> value from fragmentactivity to its fragment as from this value i have to create listview using simple adapter.. before this i have send the value from activity to fragmentactivity using putExtra(string, serializable) then fetching it in fragmentactivity using getintent.getSerializable extra..but after that i don't know hwo to use this value is fragment for list view.. This is mainactivity from where i am sending the value @Override protected void onPostExecute(Void result) { // TODO Auto-generated method stub super.onPostExecute(result); progress.dismiss(); Intent i = new Intent(MainActivity.this, Pager.class); i.putExtra("DATALIST", datatList); //Toast.makeText(getApplicationContext(), "Bundle Value" +datatList, Toast.LENGTH_LONG).show(); startActivity(i); this is pager extends fragmentactivity Intent intent = getIntent(); data = (ArrayList&lt;HashMap&lt;String, String&gt;&gt;) intent.getSerializableExtra("DATALIST"); Toast.makeText(getApplicationContext(), "Bundle Value in pager" +data, Toast.LENGTH_LONG).show(); now i want to use "data value " in fragment of pager from listview please explain how.. public class TabsPagerAdapter extends FragmentPagerAdapter { public TabsPagerAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int index) { switch (index) { case 0: // Top Rated fragment activity return new TopRatedFragment(); case 1: // Games fragment activity return new GamesFragment(); case 2: // Movies fragment activity return new MoviesFragment(); } return null; } @Override public int getCount() { // get item count - equal to number of tabs return 3; } }
tagged with: android
type: AnsweredQuestion
tagged with: java
type: Question
answer count: 2
has title: how to send arraylist<hashmap<string, string>> value from fragmentactivity to fragment for listview
accepted answer: http://stackoverflow.com/a/21597105
has answer: http://stackoverflow.com/a/21597382
score: 0
possible better answer: http://stackoverflow.com/a/21597382
has answer: http://stackoverflow.com/a/21597105

http://stackoverflow.com/a/21671824
upvote count: 5
has body: From JLS: The type of the shift expression is the promoted type of the left-hand operand. The promoted type of byte is int - and that's the reason why, in most cases, you have to cast the result as follows: byte e = (byte) (0b1 &lt;&lt; getAnInt()); So the real question is why, on the first 3 lines, there is no need for casting. Now, that's not accurate either cause if you'll change the line: private final static int constant = 3; to: private final static int constant = 1000; you'll get a compilation error on: byte c = 0b1 &lt;&lt; constant; as well. The shift operation might create an integer number which has bigger value than the byte on the left side of the assignment can hold - which triggers the compile-time error and forces us to cast to byte in order to grab only the least significant 8 bits. So why in the first 3 lines we didn't need to cast to byte ? The compiler recognized that we're using a constant (or a final) and thus "knows" that this value cannot be changed later on, so it allows Narrowing Primitive Conversion for the assignment to byte - on the left side: byte c = 0b1 &lt;&lt; 3;
score: 5
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21670416
has comment: http://stackoverflow.com/comment/32759694

http://stackoverflow.com/q/21557066
accepted answer: http://stackoverflow.com/a/21558683
type: AnsweredQuestion
downvote count: 0
score: 10
favorite count: 0
type: Question
answer count: 2
tagged with: spring
has answer: http://stackoverflow.com/a/21558683
tagged with: java
has title: How to wire a Quartz Scheduler into my Spring context?
tagged with: quartz-scheduler
upvote count: 10
has answer: http://stackoverflow.com/a/37832030
has body: I have an application in which I want to use a Quartz Scheduler object. I've read the Spring documentation regarding this and they suggest to use a SchedulerFactoryBean like this: true The config looks like this: org.quartz.scheduler.skipUpdateCheck = true org.quartz.scheduler.instanceName = MyQuartzScheduler org.quartz.scheduler.jobFactory.class = org.quartz.simpl.SimpleJobFactory org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool org.quartz.threadPool.threadCount = 5 log4j.rootLogger=INFO, stdout log4j.logger.org.quartz=DEBUG log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n Now if i want to inject schedulerFactoryBean into one of my objects I get an exception stating: Could not convert constructor argument value of type [org.quartz.impl.StdScheduler] to required type [org.springframework.scheduling.quartz.SchedulerFactoryBean]: Why do I get a StdScheduler instead of a schedulerFactoryBean? Do I miss a configuration step?
possible better answer: http://stackoverflow.com/a/37832030

http://stackoverflow.com/q/21645206
upvote count: 2
has comment: http://stackoverflow.com/comment/32712335
has body: I'm new to android. I just tried creating a simple app that performs basic mathematical operations (addition,subtraction,multiplication and division). When i try to run the code i get FATAL EXCEPTION: mainerror. I've gone through the other threads that had the same problem. I still couldn't figure out why i'm having this error. The mainactivity.java file is package com.example.mathematicalopr; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class MainActivity extends Activity { Button add,sub,mul,div; TextView display2; EditText display,display1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //int c=0; add = (Button) findViewById(R.id.bAdd); sub = (Button) findViewById(R.id.bSub); mul = (Button) findViewById(R.id.times); div = (Button) findViewById(R.id.divide); display = (EditText) findViewById(R.id.tvDisplay); String myFirstNum = display.getText().toString(); final int a = Integer.parseInt(myFirstNum); display1 = (EditText) findViewById(R.id.tvDisplay1); String mySecondNum = display1.getText().toString(); final int b = Integer.parseInt(mySecondNum); display2 = (TextView) findViewById(R.id.tvDisplay2); add.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub int c = a+b; display2.setText("Answer is"+c); } }); sub.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub int c = a-b; display2.setText("Answer is"+c); } }); mul.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub int c = a*b; display2.setText("Answer is"+c); } }); div.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v)…
has answer: http://stackoverflow.com/a/21645474
favorite count: 0
has comment: http://stackoverflow.com/comment/32712238
tagged with: android
has comment: http://stackoverflow.com/comment/32712414
answer count: 4
has comment: http://stackoverflow.com/comment/32712296
type: AnsweredQuestion
score: 2
downvote count: 0
tagged with: java
possible better answer: http://stackoverflow.com/a/21645344
has comment: http://stackoverflow.com/comment/32712395
has answer: http://stackoverflow.com/a/21645353
has comment: http://stackoverflow.com/comment/32712360
has comment: http://stackoverflow.com/comment/32712239
type: Question
has answer: http://stackoverflow.com/a/21645422
accepted answer: http://stackoverflow.com/a/21645422
has answer: http://stackoverflow.com/a/21645344
has comment: http://stackoverflow.com/comment/32712405
has title: FATAL EXCEPTION: main. (Runtime exception) . Android
tagged with: runtime-error

http://stackoverflow.com/comment/32710986
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21644312
has text: How is it that folks get rep for editing what is absolutely style choices? @BoristheSpider took out spaces that are w/o doubt legit, and actually created a format worse than op's and gets rep for it. Just look at the `for` loop format! It's clear an intentional style choice was purposefully edited out for the sake of rep leaving the op looking sub-par; awesome!!

http://stackoverflow.com/comment/32498510
type: AnswerComment
type: Comment
has text: also on trying to replace ndash with a string i get the following error SXXP0003: Error reported by XML parser: The entity "ndash" was referenced, but not declared
comment on: http://stackoverflow.com/a/21523662
score: 0

dayofweek
type: Tag
tags question: http://stackoverflow.com/q/21643339
tag name: dayofweek
tags question: http://stackoverflow.com/q/21621735

http://stackoverflow.com/comment/32632793
score: 2
comment on: http://stackoverflow.com/q/21599852
type: QuestionComment
type: Comment
has text: Are you sure you call `loadPage` and `changeResetPassword` in the correct order and moreover on the same instance ?

http://stackoverflow.com/q/21523551
has body: I have one Regex that contains this expression String EmployeeIdPattern = "^[^\\d-\\s][A-Z0-9].*(?&lt;!0)"; I am looking for which can take minimum 3 character like A001 but last character should not matched like A0000 so how I block ending zero and It should not take any special character. like@#$%%*()_+,It should block whitespaces at the start and end I want to pass,S023,S001... like that..
type: UnansweredQuestion
tagged with: regex
has answer: http://stackoverflow.com/a/21523726
tagged with: java
downvote count: 1
type: Question
score: -1
upvote count: 0
answer count: 1
favorite count: 0
has title: I am searching for Regex for employeeId for Jsf

http://stackoverflow.com/comment/32531604
has text: @mu is too short: ok updated the question w/ a shorter query.
comment on: http://stackoverflow.com/q/21540527
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32506203
has text: @IanRoberts [Not according to the JLS](http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.9.4). Fields are initialized to their default values before any constructor runs.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21527955

http://stackoverflow.com/comment/32553318
score: 0
comment on: http://stackoverflow.com/a/21555282
type: AnswerComment
has text: I don't think so, but maybe wait for some guys with more ui experience
type: Comment

http://stackoverflow.com/q/21572485
upvote count: 1
tagged with: urlconnection
favorite count: 0
has comment: http://stackoverflow.com/comment/32585026
answer count: 1
tagged with: utf-8
has title: Java URLConnection utf-8 encoding doesn't work
has comment: http://stackoverflow.com/comment/32585664
has comment: http://stackoverflow.com/comment/32585227
type: AnsweredQuestion
downvote count: 0
has comment: http://stackoverflow.com/comment/32585386
has comment: http://stackoverflow.com/comment/32585449
score: 1
tagged with: java
type: Question
has body: I'm writing a small crawler for sites in English only, and doing that by opening a URL connection. I set the encoding to utf-8 both on the request, and the InputStreamReader but I continue to get gobbledigook for some of the requests, while others work fine. The following code represents all the research I did and advice out there. I have also tried changing URLConnection to HttpURLConnection with no luck. Some of the returned strings continue to look like this: ??}?r?H????P?n?c??]?d?G?o??Xj{?x?"P$a?Qt?#&amp;??e?a#?????lfVx)?='b?"Y(defUeefee=??????.??a8??{O??????zY?2?M???3c??@ What am I missing? My code: public static String getDocumentFromUrl(String urlString) throws Exception { String wholeDocument = null; URL url = new URL(urlString); URLConnection conn = url.openConnection(); conn.setRequestProperty("Content-Type", "text/plain; charset=utf-8"); conn.setRequestProperty("Accept-Charset", "utf-8"); conn.setConnectTimeout(60*1000); // wait only 60 seconds for a response conn.setReadTimeout(60*1000); InputStreamReader isr = new InputStreamReader(conn.getInputStream(), "utf-8"); BufferedReader in = new BufferedReader(isr); String inputLine; while ((inputLine = in.readLine()) != null) { wholeDocument += inputLine; } isr.close(); in.close(); return wholeDocument; }
has answer: http://stackoverflow.com/a/21575331
tagged with: encoding
accepted answer: http://stackoverflow.com/a/21575331

http://stackoverflow.com/q/21669992
score: 0
has comment: http://stackoverflow.com/comment/32756268
linked to: http://stackoverflow.com/q/942035
has comment: http://stackoverflow.com/comment/32755973
has title: Why @Transient of ejb3 is not working as expected? It still gets persisted
tagged with: jpa
answer count: 1
tagged with: persistence
linked to: http://stackoverflow.com/q/594597
linked to: http://stackoverflow.com/q/4188048
has answer: http://stackoverflow.com/a/21672419
tagged with: ejb-3.0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32755903
has body: import javax.persistence.*; simple POJO class A { @Transient protected transient someClass X; } Despite this, in the database, I still see it persisted? Any idea of this weird behavior?
type: Question
has comment: http://stackoverflow.com/comment/32756172
accepted answer: http://stackoverflow.com/a/21672419
tagged with: java
has comment: http://stackoverflow.com/comment/32756106
tagged with: transient
has comment: http://stackoverflow.com/comment/32755932

http://stackoverflow.com/a/21579442
answers question: http://stackoverflow.com/q/21574468
has comment: http://stackoverflow.com/comment/32601309
downvote count: 0
type: Answer
upvote count: 3
score: 3
has body: The best way is to catch exception. If something go wrong an exception will be launched and you could remove the partially written file in this case. A second way is to have a in-memory stream before writing down to the filesystem but it consumes memory. A third way is to ensure the destination disk capacity (new File(path).getFreeSpace()) The MD5 check sounds too slow for me in regards of the question.

http://stackoverflow.com/a/21660869
accepted answer of: http://stackoverflow.com/q/21660394
has body: You can use a regex with the case insensitive modifier, like stated here: public ParseQuery&lt;T&gt; whereMatches(String key, String regex, String modifiers) Add a regular expression constraint for finding string values that match the provided regular expression. This may be slow for large datasets. Parameters: key - The key that the string to match is stored in. regex - The regular expression pattern to match. modifiers - Any of the following supported PCRE modifiers: &nbsp; &nbsp; i - Case insensitive search &nbsp; &nbsp; m - Search across multiple lines of input Returns: Returns the query, so you can chain this call.
answers question: http://stackoverflow.com/q/21660394
has comment: http://stackoverflow.com/comment/32786732
type: Answer
has comment: http://stackoverflow.com/comment/32739446
score: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/32786647
type: AcceptedAnswer
upvote count: 3

http://stackoverflow.com/a/21601788
has body: Every class in java extends the java.lang.Object class. This is useful for many cases such as this. The session holds attributes, but it doesn't limit you to the type of the attribute - it holds the attributes as Object type objects. Since java is statically typed (the compiler needs to know the type of every variable) you need to explicitly cast the attribute you have just get from the session to your type, as getAttribute() returns java.lang.Object object. See more at http://en.wikipedia.org/wiki/Downcasting
type: Answer
score: 0
answers question: http://stackoverflow.com/q/21601624

http://stackoverflow.com/comment/32712670
has text: Please provide further details, some background information and some code might help us...
comment on: http://stackoverflow.com/q/21645333
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21519233
tagged with: java
score: 2
has title: Java error: <identifier> expected timer.start() ;
downvote count: 0
answer count: 1
has answer: http://stackoverflow.com/a/21519245
favorite count: 0
has body: How do I fix this error? error: expected timer.start() import java.awt.event.ActionEvent ; import java.awt.event.ActionListener ; import javax.swing.JFrame ; import javax.swing.Timer ; /** This class illustrates using a Timer with a listener The listener illustrates using an interface. The program also illustrates that the inner class has access to constants in the local environment, but not variables. This is an example from the book, so the answer is there. Your job is 1. write the line that makes the Rectangle component, remembering that it will have to be a constant. 2. write the listener so that every time the timer ticks, it moves the rectangle in the component by (dx, dy) = (DELTA, DELTA). */ public class RectangleComponentViewerWithTimer { private static final int FRAME_WIDTH = 300 ; private static final int FRAME_HEIGHT = 400 ; private static final int DELTA = 2 ; private static final int LIMIT = 30 ; private static final int INTERVAL = 400 ; public static void main(String[] args) { //-----------Start below here. To do: approximate lines of code = 12 // 1. create the RectangleComponent1 object called component. //Hint: component will be used in the inner class RectangleComponent1 component = new RectangleComponent1(); //1. define class TimerListener, an ActionListener class TimerListener implements ActionListener {// //2. instance variable count starting at zero ; int count = 0; //3. actionPerformed method signature ; public void actionPerformed(ActionEvent event) {// //4. increment count ; count++; //5. tell component to moveBoxBy DELTA and DELTA ; component.moveBoxBy(DELTA, DELTA); //6. when count reaches the LIMIT if (count == LIMIT) //7. print component.toString() ; System.out.println(component.toString()); //8. stop the application System.exit(0); }// }// }// //9. make the listener ActionListener listener = new TimerListener(); //10. make the timer based on INTERVAL and listener Timer timer = new Timer(INTERVAL, listener); //11. start the timer timer.s…
type: AnsweredQuestion
tagged with: timer
upvote count: 2
accepted answer: http://stackoverflow.com/a/21519245
type: Question

http://stackoverflow.com/comment/32679119
has text: Yes I tried now it gives me this error " Caused by: java.lang.IllegalStateException: get field slot from row 0 col -1 failed"
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21625054

http://stackoverflow.com/a/21639429
type: Answer
accepted answer of: http://stackoverflow.com/q/21639325
has body: First, In Eclipse, you can use Ctrl-SHIFT-O to automatically import anything you need. From the java package tutorial: For convenience, the Java compiler automatically imports two entire packages for each source file: (1) the java.lang package and (2) the current package (the package for the current file). The IDE will not import all your packages because 1. You may not need them, why import them? More importantly, you can have classes in different packages with the same name, then this will cause name ambiguities. If a member in one package shares its name with a member in another package and both packages are imported, you must refer to each member by its qualified name. For example, the graphics package defined a class named Rectangle. The java.awt package also contains a Rectangle class. If both graphics and java.awt have been imported, the following is ambiguous. This would cause unnecessary headache making sure you are always referring to the correct package. By importing packages and classes yourself, you can be sure that you are always using the specific class that you intended to.
answers question: http://stackoverflow.com/q/21639325
score: 0
type: AcceptedAnswer

executorservice
type: Tag
tags question: http://stackoverflow.com/q/21550307
tag name: executorservice
tags question: http://stackoverflow.com/q/21676713

http://stackoverflow.com/a/21575368
has comment: http://stackoverflow.com/comment/32592135
score: 109
upvote count: 109
accepted answer of: http://stackoverflow.com/q/21574236
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21574236
has body: What is wrong here is that your session management configuration is set to close session when you commit transaction. Check if you have something like: thread in your configuration. In order to overcome this problem you could change the configuration of session factory or open another session and only then ask for those lazy loaded objects. But what I would suggest here is to initialize this lazy collection in getModelByModelGroup itself and call: Hibernate.initialize(subProcessModel.getElement()); when you are still in active session. And one last thing. A friendly advice. You have something like this in your method: for (Model m : modelList) { if (m.getModelType().getId() == 3) { model = m; break; } } Please insted of this code just filter those models with type id equal to 3 in the query statement just couple of lines above. Some more reading: session factory configuration problem with closed session
has comment: http://stackoverflow.com/comment/32591114

http://stackoverflow.com/comment/32495774
has text: // works fine, am able to skip those comments..but -- comments doesn't working
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21522410
type: Comment

http://stackoverflow.com/a/21647980
answers question: http://stackoverflow.com/q/21647337
has body: I don't use this library myself, but have you tried the HttpClient class? HttpClient client = new HttpClient(); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password)); GetMethod method = new GetMethod(uri); client.executeMethod(method); You still have to build the uri and set timeouts, but it could be an option.
score: 0
type: Answer

http://stackoverflow.com/a/21530703
type: AcceptedAnswer
downvote count: 0
has body: You are getting the error because your 'this' operator points to new AdapterView.OnItemSelectedListener() (the new listener you created). To fix this replace with: &lt;YourClassName&gt;.this. Also, I am not sure what you are trying to do but decalring the new adpater in the listener is not a very good idea. It would be better to just initialize it over there.
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/32511361
score: 1
accepted answer of: http://stackoverflow.com/q/21530476
answers question: http://stackoverflow.com/q/21530476

http://stackoverflow.com/q/21592347
answer count: 1
has comment: http://stackoverflow.com/comment/32620954
has comment: http://stackoverflow.com/comment/32620437
favorite count: 0
has comment: http://stackoverflow.com/comment/32621507
has comment: http://stackoverflow.com/comment/32620772
downvote count: 0
score: 1
tagged with: jarsigner
tagged with: java
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21614882
linked to: http://stackoverflow.com/q/10991856
has title: How to use Jarsigner on machine which dosen't have JDK
accepted answer: http://stackoverflow.com/a/21614882
tagged with: installanywhere
has comment: http://stackoverflow.com/comment/32621605
has body: I want to use jarsigner.exe on a machine where I don't have JDK installed or JAVA_HOME set. We are using installanywhere to install our product and inside that we have bundled JRE. JRE doesn't have jarsigner.exe. I tried to included jarsigner.exe inside jre and tried to use it but it's not working. With regards, Avinash Nigam
upvote count: 1

http://stackoverflow.com/a/21634513
score: 1
upvote count: 1
downvote count: 0
answers question: http://stackoverflow.com/q/21612829
type: Answer
has body: There is another API called JWebServices for Exchange. Supports all new features in Exchange 2013

object
tags question: http://stackoverflow.com/q/21517394
tags question: http://stackoverflow.com/q/21598744
tags question: http://stackoverflow.com/q/21535029
tag name: object
tags question: http://stackoverflow.com/q/21564890
tags question: http://stackoverflow.com/q/21599852
tags question: http://stackoverflow.com/q/21618575
tags question: http://stackoverflow.com/q/21663110
tags question: http://stackoverflow.com/q/21538166
tags question: http://stackoverflow.com/q/21578226
tags question: http://stackoverflow.com/q/21664198
tags question: http://stackoverflow.com/q/21559952
tags question: http://stackoverflow.com/q/21640720
tags question: http://stackoverflow.com/q/21540063
tags question: http://stackoverflow.com/q/21515125
tags question: http://stackoverflow.com/q/21532091
tags question: http://stackoverflow.com/q/21627214
tags question: http://stackoverflow.com/q/21582242
tags question: http://stackoverflow.com/q/21640444
tags question: http://stackoverflow.com/q/21669244
tags question: http://stackoverflow.com/q/21638529
tags question: http://stackoverflow.com/q/21554988
tags question: http://stackoverflow.com/q/21547480
tags question: http://stackoverflow.com/q/21594812
tags question: http://stackoverflow.com/q/21533840
tags question: http://stackoverflow.com/q/21618071
tags question: http://stackoverflow.com/q/21673440
tags question: http://stackoverflow.com/q/21657307
tags question: http://stackoverflow.com/q/21576726
type: Tag
tags question: http://stackoverflow.com/q/21564612
tags question: http://stackoverflow.com/q/21601227
tags question: http://stackoverflow.com/q/21518362
tags question: http://stackoverflow.com/q/21571479
tags question: http://stackoverflow.com/q/21525559

http://stackoverflow.com/q/21522009
favorite count: 0
tagged with: antlr4
has title: How to skip single line sql comment -- in antlr4
has answer: http://stackoverflow.com/a/21522178
type: AnsweredQuestion
upvote count: 2
downvote count: 2
possible better answer: http://stackoverflow.com/a/21522410
has answer: http://stackoverflow.com/a/21522410
type: Question
tagged with: java
has body: How do I skip sql single line comments in antlr4 grammar? This is the input which I have given: -- -- $INPUT.sql$ -- CREATE TABLE table_one ( customer_number integer, address character varying(30)); create table table_two ( id integer, city character varying(50));
accepted answer: http://stackoverflow.com/a/21522178
tagged with: antlr
score: 0
answer count: 2
tagged with: sql
has comment: http://stackoverflow.com/comment/32499696

http://stackoverflow.com/q/21552913
has comment: http://stackoverflow.com/comment/32584910
upvote count: 2
accepted answer: http://stackoverflow.com/a/21554040
has body: How can I modify the read timeout for embedded tomcat? From Apache Tomcat Configuration Reference: socket.soTimeout Value in milliseconds for the sockets read timeout (SO_TIMEOUT). Default value is 5000 milliseconds. I've tried the following httpConnector.setAttribute("channelNioSocket.soTimeout", 1); httpConnector.setAttribute("soTimeout", 1); httpConnector.setAttribute("SO_TIMEOUT", 1); I expected to get SocketTimeoutException as I changed the value to 1 millisecond, but didn't, so I assume it's not working.
downvote count: 0
answer count: 1
tagged with: tomcat
favorite count: 0
has answer: http://stackoverflow.com/a/21554040
has title: Modify SO_TIMEOUT (read timeout) for embedded tomcat
score: 2
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/21550369
tagged with: embedded-tomcat-7
type: Question
tagged with: java

http://stackoverflow.com/q/21656440
tagged with: android
answer count: 1
score: 8
tagged with: http://stackoverflow.com/tag/xml
favorite count: 0
linked to: http://stackoverflow.com/q/15774533
has comment: http://stackoverflow.com/comment/68606958
type: UnansweredQuestion
has title: android.os.TransactionTooLargeException retrieving installed applications
downvote count: 0
tagged with: java
has body: I'm recovering all the applications installed on the device and I stumbled upon this error. java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:300) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) at java.util.concurrent.FutureTask.setException(FutureTask.java:222) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:811) Caused by: java.lang.RuntimeException: Package manager has died at android.app.ApplicationPackageManager.queryIntentActivitiesAsUser(ApplicationPackageManager.java:499) at android.app.ApplicationPackageManager.queryIntentActivities(ApplicationPackageManager.java:485) at com.name.package.MyClass$RetrieveApps.doInBackground(MyClass.java:363) at com.name.package.MyClass$RetrieveApps.doInBackground(MyClass.java:1) at android.os.AsyncTask$2.call(AsyncTask.java:288) at java.util.concurrent.FutureTask.run(FutureTask.java:237) ... 4 more Caused by: android.os.TransactionTooLargeException at android.os.BinderProxy.transact(Native Method) at android.content.pm.IPackageManager$Stub$Proxy.queryIntentActivities(IPackageManager.java:2165) at android.app.ApplicationPackageManager.queryIntentActivitiesAsUser(ApplicationPackageManager.java:493) ... 9 more In doInBackground() method i use this code to retrieve the installed apps. PackageManager packageManager = getPackageManager(); List&lt;ResolveInfo&gt; mResolveInfo; Intent queryIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER); mResolveInfo = packageManager.queryIntentActivities(queryIntent, 0); for (ResolveInfo ri : resolveInfos) { Class class = new Class(); class.icon = ri.loadIcon(packageManager); class.label = ri.load…
upvote count: 8
type: Question
has answer: http://stackoverflow.com/a/22973973

http://stackoverflow.com/a/21526786
answers question: http://stackoverflow.com/q/21526747
type: AcceptedAnswer
downvote count: 0
type: Answer
has body: how many String objects are created in the above declaration? This is my interview question "Sachin" -> String literal "Tendulkar" -> String literal only one String s is created from concatenation of the two literals
upvote count: 1
score: 1
accepted answer of: http://stackoverflow.com/q/21526747

http://stackoverflow.com/comment/32639045
comment on: http://stackoverflow.com/a/21596717
score: 0
type: Comment
has text: Prepare a new question, post relevant code and describe your problem carefully; attach stacktrace of your error and wait for someone else answer your question. Otherwise try debug, it's really useful to learn! :)
type: AnswerComment

http://stackoverflow.com/a/21641128
score: 0
answers question: http://stackoverflow.com/q/21641102
has comment: http://stackoverflow.com/comment/32705733
has comment: http://stackoverflow.com/comment/32705880
type: Answer
has body: When the list is empty, set your head and tail to the new element. Should be ok after that, though more null checks are rarely a bad idea. if (head == null) { head = node; tail = node; } else { node.prev = tail; tail.next = null; // Did you really mean tail.next = node? This looks more likely.. tail = node; }

http://stackoverflow.com/comment/32678153
has text: Sorry if this is obvious, but have you overridden `toString()` or `hashCode()`? It's the only way I've been able to reproduce anything like what you're saying has happened.
comment on: http://stackoverflow.com/q/21625561
type: Comment
type: QuestionComment
score: 2

http://stackoverflow.com/comment/32575626
comment on: http://stackoverflow.com/a/21566951
score: 0
type: AnswerComment
type: Comment
has text: Excellent @Josh M, it means if the service is not running it will not show up, tasklist will only show running?

http://stackoverflow.com/comment/32674371
has text: *"I'll do that."* ..when? I was hoping to see an edit, so that I could up-vote this answer.
comment on: http://stackoverflow.com/a/21619160
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/21657147
has answer: http://stackoverflow.com/a/21657218
has comment: http://stackoverflow.com/comment/32733214
has comment: http://stackoverflow.com/comment/32733228
type: UnansweredQuestion
upvote count: 0
tagged with: java
has title: Given two numbers, return true if any one of them divides the other, else return false
type: Question
has body: Given two numbers, return true if any one of them divides the other, else return false public class DividesAB { static int testcase11 = 208; static int testcase12 = 7; boolean aDivisblebyb, bDivisblebya, answer; public static void main(String args[]){ DividesAB testInstance = new DividesAB(); boolean result = testInstance.divides(testcase11,testcase12); System.out.println(result); } //write your code here public boolean divides(int a, int b){ boolean aDivisiblebyb = a%b == 0; boolean bdivisiblebya = b%a == 0; boolean answer = aDivisiblebyb||bDivisiblebya; return answer; } } I have been getting errors like cannot find symbol
has answer: http://stackoverflow.com/a/21657443
downvote count: 6
answer count: 3
has answer: http://stackoverflow.com/a/21657209
score: -6
favorite count: 0

http://stackoverflow.com/a/21596526
answers question: http://stackoverflow.com/q/21596465
score: 1
accepted answer of: http://stackoverflow.com/q/21596465
type: AcceptedAnswer
downvote count: 0
type: Answer
upvote count: 1
has body: JSONArray data = jsonObj.getJSONArray("data"); for (int i = 0; i < data.length(); i++) { Integer prod = (Integer) data.get(i); System.out.println("Prod " + prod); // loop and add it to array or arraylist }

http://stackoverflow.com/q/21540900
has comment: http://stackoverflow.com/comment/32534962
has body: I am currently making a hibernate call as such Query query = session.createQuery(sql); System.out.println("TIME: "+(System.currentTimeMillis()-currTimeLong)); List results = query.list(); //VERY SLOW IN THREADS System.out.println("TIME: "+(System.currentTimeMillis()-currTimeLong)); Now, I am making multiple such calls for a server application. Hence, I decided to simultaneously run them by wrapping this operation in Runnables/Threads. When I did that, query.list() became insanely slow. Almost by 1000+ milliseconds. Why does hibernate's query.list() run so much slower when wrapped in a thread? Does it make a call to the main thread somehow?
has comment: http://stackoverflow.com/comment/32529313
has comment: http://stackoverflow.com/comment/32529305
has title: Java Hibernate List - Called inside a thread is slow
has comment: http://stackoverflow.com/comment/32529802
score: 0
has comment: http://stackoverflow.com/comment/32529580
type: UnansweredQuestion
answer count: 0
tagged with: java
tagged with: hibernate
has comment: http://stackoverflow.com/comment/32529284
type: Question

http://stackoverflow.com/q/21676788
tagged with: java
has answer: http://stackoverflow.com/a/21677359
has answer: http://stackoverflow.com/a/21677419
has answer: http://stackoverflow.com/a/21677314
answer count: 4
type: Question
type: AnsweredQuestion
tagged with: android
accepted answer: http://stackoverflow.com/a/21677314
has answer: http://stackoverflow.com/a/21703815
has title: Change a textview text and position when you click and then click again go back to the original
has body: Hello i am new in Android apps, so i want your help. So basically what i am trying to do is to change the content of textview from "Read more" to "Read less" and then when i click again to change back to "Read more". Then my second question is how can i change my textview position from my main activity (java not xml) when i click "Read more", and when it's clicked again to go back again to the original position. This is my main activity: TextView paragraphmore; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); paragraphmore = (TextView) findViewById(R.id.paragraphmore); // hide until its title is clicked paragraphmore.setVisibility(View.GONE); } public void toggle_contents(View v){ paragraphmore.setVisibility(paragraphmore.isShown() ? View.GONE : View.VISIBLE ); TextView view = (TextView) findViewById(R.id.readbutton); view.setText("Read less"); } these are the textviews:
possible better answer: http://stackoverflow.com/a/21677359
score: 0

http://stackoverflow.com/q/21673668
score: 0
tagged with: http://stackoverflow.com/tag/xml
accepted answer: http://stackoverflow.com/a/21675177
type: Question
type: AnsweredQuestion
tagged with: java
has title: Strange xml parsing behaviour
has body: I am trying to parse an xml file using DOM parser. I have a strange parsing behaviour when trying to parse the following xml file: 1 Numeric 2 18948 3872 mmHg Compound-Basic-Nu-Observed-Value 2 18949 0 float 120.000000 2 18950 1 float 76.000000 2 18951 2 float 91.000000 Absolute-Time-Stamp century intu8 20 year intu8 14 month intu8 2 day intu8 6 hour intu8 15 minute intu8 26 second intu8 14 sec_fractions intu8 0 I am trying to navigate to each element using getChildNotes() method. However, when I use getChildNotes() for the data-list element, I am getting 3 elements only (While I was expecting to get only one "entry" element). Could someone clarify this to me? My parsing code: Document d = parse_xml(xml); NodeList datalists = d.getElementsByTagName("data-list"); // data list for (int i = 0; i < datalists.getLength(); ++i) { Node datalist = datalists.item(i); NodeList entries = datalist.getChildNodes(); // prints out 3 System.out.println(entries.getLength()); } parse_xml(): public static Document parse_xml(String xml) { Document d = null; try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); d = db.parse(new ByteArrayInputStream(xml.getBytes("UTF-8"))); d.getDocumentElement().normalize(); } catch (ParserConfigurationException e) { System.out.println("XML parser error"); } catch (SAXException e) { System.out.println("SAX exception"); } catch (IOException e) { System.out.println("IO exception in xml parsing"); } return d; }
tagged with: dom
tagged with: xml-parsing
answer count: 1
has answer: http://stackoverflow.com/a/21675177

http://stackoverflow.com/a/21616517
accepted answer of: http://stackoverflow.com/q/21616016
answers question: http://stackoverflow.com/q/21616016
has comment: http://stackoverflow.com/comment/32678430
type: Answer
has body: Yes, try this code - import org.apache.poi.xwpf.usermodel.ParagraphAlignment; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFParagraph; import org.apache.poi.xwpf.usermodel.XWPFRun; import org.apache.poi.xwpf.usermodel.VerticalAlign; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class ApachePOI { public static void main(String[] args) { XWPFDocument document = new XWPFDocument(); XWPFParagraph paragraphOne = document.createParagraph(); paragraphOne.setAlignment(ParagraphAlignment.CENTER); XWPFRun paragraphOneRunOne = paragraphOne.createRun(); paragraphOneRunOne.setFontSize(25); paragraphOneRunOne.setBold(true); paragraphOneRunOne.setText("Oxygene - O"); XWPFRun paragraphOneRunTwo = paragraphOne.createRun(); paragraphOneRunTwo.setFontSize(17); paragraphOneRunTwo.setBold(true); paragraphOneRunTwo.setSubscript(VerticalAlign.SUBSCRIPT); paragraphOneRunTwo.setText("2"); try { FileOutputStream fos = new FileOutputStream("C://test.docx"); document.write(fos); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
has comment: http://stackoverflow.com/comment/32682069
score: 3
has comment: http://stackoverflow.com/comment/32663031
upvote count: 3
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/32562554
type: Comment
has text: Ok, than i have a issue. synchronized(b){ try{ b.wait(); }catch(InterruptedException e){} now as i acquired a lock on b object, it means no other thread can acquire a lock on b object. so maximum one thread can be in waiting state, than why there is a notifyall method, because maximum one thread can be in waiting state than there should be notify only.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21560073

http://stackoverflow.com/comment/32632832
type: AnswerComment
has text: Thanks, will try to make changes based on that. I want to work with Hibernate, so I guess I'll try the sessionFactory approach. A question though, why am I not using the sessionFactory right now? As far as I understood, I injected the sessionFactory to my DAO via a setter injection. So I should be using it already?
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21599567

http://stackoverflow.com/q/21556332
has comment: http://stackoverflow.com/comment/32564264
has comment: http://stackoverflow.com/comment/32563656
score: 12
has comment: http://stackoverflow.com/comment/32564165
has answer: http://stackoverflow.com/a/59203403
tagged with: parsing
favorite count: 0
accepted answer: http://stackoverflow.com/a/21565923
upvote count: 12
has comment: http://stackoverflow.com/comment/106608436
has comment: http://stackoverflow.com/comment/94489264
has comment: http://stackoverflow.com/comment/32564233
has comment: http://stackoverflow.com/comment/32570624
has comment: http://stackoverflow.com/comment/32574535
has body: I'm parsing simple JSON object with Gson. I want it to throw some error when key name is duplicated. E.g. { a: 2, a: 3 } In my case, Gson parses such JSON and sets a to 3. I want it to throw some exception. I know I can parse JSON as map, and then Gson throws exception in such case, but only if the duplicated key is not nested in the map. If I have e.g. JSON like this: { a: 2, b: { dup: 1, dup: 2 } } Still, it is parsed without any exception and I have only one "dup" with value 2. Can I somehow setup Gson to throw error in such case? Or to have duplicated entries in JsonObject instance, so that I can detect it myself (but I doubt that, as it would be invalid JsonObject) Reproducible example String json = "{\"a\":2, \"a\":3}"; Gson gson = new Gson(); JsonObject jsonObject = gson.fromJson(json, JsonObject.class); System.out.println(jsonObject); prints out {"a":3}
has answer: http://stackoverflow.com/a/21565923
type: AnsweredQuestion
downvote count: 0
has comment: http://stackoverflow.com/comment/32571530
tagged with: java
tagged with: http://stackoverflow.com/tag/json
tagged with: gson
has comment: http://stackoverflow.com/comment/32564292
possible better answer: http://stackoverflow.com/a/59203403
has comment: http://stackoverflow.com/comment/32565327
has comment: http://stackoverflow.com/comment/32564382
type: Question
answer count: 2
has title: Make Gson throw exception on parsing JSON with duplicated key

http://stackoverflow.com/a/21564472
score: 1
upvote count: 1
type: Answer
has body: String dateOfBirth = dateOfBirthTextField.getText().toString(); SimpleDateFormat s=new SimpleDateFormat("MM/dd/yyyy"); // use your pattern here Date d = s.parse(dateOfBirth);
downvote count: 0
answers question: http://stackoverflow.com/q/21564389

http://stackoverflow.com/a/72114722
type: Answer
has comment: http://stackoverflow.com/comment/127440650
has comment: http://stackoverflow.com/comment/127420554
answers question: http://stackoverflow.com/q/21540378
has body: I find it insane to import the entirety of Java Swing only for this. There are other solutions. My solution below is not too great, but I think it's better than importing a completely new library. Image image = /* your image */; int width = (int) image.getWidth(); int height = (int) image.getHeight(); int pixels[] = new int[width * height]; // Load the image's data into an array // You need to MAKE SURE the image's pixel format is compatible with IntBuffer image.getPixelReader().getPixels( 0, 0, width, height, (WritablePixelFormat&lt;IntBuffer&gt;) image.getPixelReader().getPixelFormat(), pixels, 0, width ); BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); for (int y = 0; y &lt; height; y++) { for (int x = 0; x &lt; width; x++) { // There may be better ways to do this // You'll need to make sure your image's format is correct here var pixel = pixels[y * width + x]; int r = (pixel &amp; 0xFF0000) &gt;&gt; 16; int g = (pixel &amp; 0xFF00) &gt;&gt; 8; int b = (pixel &amp; 0xFF) &gt;&gt; 0; bufferedImage.getRaster().setPixel(x, y, new int[]{r, g, b}); } }
score: 0

http://stackoverflow.com/a/21592963
type: Answer
has body: You were correct that is the solution. You can check if there is any not null and return false at the first occurrence. String table_1 = null; String table_2 = null; List&lt;String&gt; tables = new LinkedList&lt;&gt;(); tables.add(table_1); tables.add(table_2); for (String table : tables) { if (table != null) {System.out.println("False");} }
answers question: http://stackoverflow.com/q/21592835
score: 0

http://stackoverflow.com/q/21625170
tagged with: image
accepted answer: http://stackoverflow.com/a/21625684
answer count: 2
has title: Moving JButtons to the left when having a background image in JFrame
downvote count: 0
tagged with: paintcomponent
favorite count: 0
upvote count: 2
tagged with: swing
tagged with: jbutton
score: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21625684
has comment: http://stackoverflow.com/comment/32682599
tagged with: java
possible better answer: http://stackoverflow.com/a/21625500
has answer: http://stackoverflow.com/a/21625500
has body: I'm pretty new to Java and working on a project. As a test for making my mainmenu, I've been experimenting with the JFrame and a picture of the powerrangers. My problem is that I've tried so many times and spent so many time on trying to get my play and my help buttons to the left of my window. I've tried making a grid of 4 and putting in an empty label but it just won't work. This is my code: package be.kdg.AngryTanksKlad; import java.awt.*; import java.awt.event.ActionEvent; import java.io.IOException; import java.net.URL; import javax.imageio.ImageIO; import javax.swing.*; public class Main { public static void main(String[] args) throws IOException { final Image image = ImageIO.read(new URL("http://www.modernmom.com/sites/default/files/images/Power%2BRangers%2BPowerRangersMMPR.jpg")); final JFrame frame = new JFrame(); frame.add(new ImagePanel(image)); frame.setSize(800, 600); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } @SuppressWarnings("serial") class ImagePanel extends JPanel { private Image image; private boolean tile; private JPanel menu = new JPanel(new FlowLayout(FlowLayout.LEFT)); ImagePanel(Image image) { this.image = image; this.tile = false; final JButton play = new JButton("PLAY"); final JButton help = new JButton("HELP"); final JLabel empty = new JLabel(); } menu.setLayout(new GridLayout(4,4)); menu.add(empty); menu.add(play); menu.add(help); add(menu,BorderLayout.CENTER); menu.setOpaque(false); setVisible(true); }; @Override public void paintComponent(Graphics g) { super.paintComponent(g); if (tile) { int iw = image.getWidth(this); int ih = image.getHeight(this); if (iw &gt; 0 &amp;&amp; ih &gt; 0) { for (int x = 0; x &lt; getWidth(); x += iw) { for (int y = 0; y &lt; getHeight(); y += ih) { g.drawImage(image, x, y, iw, ih, this); } } } } else { g.drawImage(image, 0, 0, getWidth(), getHeight(), this); } } }
type: Question
has comment: http://stackoverflow.com/comment/32676859
has comment: http://stackoverflow.com/comment/32676714

http://stackoverflow.com/q/21541820
linked to: http://stackoverflow.com/q/4869815
downvote count: 1
favorite count: 0
upvote count: 0
has answer: http://stackoverflow.com/a/21591847
has answer: http://stackoverflow.com/a/21542324
has title: Download Hadoop source configure it on eclipse
type: UnansweredQuestion
tagged with: java
score: -1
tagged with: eclipse
type: Question
tagged with: hadoop
answer count: 2
has body: I need to find full instructions on how to download the Hadoop source code and how to configure it on Eclipse Kepler version.

http://stackoverflow.com/comment/32573053
has text: Read the file contents (if you can) into a `List` or array and simply maintain some kind of pointer which represents the current index in the `List` or array
comment on: http://stackoverflow.com/q/21565712
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32485691
comment on: http://stackoverflow.com/q/21516375
score: 0
has text: @JakubJirutka You can reference (final) variables from inside the local class. @ markus-a This is probably also the reason you can't define an interface there, as you might as well do it on class-level, or in a separate file, it adds nothing to define it in a function
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32687141
has text: And what about *aop* at the begining?
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21630392
type: AnswerComment

http://stackoverflow.com/comment/32766773
type: Comment
comment on: http://stackoverflow.com/a/21676432
score: 0
has text: Same exception occurred again
type: AnswerComment

http://stackoverflow.com/comment/32811404
has text: @davmac The JLS specifies nothing like this. Please search http://cr.openjdk.java.net/~mr/se/8/java-se-8-pfd-spec/java-se-8-jls-pfd-diffs.pdf for "constant pool". It doesn't even appear! The constant pool is no abstract concept, but a very real section in the class file. Hence, I ask again, where in the JLS is it stated, that a conforming compiler must make use of the class files constant pool mechanism? Only the following is required: There must be a method String.intern to enable sharing (without saying how exactly) and "a string literal always refers to the same instance of class String"
comment on: http://stackoverflow.com/a/21676422
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/32511298
has text: Further reading on casting from Object[] to String[]: http://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)#Arrays
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21531012

http://stackoverflow.com/comment/32539841
score: 0
comment on: http://stackoverflow.com/q/21546645
type: Comment
type: QuestionComment
has text: This is an assignment that requires me to use these arrays :(

http://stackoverflow.com/q/21548506
has comment: http://stackoverflow.com/comment/32819868
has answer: http://stackoverflow.com/a/21712007
tagged with: java
has comment: http://stackoverflow.com/comment/32807940
has comment: http://stackoverflow.com/comment/32832854
has comment: http://stackoverflow.com/comment/32549705
has comment: http://stackoverflow.com/comment/32802470
has comment: http://stackoverflow.com/comment/32830193
has comment: http://stackoverflow.com/comment/32549688
type: Question
has comment: http://stackoverflow.com/comment/32550821
has answer: http://stackoverflow.com/a/21631660
has answer: http://stackoverflow.com/a/21768479
tagged with: hotswap
has comment: http://stackoverflow.com/comment/32691790
tagged with: tomcat
tagged with: maven-3
has body: Usually i start tomcat using mvnDebug tomcat:run. After Code-change i need to use mvn tomcat:redeploy. This is sub-optimal because i often only change content of existing method-bodys. Can I HotSwap the method's body into the runtime, and hot-redeploy as a fallback? I have unfortunatally nothing found like a maven-hotswap-plugin. faces-config.xml ... com.sun.facelets.FaceletViewHandler de_DE Message message org.springframework.web.jsf.el.SpringBeanFacesELResolver </faces-config> web.xml: org.springframework.web.context.ContextLoaderListener org.springframework.web.context.request.RequestContextListener pom.xml: org.hibernate hibernate-envers 4.3.0.Final net.java.dev.ajax4jsf ajax4jsf 1.0.6 org.hibernate hibernate-core 3.6.6.Final commons-lang commons-lang 2.3 org.apache.myfaces.core myfaces-api 1.2.10 compile org.apache.myfaces.core myfaces-impl 1.2.10 runtime org.apache.myfaces.tomahawk tomahawk12 1.1.9 runtime javax.servlet jstl 1.2 runtime com.sun.facelets jsf-facelets 1.1.14 org.hibernate hibernate-validator 3.1.0.GA org.springframework spring 2.5.6 org.postgresql postgresql 9.2-1004-jdbc41 servletapi servlet-api 2.4 provided org.apache.tomcat.maven tomcat7-maven-plugin 2.2 true
linked to: http://stackoverflow.com/q/998737
has comment: http://stackoverflow.com/comment/32893661
upvote count: 7
downvote count: 1
answer count: 7
has comment: http://stackoverflow.com/comment/32866718
favorite count: 0
has answer: http://stackoverflow.com/a/21727233
has comment: http://stackoverflow.com/comment/32804758
has answer: http://stackoverflow.com/a/21757839
has answer: http://stackoverflow.com/a/21682542
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32551571
score: 6
has comment: http://stackoverflow.com/comment/32830273
has comment: http://stackoverflow.com/comment/32551345
has title: HotSwaping code into "mvnDebug tomcat:run"
has comment: http://stackoverflow.com/comment/33046442
has comment: http://stackoverflow.com/comment/32893715
has comment: http://stackoverflow.com/comment/32843995
has answer: http://stackoverflow.com/a/21632678

http://stackoverflow.com/comment/32570452
has text: Borrowing @delnan's comment below: *"Well, duh. Making x immutable doesn't prevent mutation of y. That doesn't mean it's pointless."*
comment on: http://stackoverflow.com/a/21564439
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32586548
comment on: http://stackoverflow.com/a/21569669
score: 0
type: AnswerComment
has text: See the last link in my answer, or, you could just do what you already do, `tv = new MyTouchEventView(this); setContentView(tv);` in your new activity
type: Comment

http://stackoverflow.com/q/21570201
tagged with: java
tagged with: eclipse
score: 0
has body: When isAlertPresent() command is used it gives syntax error on boolean @ expected. The code used was public boolean isAlertPresent(){ boolean presentFlag = false; try { Alert alert = driver.switchTo().alert(); presentFlag = true; alert.accept(); } catch (NoAlertPresentException ex) { ex.printStackTrace(); } return presentFlag; } The error shown is Exception in thread "main" java.lang.Error: Unresolved compilation problems: Syntax error on token "boolean", @ expected isAlertPresent cannot be resolved to a type Syntax error, insert "enum Identifier" to complete EnumHeaderName Syntax error, insert "EnumBody" to complete BlockStatement How to rectify this error?
answer count: 1
accepted answer: http://stackoverflow.com/a/21723946
has comment: http://stackoverflow.com/comment/32581784
has title: Syntax Error On Boolean @ expected
tagged with: selenium-webdriver
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32603076
tagged with: selenium
has answer: http://stackoverflow.com/a/21723946
type: Question
has comment: http://stackoverflow.com/comment/32584932
has comment: http://stackoverflow.com/comment/32581612

http://stackoverflow.com/comment/32489620
type: Comment
comment on: http://stackoverflow.com/a/21518294
score: 0
type: AnswerComment
has text: Simply printing to console is enough: `System.out.println("scalar: "+scalar)`. The matrix though, is a little harder: `System.out.println("matrix: "+Arrays.deepToString(matrix));`

http://stackoverflow.com/q/21588871
answer count: 1
favorite count: 0
upvote count: 2
has comment: http://stackoverflow.com/comment/32615712
score: 2
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21589522
tagged with: java
has comment: http://stackoverflow.com/comment/32615554
has title: Check if there is an error in update/insert | MongoDB Java driver
has body: I want to check if an insert fails (due to unique=True index in the collection). If there is an error do something. Bellow is an example of my code. DBCollection user...; BasicDBObject Doc = new BasicDBObject(... ); String user_exists = user.insert(Doc).getError(); //insert the doc get error if any if(user_exists!=null){ //any errors? user.update(new BasicDBObject(...)); // error exists so do smthng } The above as it is does not work. I believe that the String user_exists is always null. How can I make the above work? I have seen similar SO questions and mention the WriteConcern which can be passed in the insert(). E.g. coll.insert(dbObj, WriteConcern.SAFE); sources: SO question or Mongo docs However I do not know which one field should I pass (SAFE, ACKNOWLEDGED, UNACKNOWLEDGED etc..) in order to get the error. Maybe I'm pointed in the wrong direction. I do not wish to raise an exception just to check if there is an error returned by the insert operation.
type: Question
tagged with: mongodb
tagged with: mongodb-java
downvote count: 0
has comment: http://stackoverflow.com/comment/32615073
linked to: http://stackoverflow.com/q/19998394
has answer: http://stackoverflow.com/a/21589522
has comment: http://stackoverflow.com/comment/32616244

http://stackoverflow.com/comment/60250844
comment on: http://stackoverflow.com/a/34916920
has text: the only thing you are changing is the client id, which is then used to generate a persistence directory if one is not specified
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/q/21602251
has title: how to use google translate paid api in android
tagged with: android
has comment: http://stackoverflow.com/comment/32636878
has comment: http://stackoverflow.com/comment/32637376
type: UnansweredQuestion
answer count: 0
tagged with: java
type: Question
has body: H, i want to use google paid translate api, i have enable billing and activate that api from google console service i have also generated the android key but every time i am getting error like below screen "Access Not Configured. Please use Google Developers Console to activate the API for your project.
tagged with: google-translate
score: 0
has comment: http://stackoverflow.com/comment/32637994

http://stackoverflow.com/comment/32679851
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21623911
score: 0
has text: I executed that command and received following result

http://stackoverflow.com/comment/32647422
type: AnswerComment
has text: This does not work for me. We are running a jar from a shell script. The shell script is started from a flash application. Thus, I have no plist.
type: Comment
comment on: http://stackoverflow.com/a/21598496
score: 0

http://stackoverflow.com/a/21604978
downvote count: 0
score: 6
accepted answer of: http://stackoverflow.com/q/21604443
has body: I suspect the problem is due to your usage of HttpServletResponse.flushBuffer(). As the API of HttpServletRequest states: Forces any content in the buffer to be written to the client. A call to this method automatically commits the response, meaning the status code and headers will be written. My assumption would be that Spring attempts to set the Content-Type header on the HttpServletResponse after the method on your controller has returned. However, because you have committed the response with your call to HttpServletResponse.flushBuffer(), it cannot do this. I would try either: Injecting the HttpServletResponse into your controller and setting the header yourself in code before calling HttpServletResponse.flushBuffer() Removing your usage of HttpServletRequest.flushBuffer()
answers question: http://stackoverflow.com/q/21604443
has comment: http://stackoverflow.com/comment/64831329
type: AcceptedAnswer
upvote count: 6
has comment: http://stackoverflow.com/comment/32641812
type: Answer
has comment: http://stackoverflow.com/comment/32641662

http://stackoverflow.com/comment/32706744
type: QuestionComment
comment on: http://stackoverflow.com/q/21641734
score: 0
has text: Please clarify what you mean by "most efficient". Efficient in processing time? Efficient in clarity and code length? Efficient in memory usage? Efficient in data sent across the network? Also, what frameworks are you using?
type: Comment

stringbuilder
tags question: http://stackoverflow.com/q/21672927
tags question: http://stackoverflow.com/q/21572614
tags question: http://stackoverflow.com/q/21553562
tags question: http://stackoverflow.com/q/21551267
tags question: http://stackoverflow.com/q/21654284
type: Tag
tag name: stringbuilder
tags question: http://stackoverflow.com/q/21645559

http://stackoverflow.com/q/21572692
tagged with: game-physics
has body: I am making a game using LibGDX and Box2D. I use Physics Body Editor to create fixtures for my game character. I would like to change fixtures during the player walking animation, because his posture is slightly changing, of course. I have no idea how can I do it. I thought about destroying the fixture and then using the other one from loader file, but I can't access fixture directly, because I am not declaring it manually. If you need more info I will give it to you. Thank you for your help in advance.
tagged with: libgdx
tagged with: game-engine
answer count: 1
downvote count: 0
favorite count: 0
has title: Replacing fixtures created in Body Editor Loader for character animation
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/28489401
score: 1
tagged with: java
upvote count: 1
tagged with: box2d
type: Question

http://stackoverflow.com/comment/32687661
comment on: http://stackoverflow.com/q/21630849
score: 1
has text: the emulator is always slow. use a real device.
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21638797
downvote count: 3
upvote count: 1
has body: Try to implement touch instead of click or using ImageButton instead of ImageView holder.imageView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { switch (arg1.getAction()) { case MotionEvent.ACTION_DOWN: { Toast.makeText(context, "Clicked on image", Toast.LENGTH_LONG) .show(); break; } } return true; } });
score: -2
has comment: http://stackoverflow.com/comment/32701835
has comment: http://stackoverflow.com/comment/32702584
has comment: http://stackoverflow.com/comment/32701739
has comment: http://stackoverflow.com/comment/32701793
type: Answer
answers question: http://stackoverflow.com/q/21638716
has comment: http://stackoverflow.com/comment/32701908

http://stackoverflow.com/a/21648146
has body: To interact with a dynamic web page you would need to use frameworks like HtmlUnit that have support for javascript. HtmlUnit is a "GUI-Less browser for Java programs". It models HTML documents and provides an API that allows you to invoke pages, fill out forms, click links, etc... just like you do in your "normal" browser. You requirement to fill HTML forms is well understood by such apis and can dynamically invoke the js/ajax components to interact with your server side too.
has comment: http://stackoverflow.com/comment/32718198
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32718281
has comment: http://stackoverflow.com/comment/32719251
type: Answer
answers question: http://stackoverflow.com/q/21647943
score: 2
has comment: http://stackoverflow.com/comment/32717830
accepted answer of: http://stackoverflow.com/q/21647943
upvote count: 2
has comment: http://stackoverflow.com/comment/32720617

http://stackoverflow.com/q/21520673
tagged with: minecraft
has comment: http://stackoverflow.com/comment/32492818
has title: Bukkit Plugin Coding Fix?
favorite count: 0
has comment: http://stackoverflow.com/comment/32612357
has body: I am trying to make a plugin. This plugin will give a player a special cookie on their first join, which allows them to click it and see their clicks in the lore. I know, it sounds useless but I will add to it. It does not currently work and there are no errors in the console. When I try to right click to use it it simply does nothing. Please help. I am new to Java. package me.jrneulight.cookieclicker; import java.util.Arrays; import java.util.List; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.java.JavaPlugin; public class Main extends JavaPlugin implements Listener { @Override public void onEnable() { getServer().getPluginManager().registerEvents(this, this); FileConfiguration config = this.getConfig(); config.addDefault("players.example", "1"); config.options().copyDefaults(true); saveConfig(); } @Override public void onDisable() { } public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("cookieclicker")) { ItemStack cookie = new ItemStack(Material.COOKIE); ItemMeta meta = cookie.getItemMeta(); String clicked = "0"; List&lt;String&gt; lore = Arrays.asList("Click me!", "Cookies Clicked: " + clicked); meta.setDisplayName(ChatColor.GOLD + "Cookie Clicker"); meta.setLore(lore); cookie.setItemMeta(meta); ((HumanEntity) sender).getInventory().addItem(cookie); return true; } return false; } @EventHandler public void onPlayerLoginEvent(PlayerLoginEvent event) { Player player = ev…
downvote count: 2
has answer: http://stackoverflow.com/a/25020249
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/25020249
tagged with: java
tagged with: bukkit
has answer: http://stackoverflow.com/a/21539989
has comment: http://stackoverflow.com/comment/32511747
type: Question
answer count: 2
upvote count: 0
score: -2
accepted answer: http://stackoverflow.com/a/21539989

http://stackoverflow.com/a/21538065
answers question: http://stackoverflow.com/q/21537982
upvote count: 0
type: Answer
downvote count: 1
score: -1
has body: Yes, When you are implementing an Interface you will have to implement all its methods (unless the default method in Java 8 and later). That is the purpose of defining an Interface. And yes, you can have your own methods in the implementing class where you implement an Interface.

http://stackoverflow.com/comment/32735910
score: 0
type: Comment
has text: Yes I can see the check mark now. Got mind blurred by hours of refreshing Eclipse and Tomcat and wrestling with url pattern
type: AnswerComment
comment on: http://stackoverflow.com/a/21658698

http://stackoverflow.com/a/21609314
upvote count: 1
answers question: http://stackoverflow.com/q/21608990
score: 1
accepted answer of: http://stackoverflow.com/q/21608990
has comment: http://stackoverflow.com/comment/32660989
has comment: http://stackoverflow.com/comment/32649364
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/32657226
has body: //added an import here import java.util.ArrayList; import java.util.Scanner; class programTwo { //main difference is the average calculation is done within a method instead of main public static void main( String[] args ) { Scanner scan = new Scanner(System.in); ArrayList&lt;Double&gt; myArr = new ArrayList&lt;Double&gt;(); double sum = 0; int count = 0; System.out.println("Enter a number to be averaged:"); String inputs = scan.nextLine(); while (!inputs.contains("q")) //input until user no longer wants to give input { if (count == 21) { break; //this command here jumps out of the input loop if there are 21 } Scanner scan2 = new Scanner(inputs); // create a new scanner out of our single line of input myArr.add(scan2.nextDouble()); //simply adding to the array list count += 1; System.out.println("Please enter another number or press Q for your average"); inputs = scan.nextLine(); } Double average = calculate_average(myArr); //go to method calculate average, expect a double to be returned System.out.println("Your average is: " + average); } private static Double calculate_average( ArrayList&lt;Double&gt; myArr ) //method definition { Double Sum = 0.0; for (Double number: myArr) //for loop that iterates through an array list { Sum += number; //add all the numbers together into a sum } return Sum / myArr.size(); //return the sum divided by the number of numbers in the array list } } This should help. Best of luck :)

http://stackoverflow.com/comment/102047997
comment on: http://stackoverflow.com/a/55240834
score: 0
has text: Now that a few months have passed, would you still recommend using dual transaction managers? I have the same problem; I want to use Spring JPA on top of legacy Hibernate code.
type: AnswerComment
type: Comment

http://stackoverflow.com/a/21628017
downvote count: 0
answers question: http://stackoverflow.com/q/21555646
has body: The solution was pretty simple... Just hide the Ref field. It does now provide any value to the API consumer and it just create trouble to the parser: I replaced the List&lt;Ref&lt;Car&gt;&gt; getter and setter by: public List&lt;Car&gt; getCars() { List&lt;Car&gt; ret = new ArrayList&lt;&gt;(); Iterator&lt;Ref&lt;Car&gt;&gt; it = cars.iterator(); while (it.hasNext()) ret.add(it.next().getValue()); return ret; } public void setCars(List&lt;Car&gt; newCars) { Iterator&lt;Car&gt; it = newCars.iterator(); while (it.hasNext()) addCar(it.next()); } That's all
type: Answer
score: 3
upvote count: 3

http://stackoverflow.com/a/21587509
has comment: http://stackoverflow.com/comment/32612509
type: Answer
answers question: http://stackoverflow.com/q/21587385
score: 1
upvote count: 1
has body: You need to treat each ArrayList separately, i.e. have one ArrayList per Character key. List&lt;Boolean&gt; used; char[] charArray = str.toCharArray(); for (char c : charArray) { used = charCheck.get(c); // Get the list of values for this character if (used == null) { // No values stored so far for this character used = new ArrayList&lt;Boolean&gt;(); // Create a new (empty) list of values charCheck.put(c, used); // Add the empty list of values to the map } used.add(false); // Add the value for this character to the value list } Also, I would suggest using a HashMap instead of a Hashtable: HashMap&lt;Character, List&lt;Boolean&gt;&gt; charCheck = new HashMap&lt;Character, List&lt;Boolean&gt;&gt;();
downvote count: 0
has comment: http://stackoverflow.com/comment/32612194

http://stackoverflow.com/comment/32739975
has text: Can I write this in my Stock classs :private Queue<Stock> StockList = new LinkedList<Stock>(); And can I write this code my in my buy method ? Stock newStock = new Stocks(numBuyShares,priceBuyShares); StockList.add(newStock);
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21660975

http://stackoverflow.com/q/21585052
tagged with: aop
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/32607904
favorite count: 0
tagged with: spring-aop
has answer: http://stackoverflow.com/a/21585958
has body: I'm building and End to End testing framework for a production spring batch project. We'd like to use an in-memory embedded db (in our case hsqldb) for these tests since it will run much faster and have not environmental constraints. Since the SQL syntax is slightly different between these db engines, we would like to use spring AOP to intercept the sql going to the database and take out/replace sql commands that are not supported. (we've looked at paramaterizing the sql completely, but we have the incompatible commands reduced to only a few little things, such as the "(nolock)" hint. ) I set up an AOP aspect for JDBCTemplate that works following a pretty standard aop pattern for logging sql: @Pointcut("execution(* org.springframework.jdbc.core.JdbcOperations.*(String, ..))") public void modifyJdbcOperations() { } and it works great with this spring config setup: &lt;aop:aspectj-autoproxy proxy-target-class="true" &gt; &lt;aop:include name = "SQLModifierAspect"/&gt; &lt;/aop:aspectj-autoproxy&gt; &lt;aop:config proxy-target-class="true"&gt; &lt;/aop:config&gt; &lt;bean id="SQLModifierAspect" class="e2e.framework.SQLModifierAspect" /&gt; Then I tried to set up a similar pointcut for the a method on one of our DAO objects that is constructor injected: @Pointcut("execution(* com.*.dao.DateDao.buildSelectByDateCarryForward())") public void modifyDateDao() { } But when I run the E2E framework with this pointcut I get: Caused by: java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:721) ~[cglib-2.2.jar:na] I see that this is because I have configured to use CGLIB instead of Spring dynamic proxy based AOP. I read up on the differences here: http://docs.spring.io/spring/docs/3.0.0.M3/reference/html/ch08s06.html I can't realistically refactor our entire production project to use property DI instead of constructor DI. If I switch back to Spring Dynamic Proxies, then th…
has title: Can I use both dynamic proxies and CGLib proxies in the same application context?
has comment: http://stackoverflow.com/comment/32644933
score: 2
upvote count: 2
type: UnansweredQuestion
tagged with: spring
type: Question
tagged with: java

jaxp
type: Tag
tag name: jaxp
tags question: http://stackoverflow.com/q/21606204

http://stackoverflow.com/comment/32653514
type: QuestionComment
score: 2
has text: Think about what happens if `readLine` throws an exception.
comment on: http://stackoverflow.com/q/21611726
type: Comment

http://stackoverflow.com/q/21641551
has comment: http://stackoverflow.com/comment/32706461
linked to: http://stackoverflow.com/q/3122422
tagged with: java
linked to: http://stackoverflow.com/q/17531824
has title: What is the difference between FileInputStream and BufferedInputStream in Java?
type: Question
has answer: http://stackoverflow.com/a/21641689
answer count: 3
linked to: http://stackoverflow.com/q/18600331
has answer: http://stackoverflow.com/a/21641597
has comment: http://stackoverflow.com/comment/32710343
favorite count: 0
has answer: http://stackoverflow.com/a/21641566
type: UnansweredQuestion
has body: What is the difference between FileInputStream and BufferedInputStream in Java?
score: 11
upvote count: 15
downvote count: 4

http://stackoverflow.com/q/21652509
has title: Writing DAO : how to override or implements the interface methods in abstract class?
type: Question
tagged with: spring
has comment: http://stackoverflow.com/comment/32725361
upvote count: 3
tagged with: java
tagged with: hibernate
accepted answer: http://stackoverflow.com/a/21652661
answer count: 1
has comment: http://stackoverflow.com/comment/32727526
has comment: http://stackoverflow.com/comment/32725236
has comment: http://stackoverflow.com/comment/32725126
has comment: http://stackoverflow.com/comment/32725270
type: AnsweredQuestion
score: 3
downvote count: 0
has body: I am working with Spring 3.2 and Hibernate 4. I am writing the persistence layer access with dao. Here is the dao interface code : public interface AbstractDao&lt;E, I extends Serializable&gt; { public E findById(I id); public void saveOrUpdate(E e); public void delete(E e); public List&lt;E&gt; findByCriteria(Criterion criterion); } Just after I have written following the abstract class which implements the interface : public abstract class AbstractDaoImpl&lt;E, I extends Serializable&gt; implements AbstractDao&lt;E,I&gt; { private Class&lt;E&gt; entityClass; protected AbstractDaoImpl(Class&lt;E&gt; entityClass) { this.entityClass = entityClass; } @Autowired private SessionFactory sessionFactory; public Session getCurrentSession() { return sessionFactory.getCurrentSession(); } @Override public E findById(I id) { return (E) getCurrentSession().get(entityClass, id); } @Override public void saveOrUpdate(E e) { getCurrentSession().saveOrUpdate(e); } @Override public void delete(E e) { getCurrentSession().delete(e); } @Override public List&lt;E&gt; findByCriteria(Criterion criterion) { Criteria criteria = getCurrentSession().createCriteria(entityClass); criteria.add(criterion); return criteria.list(); } } I am getting some compilation errors on all methods that i have implemented in the abstract class : findById(I id), saveOrUpdate(E e), delete(E e) ,findByCriteria(Criterion criterion). The error message is : Multiple markers at this line - implements com.startup.app.models.hibernate.dao.AbstractDao.findById - The method findById(I) of type AbstractDaoImpl must override a superclass method What wrong, I don't understand. thanks.
has answer: http://stackoverflow.com/a/21652661
favorite count: 0
has comment: http://stackoverflow.com/comment/32725319

http://stackoverflow.com/comment/35160315
type: Comment
has text: @M.Deinum I confirmed it's not well known but very elegant! one question though (curiosity) : why wouldn't you mix both strategies ?
comment on: http://stackoverflow.com/a/21673855
type: AnswerComment
score: 0

http://stackoverflow.com/a/21626061
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21625772
score: 2
upvote count: 2
has body: Invert the map twice import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; public class UniqueMapValues { public static void main(String[] args) { Map&lt;Integer, String&gt; hm = new HashMap&lt;Integer, String&gt;(); hm.put(1, "Anil"); hm.put(2, "Deven"); hm.put(3, "sanjay"); hm.put(4, "sanjay"); hm.put(5, "Raj"); hm.put(6, "sanjay"); hm = invert(invert(hm)); System.out.println(hm); } private static &lt;K, V&gt; Map&lt;V, K&gt; invert(Map&lt;K, V&gt; map) { Map&lt;V, K&gt; result = new HashMap&lt;V, K&gt;(); for (Entry&lt;K, V&gt; entry : map.entrySet()) { result.put(entry.getValue(), entry.getKey()); } return result; } }

http://stackoverflow.com/a/21646203
downvote count: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21645978
upvote count: 3
answers question: http://stackoverflow.com/q/21645978
type: Answer
has comment: http://stackoverflow.com/comment/32714139
has body: right click on your project run as > run dialog > class path tab then add derby.jar , derbynet.jar and derbyclient.jar by clicking on add external jar those three jar file you can find them in the folder downloaded from apatche DB
score: 3

http://stackoverflow.com/a/21541993
score: 1
upvote count: 1
downvote count: 0
answers question: http://stackoverflow.com/q/21541928
has comment: http://stackoverflow.com/comment/32531439
type: Answer
has body: Your problem is you're moving begPoint and endPoint before checking the charAts. Move the code advancing begPoint and endPoint to after you use the method charAt.

http://stackoverflow.com/comment/32528700
type: Comment
type: QuestionComment
has text: Hello, thanks for the comment. My question is not that. What I want to know is how can I get the JSONArray from another class after AsyncTask end.
comment on: http://stackoverflow.com/q/21540451
score: 0

http://stackoverflow.com/comment/32525378
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21538695
has text: I was fooled into thinking the OP actually wanted to write his OWN program to do this. If he did, this is how it might be done.

http://stackoverflow.com/comment/32707875
type: Comment
has text: @TastyLemons Why you would like to assign to position a random value, if you will only reach `//Success` when the random value is 100?
score: 1
comment on: http://stackoverflow.com/a/21642468
type: AnswerComment

tcp
tags question: http://stackoverflow.com/q/21529030
type: Tag
tags question: http://stackoverflow.com/q/21613843
tags question: http://stackoverflow.com/q/21532990
tags question: http://stackoverflow.com/q/21624101
tags question: http://stackoverflow.com/q/21633879
tags question: http://stackoverflow.com/q/21550337
tags question: http://stackoverflow.com/q/21628146
tag name: tcp

http://stackoverflow.com/comment/32715777
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21647009
score: 0
has text: I have done my program according to your code and I have had succesfully! Thank you once again.

http://stackoverflow.com/comment/32769727
type: Comment
comment on: http://stackoverflow.com/a/21678054
score: 0
type: AnswerComment
has text: Yes, I agree the practice is relevant, but to see good and explaining examples also necessary.

http://stackoverflow.com/a/21587342
upvote count: 7
type: Answer
answers question: http://stackoverflow.com/q/21535806
downvote count: 0
score: 7
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21535806
has body: Your images do not fill the card because in your card background you have a padding of 8dp on either side &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android"&gt; ... &lt;item android:bottom="2dp"&gt; &lt;shape android:shape="rectangle" android:dither="true"&gt; &lt;corners android:radius="2dp" /&gt; &lt;solid android:color="@android:color/white" /&gt; &lt;padding android:bottom="8dp" android:left="8dp" android:right="8dp" android:top="8dp" /&gt; &lt;/shape&gt; &lt;/item&gt; &lt;/layer-list&gt; Remove the padding to make it fill the width. If you want to keep the shadow as well it would be better to create a 9-patch for your background so you can define where the content sits, something like: The black lines on the very left and top sides represent the scalable areas and the lines on the very bottom and right sides represent the areas where the content sits (notice the content area on the very right side does not cover the shadow area).

http://stackoverflow.com/q/21654284
has answer: http://stackoverflow.com/a/21654314
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32728254
has body: I'm trying to build a card game in java, and I want to get cards to show up with their Suit and number, so a a 4 of diamonds would be 4(diamond), except the (diamond) would be U+2666 unicode. The example I have in my book to display the suits for the cards is as follows, but I don't really understand it. I'm used to for loops that use i &lt; 0, i++. Could somebody help explain it or at the very least compare it to a normal for loop? Thanks! Alternatively, could I just use a switch statement to display the suits? private String getCardsDisplay() { StringBuilder cards = new StringBuilder(); for (Card card : hand.getCards()) { cards.append(" "); cards.append(card.getRank()); switch (card.getSuit()) { case CLUBS: cards.append("\u2663"); break; case DIAMONDS: cards.append("\u2666"); break; case HEARTS: cards.append("\u2665"); break; case SPADES: cards.append("\u2660"); break; } } return cards.toString(); }
tagged with: stringbuilder
tagged with: java
tagged with: switch-statement
type: Question
tagged with: for-loop
has title: I don't understand this loop
has answer: http://stackoverflow.com/a/21654306
has answer: http://stackoverflow.com/a/21654321
has comment: http://stackoverflow.com/comment/32728247
score: 0
answer count: 3

http://stackoverflow.com/comment/32558213
has text: we clicked out of the control panels - systems - advanced -enviromental variables area, and it seemed to not have saved JAVA_HOME = C:\Program Files\Java\jdk1.7.0_07 So i recreated it. now it works
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/21557529

http://stackoverflow.com/q/21547165
has body: i All, I have a MapActivity class which extends Activity and an associated class called MapRenderer as class in a different package. (On seeing the stack on debugging, it can be seen that the control does pass from MapActivity to MapRenderer) On one particular application input action i.e. when the user touches the screen, i need to pop up an android dialog. The code that governs this action is present in the class MapRenderer (which does not extend any class) and the method resembles. class MapRenderer{ public void drawRoute(Canvas canvas,String routeName) { if(condition 0){ //Do 0 related stuff } if(condition N){ //Do N related stuff // I need to implement the alert dialog at this place AlertDialog.Builder builder1 = new AlertDialog.Builder(context); builder1.setMessage("Write your message here."); builder1.setCancelable(true); builder1.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); builder1.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert11 = builder1.create(); alert11.show(); } if(condition inbetween){ //Do inbetween related stuff } } } But this seems to give out an error if i try to call a dialog from a class (in this case 'MapRenderer') that does not implement Activity. Can you please confirm that actions like AlertDialog popup require such code as seen sbove to be written only in a class that extends Activity ?
type: UnansweredQuestion
upvote count: 1
has title: Is it compulsory to write an Alert Dialog open code inside an Activity?
score: 1
tagged with: java
type: Question
answer count: 2
downvote count: 0
tagged with: android
has answer: http://stackoverflow.com/a/21547240
has answer: http://stackoverflow.com/a/21547208
tagged with: android-activity
has comment: http://stackoverflow.com/comment/32539143
favorite count: 0
tagged with: android-alertdialog
has comment: http://stackoverflow.com/comment/32542975

http://stackoverflow.com/comment/32661698
type: AnswerComment
score: 0
type: Comment
has text: Actually functionThreadPool is not used anywhere else so I think I'll just declare it inside ExecutionEnvironment configuration. I'll let you know if it fixes it. I'm just afraid that a similar problem will pop up somewhere else in our configs.
comment on: http://stackoverflow.com/a/21600067

http://stackoverflow.com/a/21569162
downvote count: 0
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/21569017
type: Answer
has body: If you need multiple lines of data, consider using a JTextArea instead of a JTextField. You can then just append each line. while ((line = br.readLine()) != null){ textArea.append(line + "\n"); } Or better yet, to have a more structured look, look into using a JTable. See How to use Tables Here's an example you can run using a JTable import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Scanner; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.table.DefaultTableModel; public class TestTable { String[] colNames = {"Col 1", "Col 2", "Col 3", "Col 4", "Col 5"}; JTextArea textArea = new JTextArea(7, 30); JButton button = new JButton("Show Table"); JFrame frame = new JFrame("Test Table"); public TestTable() { textArea.setText(getTextForTextArea()); textArea.setEditable(false); button.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent e) { TableDialog dialog = new TableDialog(frame, true); } }); frame.add(new JScrollPane(textArea)); frame.add(button, BorderLayout.SOUTH); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true); } private String getTextForTextArea() { String line = "1, 2, 3, 4, 5"; String textForArea = ""; for (int i = 0; i &lt; 10; i++) { textForArea += line + "\n"; } return textForArea; } class TableDialog extends JDialog { public TableDialog(final JFrame frame, boolean modal) { super(frame, modal); add(new JScrollPane(createTable())); pack(); setLocationRelativeTo(frame); setVisible(true); } private JTable createTable() { String text = textArea.getText(); DefaultTableModel model = new DefaultTableModel(colNames, 0); Scanner scanner = new Scanner(text); while (scanner.hasNextLine()) { String line = scanner.nex…

http://stackoverflow.com/comment/32621671
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21591404
has text: First off you should understand how an Activity works, and what a Context is. Without that, you are going to be very very lost in the Android Framework. Start here: http://stackoverflow.com/questions/3572463/what-is-context-in-android
score: 0

http://stackoverflow.com/q/21672531
has comment: http://stackoverflow.com/comment/32761013
has comment: http://stackoverflow.com/comment/32760838
type: UnansweredQuestion
has title: Cannot Update SQL Server Database
downvote count: 1
tagged with: java
score: -1
type: Question
upvote count: 0
answer count: 1
has comment: http://stackoverflow.com/comment/32760075
favorite count: 0
tagged with: sql-server
has comment: http://stackoverflow.com/comment/32760127
has answer: http://stackoverflow.com/a/21673505
has body: In Sql Server Management Studio, i am updating database with keeping ID as primary key. From ComboBox ,i am displaying all ID and after clicking on submit button all details are displayed in jTextField correspondig to different labels having name as column in database. Here my all details are displayed getting correctly. And there is reset button which removes details of some label, even i am getting correct this alos. But i can not update tables . I am writing the code below. Please help and whats wrong into code; package corejavaproject; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.logging.Level; import java.util.logging.Logger; public class UpdateDetails extends javax.swing.JFrame { public UpdateDetails() { initComponents(); com_view(); } private void com_view() { try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); Connection con=DriverManager.getConnection("jdbc:sqlserver://AMISH-PC:1433;databaseName=Student","sa","comprishu"); Statement stmt=con.createStatement(); String str ="select ID from Details;"; ResultSet rs = stmt.executeQuery(str); while(rs.next()) { jComboBox1.addItem(rs.getString(1)); } } catch (ClassNotFoundException | SQLException ex) { ex.printStackTrace(); } } @SuppressWarnings("unchecked") // &lt;editor-fold defaultstate="collapsed" desc="Generated Code"&gt; private void initComponents() { jLabel5 = new javax.swing.JLabel(); jComboBox1 = new javax.swing.JComboBox(); jLabel8 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); jTextField6 = new javax.swing.JTextField(); jTextField5 = new javax.swing.JTextField(); jTextField3 = new javax.swing.JTextField(); jTextField4 = new javax.swing.JTextFi…

http://stackoverflow.com/comment/32580898
type: Comment
has text: @JaJ : Yes you can use like that also . In some languages (different regex falour) '/' meaning is different , that is why i sciped that also.
comment on: http://stackoverflow.com/a/21569779
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32616899
comment on: http://stackoverflow.com/q/21590117
type: QuestionComment
has text: Sure. I just posted it.
type: Comment
score: 0

http://stackoverflow.com/comment/32609593
type: Comment
type: QuestionComment
has text: I am able to get the <hello> node in the output, it fails at the exact line `<xsl:value-of select="$foo/child"/>`
comment on: http://stackoverflow.com/q/21585857
score: 0

http://stackoverflow.com/q/21548859
score: 3
tagged with: hashcode
tagged with: java
has comment: http://stackoverflow.com/comment/32542481
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/21549302
upvote count: 3
has title: Hash function for 2D point in limited Euclidean space
has comment: http://stackoverflow.com/comment/32543238
linked to: http://stackoverflow.com/q/919612
has comment: http://stackoverflow.com/comment/32543473
has comment: http://stackoverflow.com/comment/32543132
has answer: http://stackoverflow.com/a/21596003
has comment: http://stackoverflow.com/comment/32542368
favorite count: 0
tagged with: hash
downvote count: 0
has comment: http://stackoverflow.com/comment/32542409
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32542523
has body: I am storing a lot of objects with geographically positions as 2D points (x,y) in granularity of meters. To represent the world I am using a grid divided in cells of 1 square km. Currently I am using HashMap&lt;Position, Object&gt; for this. Any other map or appropriate data structure is fine, but I the solution works so I am only interested in solving the details. I have been reading a lot about making good hash functions, specifically for 2D points. So far, no solutions have been really good (rated in terms of as collision-free as possible). To test some ideas I wrote a very simple java program to generate hash codes for points from an arbitrary number (-1000,-1000) to (1000, 1000) (x1, y1 -> x2,y2) and storing them in a HashSet&lt;Integer&gt; and this is my result: # java HashTest 4000000 number of unique positions test1: 3936031 (63969 buckets, 1,60%) collisions using Objects.hash(x,y) test2: 0 (4000000 buckets, 100,00%) collisions using (x &lt;&lt; 16) + y test3: 3998000 (2000 buckets, 0,05%) collisions using x test4: 3924037 (75963 buckets, 1,90%) collisions using x*37 + y test5: 3996001 (3999 buckets, 0,10%) collisions using x*37 + y*37 test6: 3924224 (75776 buckets, 1,89%) collisions using x*37 ^ y test7: 3899671 (100329 buckets, 2,51%) collisions using x*37 ^ y*37 test8: 0 (4000000 buckets, 100,00%) collisions using PerfectlyHashThem test9: 0 (4000000 buckets, 100,00%) collisions using x &lt;&lt; 16 | (y &amp; 0xFFFF) Legend: number of collisions , buckets(collisions), perc(collisions) Most of these hash functions perform really bad. In fact, the only good solution is the one that shifts x to the first 16 bits of the integer. The limitation, I guess, is that the two most distant points must not be more than the square root of Integer.MAX_INT, i.e. area must be less than 46 340 square km. This is my test function (just copied for each new hash function): public void test1() { HashSet&lt;Integer&gt; hashCodes = new HashSet&lt;Integer&gt;(); int collisions = 0…
has comment: http://stackoverflow.com/comment/32542525

http://stackoverflow.com/q/21589278
tagged with: java
score: 15
has comment: http://stackoverflow.com/comment/32615433
has answer: http://stackoverflow.com/a/73812567
upvote count: 15
answer count: 3
downvote count: 0
tagged with: jar
has comment: http://stackoverflow.com/comment/32619092
has title: Execute a Jar with Wildcard in Path
favorite count: 0
has comment: http://stackoverflow.com/comment/32615528
has body: I have an application that launches a jar file. However, the jar has the version number in the name and will change every few months. I'm looking to write this so I don't have to update the application's code every time the jar is changed. I've tried using * for a wildcard, but I get: Error: Unable to access jarfile C:\Selenium\vendor\selenium-server-standalone-\*.jar The command I'm running is: java -jar C:\\Selenium\\vendor\\selenium-server-standalone-*.jar When I put in the version number, the jar launches successfully. Is there anyway to use a wildcard here?
type: UnansweredQuestion
tagged with: selenium
has answer: http://stackoverflow.com/a/21590254
type: Question
has answer: http://stackoverflow.com/a/21589324

http://stackoverflow.com/comment/32637209
has text: @Shuriken He does not ask which side is better at handling touch events and I can pretty well assume that he is aware of the fact that he can easily handle touch events in Java, but he does NOT want that. You can give it as an advice but it surely is not a solution to "handling touch events in NDK and sending them to Java text views". Moreover, what does this have to do with wider platform support? Can't NDK support any platform that supports Android and Java?
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21589562

http://stackoverflow.com/comment/32532859
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21520178
has text: Sometimes it might not be the problem with the program. Whats the IDE that you are using? Eclipse maybe? Try cleaning the server and the tomcat working directory. And remove the @webservlet annotation when using the request.getContextPath().

http://stackoverflow.com/q/21540127
answer count: 1
has comment: http://stackoverflow.com/comment/32528020
has title: How to multiple different types of values from a method in java and use it in the main class?
has answer: http://stackoverflow.com/a/21540363
has comment: http://stackoverflow.com/comment/32527929
type: UnansweredQuestion
has body: I have made a method which I will use several times in my main, but change the paremeters each time. I cannot figure out how to call each different values from that method. below is what I have so far for my method, it contains type Strings, int and JLABEL. private static void method(String a, int b, int c, int d, String e, JLabel f) { try { a = (String) field1.getText(); b = (int) (Double.parseDouble(studentid.getText()); c = (studentname.getText())); d = (Integer.parseInt(hourtravel.getText())); countCommandsAdded.setText("e"); contentPane.remove(f); }catch (NumberFormatException arg0){ } } How can I return, in this case I need to return String a, int b, int c, int d, and remove JLabel f from my design and change text of String e. Thanks.
has comment: http://stackoverflow.com/comment/32528023
has comment: http://stackoverflow.com/comment/32528110
tagged with: java
type: Question
score: 0

http://stackoverflow.com/q/21591148
has body: I was trying to convert json strings to objects like this: String jsonString = "[\"string1\", \"string2\"]"; Gson gson = new Gson(); List&lt;String&gt; list = gson.fromJson(jsonString, List.class); There was this warning: warning: [unchecked] unchecked conversion list = gson.fromJson(jsonString, List.class); ^ required: List&lt;String&gt; found: List I tried to use List&lt;String&gt;.class instead of List.class but I get a compile time error saying that I can't do that... How can I get rid of this warning?
upvote count: 8
accepted answer: http://stackoverflow.com/a/21591224
has comment: http://stackoverflow.com/comment/32618771
type: AnsweredQuestion
has title: Gson gives "unchecked conversion" warning
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has answer: http://stackoverflow.com/a/21591224
tagged with: gson
has comment: http://stackoverflow.com/comment/32618624
type: Question
score: 8
downvote count: 0
answer count: 1
favorite count: 0

http://stackoverflow.com/q/21664783
favorite count: 0
has answer: http://stackoverflow.com/a/21664903
has answer: http://stackoverflow.com/a/21664860
accepted answer: http://stackoverflow.com/a/21664860
type: AnsweredQuestion
tagged with: java
type: Question
has title: Count the Number of Swaps in Selection Sort
tagged with: sorting
possible better answer: http://stackoverflow.com/a/21664903
score: 0
answer count: 2
upvote count: 1
downvote count: 1
has body: I've read through all the discussions trying to find an answer but none of the answers have worked for me so I'm trying it this way. public static int SelectionSort(long[] num) { int i, j, first; long temp; int swap = 0; int pass = 0; int count = 0; boolean Mini = false; for (i = num.length - 1; i &amp;gt; 0; i--) { for(int k = 0; k &amp;lt; num.length; k++) { System.out.println(" k = " + k + " \t X[i] = " + num[k] + " swap count: " + swap); } System.out.println(""); first = 0; //initialize to subscript of first element for(j = 1; j &amp;lt;= i; j ++) //locate smallest element between positions 1 and i. { if(num[j] &amp;lt; num[first]) { first = j; //Mini = true; } } //if(Mini){ // swap++; //} temp = num[first]; //swap smallest found with element in position i. num[first] = num[i]; num[i] = temp; } return swap; } Using a simple array as my test case: long[] X = {1, 4, 3, 2, 5}; The number of swaps should only equate to 1 because it's swapping the first and last elements only. However, it isn't working. While I know my if condition doesn't work, I can't think of what would. I can't seem to work the logic that it increments a swap when items are actually swapped.

http://stackoverflow.com/q/21627799
tagged with: java
has answer: http://stackoverflow.com/a/21628142
type: Question
has answer: http://stackoverflow.com/a/21630000
answer count: 2
tagged with: junit
downvote count: 0
possible better answer: http://stackoverflow.com/a/21628142
accepted answer: http://stackoverflow.com/a/21630000
favorite count: 0
tagged with: attributes
tagged with: installation
upvote count: 2
has title: How to use attributes in JUnit Tests?
has body: I have been working with JUnit for several years and I have found many examples where isolation within the test was not fullfil. Most of the tests I develop follow the same structure class ClassToTestTest { // Attributes private ClassToTest objectToTest; // Methods @Before public void setup() { objectToTest = new ClassToTest(); } @Test public void test1() { //do something Assert... } @Test public void test2() { //do something Assert... } } The internal state of the test object (not the ClassToTest object but the object which perform the test) are in its attributes. If there is any flaw at the setup() or teardown() methods some internal state of objectToTest might sneak to other test. Just wondering, would it be better to have no shared state? you have no attributes class ClassToTestTest { // Attributes // No attributes, no internal state // Methods @Before public void setup() { objectToTest = new ClassToTest(); } @Test public void test1() { localObjectToTest = createObjectToTest(); //do something Assert... } @Test public void test2() { localObjectToTest = createObjectToTest(); //do something Assert... } } I know the first code do pretty much the same than the second, but in the first code you are tempted to do something like // Methods @Before public void setup() { objectToTest = objectToTest.reset(); } or even worse, rely on the previous test in order to use the state of the objectToTest in the previous test to "save" time and you end up with an empty setup() method Following the second code is much dificult to reach this point because there is no shared state, every object is local. What are your thoughts? Make sense? Is it worthy?
tagged with: unit-testing
type: AnsweredQuestion
score: 2

http://stackoverflow.com/a/21545226
score: 0
has body: You have 1 + n(b-1) in n(int b) function. The call n(a-1) will do 4 recursive calls to n(int b) and return 4
type: Answer
answers question: http://stackoverflow.com/q/21545137

http://stackoverflow.com/comment/32567706
has text: In any event, add println statements to print out julianDay, year, and day.
comment on: http://stackoverflow.com/q/21558975
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32585906
score: 0
type: Comment
has text: The Problem is i cant reach the plugins to download them , i ve searched in many links .
type: AnswerComment
comment on: http://stackoverflow.com/a/21572927

http://stackoverflow.com/comment/32757330
comment on: http://stackoverflow.com/q/21670923
score: 0
has text: what are the contents and sizes of your `exData` and `exLabels` arrays? are they within the limits of the values reached by `i` and `j`. Please specify the line at which you get the exception.
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21522654
has comment: http://stackoverflow.com/comment/32496339
has comment: http://stackoverflow.com/comment/32501828
has comment: http://stackoverflow.com/comment/32497864
has comment: http://stackoverflow.com/comment/32539409
has comment: http://stackoverflow.com/comment/32583593
upvote count: 2
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32516895
has comment: http://stackoverflow.com/comment/32496466
has comment: http://stackoverflow.com/comment/32579538
has comment: http://stackoverflow.com/comment/32580149
has comment: http://stackoverflow.com/comment/32496769
type: Answer
has body: You can achieve it in a cleaner way using gson. Create a POJO for Parent and an array value of type Parent[] public class Parent { public String getName() { return name; } public void setName(String name) { this.name = name; } public String getParent() { return parent; } public void setParent(String parent) { this.parent = parent; } public String getType() { return type; } public void setType(String type) { this.type = type; } public Parent[] getChildren() { return children; } public void setChildren(Parent[] children) { this.children = children; } private String name; private String parent; private String type; private Parent[] children; } Easily read the json and manipulate the Parent object thus returned: BufferedReader br = new BufferedReader(new FileReader("array.json")); //File containing your initial json Gson gson = new Gson(); Parent[] parentObjArray = gson.fromJson(br, Parent[].class); Parent folder2 = parentObjArray[1]; parentObjArray[0].setChildren(new Parent[] { folder2 }); System.out.println(gson.toJson(parentObjArray)); Resulting json: [ { "name": "folder1", "parent": "root", "type": "folder", "children": [ { "name": "folder2", "parent": "folder1", "type": "folder", "children": [] } ] }, { "name": "folder2", "parent": "folder1", "type": "folder", "children": [] } ] The above code uses a few assumptions specifically the exact indexes of your json array. You can further generalize and manipulate the json in accordance to your requirements. Further, the 2nd element of the array can be removed to hold a single object with a child. EDIT: As per your new requirement, you might want to add the files and folders too. Adopting my dirty approach I can manually set these values. However, would definitely stress on that Files and Folders can share a single data type - Parent, hence this solution becomes a good candidate to adopt a recursive approach. So it's: Folder1 ||=&gt; File1 ||=&gt; Folder2 ||=&gt; File2 Changed inout json: [ { "name": "folder1", "children"…
has comment: http://stackoverflow.com/comment/32496512
score: 2
accepted answer of: http://stackoverflow.com/q/21522223
answers question: http://stackoverflow.com/q/21522223

http://stackoverflow.com/a/21567593
upvote count: 3
type: Answer
answers question: http://stackoverflow.com/q/21564478
has body: Keep in mind that setters are exposed to the public, which means it can be overriden by its subclasses. When you create a subclass with the intent of modifying the behavior of one of its setters, the first thing that it will do in the construtor of the subclass is to call its superclass' constructor, which means that these setters and the added logic inside it will be executed when in fact you actually want modify the behavior of one of its setters. This kind of problems are often times hard to spot. A quote from Effective Java Item 17 Constructors must not invoke overridable methods, directly or indirectly. If you violate this rule, program failure will result. The superclass constructor runs before the subclass constructor, so the overriding method in the subclass will get invoked before the subclass constructor has run. If the overriding method depends on any initialization performed by the subclass constructor, the method will not behave as expected.
downvote count: 0
score: 3

http://stackoverflow.com/comment/32495103
type: Comment
has text: Hey What is "PREF_ACCOUNT_NAME" parameter
score: 0
comment on: http://stackoverflow.com/a/21520030
type: AnswerComment

http://stackoverflow.com/comment/32754895
score: 0
type: Comment
has text: Folder inbox = store.getFolder("INBOX"); Folder saved = store.getFolder("saved"); Message[] msgs = inbox.getMessages(); inbox.copyMessages(msgs, saved);
type: AnswerComment
comment on: http://stackoverflow.com/a/21653918

http://stackoverflow.com/a/21531033
downvote count: 0
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/21530943
has body: Note that your method takes argument of type Class&lt;?&gt;. The argument you pass to the Class#getDeclaredMethod() is an array of Class instances for the format parameter types of that method, which in this case will be Class.class, and not MySchool.class. So, you should get the method as: Method m = libClass.getDeclaredMethod("libMethod", new Class[]{Class.class});
score: 1
accepted answer of: http://stackoverflow.com/q/21530943
type: AcceptedAnswer

http://stackoverflow.com/comment/32530157
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21541403
has text: Something like a `JTextBox`?

http://stackoverflow.com/a/21535734
has body: You can run the below test code for the configuration in the screenshot package com.zen.samples; public class IntellijTest { public static void main(String[] args) { System.out.println("Arg 1 is " + args[0]); System.out.println("Arg 1 is " + args[1]); System.out.println("System argument is " + System.getProperty("site")); System.out.println("Classpath is " + System.getProperty("java.class.path")); } } will give the foll. output to the console Arg 1 is arg1 Arg 1 is arg2 System argument is stackoverflow Classpath is /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/lib/tools.jar:/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre/lib/JObjC.jar:/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Users/zen/IdeaProjects/code/out/production/samples:/Applications/IntelliJ IDEA 12 CE.app/lib/junit-4.10.jar:/Users/zen/Downloads/log4j-1.2.16.jar:…
score: 1
downvote count: 0
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/21532684

http://stackoverflow.com/comment/32591560
score: 0
type: Comment
type: QuestionComment
has text: @DirkLachowski could be, it's been a while with Eclipse - I'm on Intellij for GWT projects these days...
comment on: http://stackoverflow.com/q/21576404

http://stackoverflow.com/comment/99061435
score: 1
has text: getParameterValue(...) is defined in AbstractChartCustomizer
comment on: http://stackoverflow.com/a/21678493
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32688984
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21631930
has text: check this [link](http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/)

http://stackoverflow.com/comment/32621121
score: 0
type: AnswerComment
has text: Doesn't work either--the reason is because I have to get the length of the array from the file that I am reading, therefore I can't declare the array with its size before I read from the file. But when I do anything in the try/catch block, it doesn't seem to change or affect the array at all
type: Comment
comment on: http://stackoverflow.com/a/21592856

http://stackoverflow.com/comment/32750491
score: 0
type: Comment
has text: I revised my code as per: http://www.coderanch.com/how-to/java/AvailableDoesntDoWhatYouThinkItDoes and instead of for loop above, revised to: int bytesRead = 0; byte[] buffer = new byte[(int)length];//takes only int while ((bytesRead = m_dis.read(buffer)) != -1) { and everything is still the same!
type: AnswerComment
comment on: http://stackoverflow.com/a/21586297

http://stackoverflow.com/comment/32636631
score: 0
comment on: http://stackoverflow.com/a/21586111
has text: P.S. are all of your java installations up to date (including the desktop's version for other programs)? which version does your project build path target?
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32639748
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21601493
type: Comment
has text: I dont know how to to the second thing you mentioned

http://stackoverflow.com/comment/32667166
type: QuestionComment
comment on: http://stackoverflow.com/q/21618886
score: 0
has text: Sounds like you have an issue somewhere else as `JScrollPane` shouldn't resize because it's contents does, that's the point...
type: Comment

http://stackoverflow.com/q/21661745
has answer: http://stackoverflow.com/a/21661771
upvote count: 1
has title: How to know the current level of rescursion?
has answer: http://stackoverflow.com/a/21661841
has body: While debugging a recursive method, I want to know what level it is at. Give me some advices about this, be it code or IDE tools (preferably Eclipse).
favorite count: 0
possible better answer: http://stackoverflow.com/a/21661786
has answer: http://stackoverflow.com/a/21661786
answer count: 4
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
type: Question
tagged with: recursion
has answer: http://stackoverflow.com/a/21661815
accepted answer: http://stackoverflow.com/a/21661815

http://stackoverflow.com/a/21562390
score: 0
type: Answer
has body: There is the problem in the XML file the updated xml is below <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> RESTfulWebServiceExample Jersey REST Service com.sun.jersey.spi.container.servlet.ServletContainer com.sun.jersey.spi.container.ContainerRequestFilters com.easyskool.filter.ServiceFilter 1 Jersey REST Service /rest/*
answers question: http://stackoverflow.com/q/21544405

http://stackoverflow.com/a/21552918
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/32604349
answers question: http://stackoverflow.com/q/21523966
has body: $1 means an anonymous class inside your Header class. Make sure all classes, whose instances are assigned to members of classes, that are stored in the HTTP sesssion, are also serializable. In the case of anonymous classes you'd better have them transient. In this case it might be applicationListener (make it lower-case), that you probably assigned to a variable of the class. Make the variable transient.
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/32549265
has comment: http://stackoverflow.com/comment/32900718
has comment: http://stackoverflow.com/comment/32549070

http://stackoverflow.com/a/21593743
type: AcceptedAnswer
upvote count: 5
type: Answer
accepted answer of: http://stackoverflow.com/q/21593718
downvote count: 0
answers question: http://stackoverflow.com/q/21593718
has body: Use word boundary (\b): result = str.replaceAll("\\bis\\b", "is not"); NOTE: \ should be escaped. Otherwise it matches backspace (U+0008). See Demo.
score: 5

http://stackoverflow.com/comment/32760342
type: Comment
comment on: http://stackoverflow.com/q/21672713
score: 0
type: QuestionComment
has text: How brother? please tell me i really need to know this..

http://stackoverflow.com/comment/32629144
type: AnswerComment
has text: Thks Dmitri! It worked, i basically have to use the log4j.conf in the /bin of jmeter
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21571905

http://stackoverflow.com/q/21538148
has answer: http://stackoverflow.com/a/21538783
tagged with: datetime
tagged with: julian-date
tagged with: java
upvote count: 1
has body: If I execute this statement using Joda-Time: System.out.println(new DateTime(1387947600*1000L)); It prints out this date: 2013-12-24T23:00:00.000-06:00 What I am trying to create is this exact date but all I have is Julian date format 13359 in EST time zone. What I have tried is appending "20" to my julian date, giving me the String "2013359". Then I use the code: DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyDDD"); DateTime test1 = formatter.parseDateTime(d2); When I print out test1, it gives me: 2013-12-25T00:00:00.000-06:00 If I convert test1 to UTC time using DateTime test2 = test1.withZoneRetainFields(DateTimeZone.forTimeZone(TimeZone.getTimeZone("UTC"))); And then print out test2, I get: 2013-12-25T00:00:00.000Z This is not what I am looking for. How can I go from "13359" in EST zone to 2013-12-24T23:00:00.000-06:00 Anybody have any idea? I have spent weeks on this!
type: Question
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21538783
has title: Java Joda-Time DateTime How to Create a Date from a Julian date
answer count: 1
downvote count: 0
score: 1
favorite count: 0

http://stackoverflow.com/comment/32612666
comment on: http://stackoverflow.com/q/21587848
has text: Let's break the problem up. How would you go about creating a random number with a certain number of digits? What have you tried? What issues are you running into?
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/32628583
type: Comment
type: QuestionComment
has text: Try updating the post with your overridden `toString()` that prints the polynomial too
score: 2
comment on: http://stackoverflow.com/q/21597081

http://stackoverflow.com/comment/32727843
score: 1
comment on: http://stackoverflow.com/q/21653995
has text: I would be surprised if this is possible at all non-flakily.
type: Comment
type: QuestionComment

intellij-idea
tags question: http://stackoverflow.com/q/21655719
tags question: http://stackoverflow.com/q/21602764
tags question: http://stackoverflow.com/q/21611366
tags question: http://stackoverflow.com/q/21583474
tags question: http://stackoverflow.com/q/21635071
tags question: http://stackoverflow.com/q/21526610
tags question: http://stackoverflow.com/q/21515392
tags question: http://stackoverflow.com/q/21588758
tags question: http://stackoverflow.com/q/21557545
tags question: http://stackoverflow.com/q/21649392
type: Tag
tags question: http://stackoverflow.com/q/21627654
tag name: intellij-idea
tags question: http://stackoverflow.com/q/21532684
tags question: http://stackoverflow.com/q/21558855
tags question: http://stackoverflow.com/q/21639254
tags question: http://stackoverflow.com/q/21516944
tags question: http://stackoverflow.com/q/21632826
tags question: http://stackoverflow.com/q/21554350
tags question: http://stackoverflow.com/q/21668535
tags question: http://stackoverflow.com/q/21517768
tags question: http://stackoverflow.com/q/21529874
tags question: http://stackoverflow.com/q/21561157
tags question: http://stackoverflow.com/q/21649779
tags question: http://stackoverflow.com/q/21520712
tags question: http://stackoverflow.com/q/21531299
tags question: http://stackoverflow.com/q/21638783
tags question: http://stackoverflow.com/q/21605068
tags question: http://stackoverflow.com/q/21530153
tags question: http://stackoverflow.com/q/21531377
tags question: http://stackoverflow.com/q/21628129
tags question: http://stackoverflow.com/q/21599546
tags question: http://stackoverflow.com/q/21674683
tags question: http://stackoverflow.com/q/21645849

http://stackoverflow.com/comment/32662967
type: Comment
comment on: http://stackoverflow.com/a/21616567
type: AnswerComment
has text: I don't know if you want commas. I think `Arrays.deepToString()` adds ", " for each element. This may/may not be desirable for your application.
score: 0

http://stackoverflow.com/comment/32588080
has text: Of course. TomCat depends java
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21553108
type: Comment

http://stackoverflow.com/comment/32649905
type: QuestionComment
comment on: http://stackoverflow.com/q/21603270
score: 0
has text: What are you trying to do? Do you want just skip first element in list?
type: Comment

http://stackoverflow.com/comment/32941892
has text: Thanks for the hints. I have been able to follow the steps successfully. I am now trying to measure success.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/21650300
type: Comment

http://stackoverflow.com/q/21579884
tagged with: java
has title: Content of FSIMAGE and EDIT files in Hadoop command error
tagged with: hadoop
answer count: 1
tagged with: hdfs
score: 0
has answer: http://stackoverflow.com/a/21637846
accepted answer: http://stackoverflow.com/a/21637846
has body: I am using Hadoop 2.2.0 version. I want to see the content of "FSIMAGE" and "EDITS" files. i used following command: bin/hdfs oiv -i fsimage -o fsimage.txt bin/hdfs oev -i edits -o edits.xml I came to know about these commands from Aapche hadoop site documentation. I ran sample word count program and after this tried above command and got this:- rushi@ubuntu:/usr/local/hadoop$ bin/hdfs oiv -i fsimage -o fsimage.xml -p XML Exception in thread "main" java.lang.NullPointerException at org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageViewer.go(OfflineImageViewer.java:140) at org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageViewer.main(OfflineImageViewer.java:260) "fsimage.xml" file created but it is EMPTY. What may be the problem or how can i see the content of these files ?
type: Question
type: AnsweredQuestion

http://stackoverflow.com/q/21534379
has comment: http://stackoverflow.com/comment/32518123
answer count: 4
has answer: http://stackoverflow.com/a/21534677
has answer: http://stackoverflow.com/a/21534651
has body: I have a bash script that look like below. All I am doing here is trying to run a java program passing in classpath and other inputs. [guest@server1]# cat runJava #!/bin/bash JARS=/home/guest/lib/* CONFIG=/home/guest/AnalyticServer.properties echo JARS=$JARS echo CONFIG=$CONFIG echo "java -cp \"$JARS\" com.test.ASDataSourceClient DELETE -c \"$CONFIG\" -n test_ds" java -cp "$JARS" com.test.ASDataSourceClient DELETE -c "$CONFIG" -n test_ds The java program runs perfectly fine when run directly on command line/terminal. I even tested running all the commands from above script on terminal directly(one by one) and verified that java program runs fine. However, when I launch these commands via script, I am having issue. It doesn't even seem to execute echo "java -cp .." command properly. Could anyone advice what I may be missing. [guest@server1]# bash runJava JARS=/home/guest/lib/* CONFIG=/home/guest/AnalyticServer.properties " -n test_dsaSourceClient DELETE -c "/home/guest/AnalyticServer.properties Exception in thread "main" java.lang.NoClassDefFoundError: com/test/ASDataSourceClient Caused by: java.lang.ClassNotFoundException: com.test.ASDataSourceClient at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Could not find the main class: com.test.ASDataSourceClient. Program will exit.
has title: Having issue running JAVA program inside BASH script
type: Question
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/21534677
possible better answer: http://stackoverflow.com/a/21534406
has answer: http://stackoverflow.com/a/21535671
has answer: http://stackoverflow.com/a/21534406
score: 0
tagged with: bash

http://stackoverflow.com/a/21636830
score: 3
answers question: http://stackoverflow.com/q/21636767
has body: The reason you are getting this error is because array objects in Java don't have a .remove() method. If you really want a dynamic collection that you can remove objects from, you should use an ArrayList. Just replace the arrays in your method signature with ArrayLists, then in your body replace array1[i] with array1.get(i) like so: public static void removeGames(Scanner keyboard, ArrayList&lt;String&gt; array1, ArrayList&lt;Double&gt; array2, ArrayList&lt;Double&gt; array3, int currentLength) { String removeInput; System.out.println("Enter the name of the game you would like to remove" + " from the list: "); removeInput = keyboard.next(); for(int i = 0; i &lt; array1.length; i++) { if(removeInput.equalsIgnoreCase(array1.get(i)) { array1.remove(i); array2.remove(i); array3.remove(i); } } } Just make sure to import java.util.ArrayList.
has comment: http://stackoverflow.com/comment/32698165
upvote count: 3
type: Answer
downvote count: 0

http://stackoverflow.com/comment/32711185
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21644248
has text: ok @Simon i have edited the question. can you plz check and let me know what the exact error is..

http://stackoverflow.com/q/21665781
has body: Is it possible to create a user-defined exception and only catch it in a try-catch or does the user-defined exception have to be thrown with the throw statement. Question: I am somewhat confused on whether when to use the throw keyword? I think that the throw is used with user-defined Exceptions. Code: (Java) public genericPanel() { try { if (i.length == size) { throw new MyOwnDefinedError("Error - Size is 1 integer to large"); } for (int index=0;index&lt;=i.length;index++) { System.out.println(i[index]); } } catch (MyOwnDefinedError o) { o.getMessage(); } catch (Exception e) { e.getMessage(); } } class MyOwnDefinedError extends Exception { MyOwnDefinedError(String myNewString) { super( myNewString); }
has answer: http://stackoverflow.com/a/21665827
has answer: http://stackoverflow.com/a/21665875
score: 0
tagged with: java
has answer: http://stackoverflow.com/a/21666495
has comment: http://stackoverflow.com/comment/32752822
type: Question
has comment: http://stackoverflow.com/comment/32748736
has title: When to use the user Java keyword Throw on a user-defined Exception?
has answer: http://stackoverflow.com/a/21665800
has answer: http://stackoverflow.com/a/21665814
answer count: 5
type: UnansweredQuestion

http://stackoverflow.com/q/21542881
upvote count: 1
has answer: http://stackoverflow.com/a/21543011
type: Question
score: 1
tagged with: java
downvote count: 0
has answer: http://stackoverflow.com/a/21544224
favorite count: 0
has answer: http://stackoverflow.com/a/21544292
has answer: http://stackoverflow.com/a/21542894
type: UnansweredQuestion
has title: Java read text file and search for a line
has body: I have the following code, which read thru the files and search for the line that start with subject and print out that line. But I only want to read the first line that contain the 'Subject' but currently it getting all the line that start with 'Subject' how can I configure such that it search for the first 'Subject' and print that one line ? br = new BufferedReader(new FileReader("FilePath")); StringBuilder sb = new StringBuilder(); String line = ""; while ((line = br.readLine()) != null) { if (line.startsWith("Subject ")) { System.out.println(line); } }
answer count: 4
tagged with: file

http://stackoverflow.com/q/21534091
answer count: 5
type: UnansweredQuestion
has body: I'm working on an assignment for a low-level java class. I have it mostly finished, but I'm stuck on how to use an ArrayList. There are two classes, the second one (PizzaMaker) is the client. I need to initialize an ArrayList in the first class and then add three items to it via user input from the client. I know how to initialize the ArrayList, but I'm having problems adding items to the list. When I run the code I have now, it returns with empty brackets [ ] or null. I'm not expecting someone to do my homework for me, but a clue as to where I'm going wrong with this code would be helpful. import java.util.*; public class Pizza { private String brand; private int size; private ArrayList&lt;String&gt; toppings = new ArrayList&lt;String&gt;(); public Pizza(String brand, int size) { this.brand = brand; this.size = size; } public void changeBrand(String brandName) { brand = brandName; } public void changeSize(int pizzaSize) { size = pizzaSize; } public void addTopping(String topping) { toppings.add("topping"); } public String getPizzaInfo() { String result = "You want a "+ size +" inch pizza made by: "+ brand +" with these toppings:" + toppings; return result; } } public class PizzaMaker { public static void main( String[] args) { int size = -1; String brand = ""; String topping = ""; brand = getBrand(); size = getSize(); topping = getTopping(); Pizza newPizza = new Pizza(brand, size); System.out.println(newPizza.getPizzaInfo()); } public static String getBrand() { Scanner kb = new Scanner(System.in); System.out.println("Enter a brand name: "); String brandName = kb.nextLine(); return brandName; } public static int getSize() { Scanner kb = new Scanner(System.in); System.out.println("Enter a size: "); int pizzaSize = kb.nextInt(); kb.nextLine(); return pizzaSize; } public static String getTopping() { Scanner kb = new Scanner(System.in); System.out.println("Enter topping: "); String topping = kb.nextLine(); return topping; } public static boolean getAgain() { return true…
upvote count: 1
has answer: http://stackoverflow.com/a/21534619
type: Question
has answer: http://stackoverflow.com/a/21534193
has comment: http://stackoverflow.com/comment/32516966
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/21534880
has title: Creating and Returning Values from an ArrayList in Java
has answer: http://stackoverflow.com/a/21534246
tagged with: class
has comment: http://stackoverflow.com/comment/32516971
has comment: http://stackoverflow.com/comment/32516961
downvote count: 0
has answer: http://stackoverflow.com/a/21534417
has comment: http://stackoverflow.com/comment/32516878
favorite count: 0
tagged with: arraylist

http://stackoverflow.com/comment/32699585
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21636457
type: Comment
has text: @AlessandroS. you're welcome:) Don't worry it's not embarrassing at all, we all get stuck in troubles that once solved seem silly but in the meanwhile they exceed us. It happens all the time. It's not just about the EDT but the most important is the SwingWorker will automatically enable the list when `doInBackground` finishes ;)

encryption
tags question: http://stackoverflow.com/q/21655286
tags question: http://stackoverflow.com/q/21651444
tags question: http://stackoverflow.com/q/21610791
tag name: encryption
tags question: http://stackoverflow.com/q/21594387
tags question: http://stackoverflow.com/q/21578790
tags question: http://stackoverflow.com/q/21599451
tags question: http://stackoverflow.com/q/21570972
tags question: http://stackoverflow.com/q/21581347
tags question: http://stackoverflow.com/q/21658033
tags question: http://stackoverflow.com/q/21594859
tags question: http://stackoverflow.com/q/21565369
tags question: http://stackoverflow.com/q/21557645
tags question: http://stackoverflow.com/q/21664967
tags question: http://stackoverflow.com/q/21678114
tags question: http://stackoverflow.com/q/21585368
tags question: http://stackoverflow.com/q/21660886
tags question: http://stackoverflow.com/q/21518678
tags question: http://stackoverflow.com/q/21630458
type: Tag

http://stackoverflow.com/a/21615373
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21615337
has body: No, generics cannot have a primitive type as the generic type parameter; it must be a reference type, such as Integer. Additionally, you are declaring a generic type parameter Integer that is now hiding the actual java.lang.Integer class. If MyClass wasn't itself meant to be generic, then remove it from the class: public class MyClass extends AnotherOne&lt;Integer&gt; If it was, use a single capital letter for the generic type parameter: public class MyClass&lt;T&gt; extends AnotherOne&lt;T&gt;
answers question: http://stackoverflow.com/q/21615337
type: Answer
upvote count: 4
score: 4

http://stackoverflow.com/q/21615748
tagged with: jdoql
score: 0
accepted answer: http://stackoverflow.com/a/21741080
answer count: 1
has body: I have verified that the entity I am looking for is in the datastore. I have verified that the list I pass as a method parameter contains this entity. I am trying to find all objects that have their 'userGmail' contained in the list of strings I pass. Here is my code @SuppressWarnings("unchecked") @ApiMethod(name = "findFriendsByEmailList") public CollectionResponse&lt;ZeppaUser&gt; findFriendsByEmailList( @Named("emailsList") List&lt;String&gt; emailsList, User user) throws OAuthRequestException { if (user == null) { throw new OAuthRequestException( "Null User Authorization Exception, findFriendsByEmailList"); } PersistenceManager mgr = null; List&lt;ZeppaUser&gt; execute = null; Query query = null; try { mgr = getPersistenceManager(); query = mgr.newQuery(ZeppaUser.class); query.declareParameters("java.util.List emailListParam"); query.setFilter("emailListParam.contains( userGmail )"); execute = (List&lt;ZeppaUser&gt;) query.execute(emailsList); query.closeAll(); } finally { mgr.close(); } return CollectionResponse.&lt;ZeppaUser&gt; builder().setItems(execute) .build(); } This is the stack trace I receive from it: Something worth noting: I do not receive this error on lists I pass in that to not contain an element found in the datastore. Just when it does exist which leads me to believe that the Query has located the element but has not been closed or executed into a return parameter correctly. If it is preferable to return List that is more than ok. I have tried multiple variations of this with no success thus far. It is getting quite frustrating.
tagged with: google-app-engine
has answer: http://stackoverflow.com/a/21741080
type: AnsweredQuestion
has title: GAE Query with Collection Parameter
tagged with: java
tagged with: jdo
type: Question

http://stackoverflow.com/comment/32562675
type: QuestionComment
has text: Why not use `switch`?
score: 0
comment on: http://stackoverflow.com/q/21560142
type: Comment

http://stackoverflow.com/q/21550369
type: Question
tagged with: jersey
answer count: 1
tagged with: tomcat
upvote count: 7
favorite count: 0
downvote count: 0
has title: java.net.SocketTimeoutException on embedded tomcat with jersey
has answer: http://stackoverflow.com/a/21572143
accepted answer: http://stackoverflow.com/a/21572143
type: AnsweredQuestion
score: 7
tagged with: java
has body: My server application use embedded tomcat with Jersey. From time to time I'm getting the following error: 02-03-2014 10:06:05 [com.sun.jersey.spi.container.ContainerResponse] [http-nio-8243-exec-4] [ERROR] - The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container java.net.SocketTimeoutException at org.apache.tomcat.util.net.NioBlockingSelector.read(NioBlockingSelector.java:191) at org.apache.tomcat.util.net.NioSelectorPool.read(NioSelectorPool.java:246) at org.apache.tomcat.util.net.NioSelectorPool.read(NioSelectorPool.java:227) at org.apache.coyote.http11.InternalNioInputBuffer.readSocket(InternalNioInputBuffer.java:419) at org.apache.coyote.http11.InternalNioInputBuffer.fill(InternalNioInputBuffer.java:789) at org.apache.coyote.http11.InternalNioInputBuffer$SocketInputBuffer.doRead(InternalNioInputBuffer.java:814) at org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:124) at org.apache.coyote.http11.AbstractInputBuffer.doRead(AbstractInputBuffer.java:346) at org.apache.coyote.Request.doRead(Request.java:422) at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:290) at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:449) at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:315) at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:200) at sun.nio.cs.StreamDecoder.readBytes(Unknown Source) at sun.nio.cs.StreamDecoder.implRead(Unknown Source) at sun.nio.cs.StreamDecoder.read(Unknown Source) at java.io.InputStreamReader.read(Unknown Source) at java.io.Reader.read(Unknown Source) at com.google.common.io.CharStreams.copy(CharStreams.java:202) at com.google.common.io.CharStreams.toStringBuilder(CharStreams.java:248) at com.google.common.io.CharStreams.toString(CharStreams.java:222) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unk…
tagged with: embedded-tomcat-7

http://stackoverflow.com/comment/32571828
score: 0
type: Comment
comment on: http://stackoverflow.com/q/21564650
type: QuestionComment
has text: @JoshDM for access on filesystem I have read of to use sendfile() system call. I wanted more details.

http://stackoverflow.com/comment/32484600
type: Comment
comment on: http://stackoverflow.com/a/21515866
score: 0
type: AnswerComment
has text: Wat? Where'd the `-1` bit come from?

http://stackoverflow.com/comment/32497166
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21523274
has text: @Bohemian Yes I think you've already done that! Still funny though!

http://stackoverflow.com/a/21649374
has comment: http://stackoverflow.com/comment/32724397
has comment: http://stackoverflow.com/comment/32732880
answers question: http://stackoverflow.com/q/21648923
type: Answer
score: 2
downvote count: 0
has body: An example should help, but it seems a 1 character ISO 8601 time zone: String myDate="2001-07-04T12:08:56GMT-3"; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'GMT'X"); if (myDate.indexOf("GMT-") &gt;= myDate.length() -1 -4) { myDate = myDate.replace("-","-0"); } if (myDate.indexOf("GMT+") &gt;= myDate.length() -1 -4) { myDate = myDate.replace("+","+0"); } System.out.println(format.parse(myDate)); it should work. the yyyy-MM-dd'T'HH:mm:ss'GMT'X is compliant with iso8601 time zone myDate = myDate.replace("-","-0"); adjusts the date to your format
upvote count: 2

http://stackoverflow.com/comment/32662547
has text: And what is your problem? What have you tried so far?
comment on: http://stackoverflow.com/q/21616404
score: 4
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21616942
type: Answer
answers question: http://stackoverflow.com/q/21616122
score: 0
has body: I made some modifications on your search method, and it worked: fileSearch.searchDirectory(new File("C:/Windows"), "notepad.exe"); Search method private void search(File file) { if (file != null &amp;&amp; file.isDirectory()) { File[] files = file.listFiles(); if (files != null) { for (File temp : files) { if (temp != null) search(temp); } } } else if (getFileNameToSearch().equals(file.getName())) { result.add(file.getAbsoluteFile().toString()); } } The null checks may seem overkill but they were necessary in my attempts. Also, in directories as big as C:\Windows, it might take a while. Copying the notepad.exe from its directory to a test directory, I was able to find a match for the search, but unable to start the executable. The reasons for that are beyond my knowledge.
has comment: http://stackoverflow.com/comment/32785841

http://stackoverflow.com/q/21571582
has answer: http://stackoverflow.com/a/21571691
has comment: http://stackoverflow.com/comment/32583367
has comment: http://stackoverflow.com/comment/32583540
has comment: http://stackoverflow.com/comment/32583521
type: Question
has answer: http://stackoverflow.com/a/21571753
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32584654
tagged with: java
possible better answer: http://stackoverflow.com/a/21571691
has comment: http://stackoverflow.com/comment/32584311
accepted answer: http://stackoverflow.com/a/21571736
tagged with: eclipse
tagged with: apache
linked to: http://stackoverflow.com/q/1163493
tagged with: jsp
has answer: http://stackoverflow.com/a/21571736
tagged with: tomcat
score: 0
answer count: 3
has title: Error 404 in Apache Tomcat using Eclipse
has body: I'm trying to run a basic servlet using Eclipse and Tomcat 7.0 but it keeps giving the 404 error HTTP Status 404 - /ServletExample/ -------------------------------------------------------------------------------- type Status report message /ServletExample/ description The requested resource (/ServletExample/) is not available. -------------------------------------------------------------------------------- Apache Tomcat/7.0.27 The different codes are : Home.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> My first JSP Please enter a colour HelloWorld.java import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.PrintWriter; public class HelloWorld extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // reading the user input String color= request.getParameter("color"); PrintWriter out = response.getWriter(); out.println ( " \n" + " \n" + " \n" + " \n" + " My first jsp \n" + " \n" + " \n" + "" + "Hello World" + " \n" + " \n" + " " ); } } web.xml <?xml version="1.0" encoding="UTF-8"?> Hello HelloWorld Hello /HelloServlet I've followed all the steps specified in this thread Yet the error persists. Please help

http://stackoverflow.com/comment/32568971
type: Comment
score: 1
comment on: http://stackoverflow.com/a/21563646
type: AnswerComment
has text: Thx for your answer! Thats correct. However, my problem is the output of the `SimpleRegression class`. When comparing to excel I get false values! Any idea why am I getting them? Please also see my update!

http://stackoverflow.com/comment/32717104
has text: You said `field of type MyType<int>`. Please show us with an example.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/21647501
type: QuestionComment

http://stackoverflow.com/q/21603650
has answer: http://stackoverflow.com/a/21603698
tagged with: netbeans
has answer: http://stackoverflow.com/a/45310144
has title: Netbeans `The conditional statement is redundant`
upvote count: 2
answer count: 4
score: 2
type: AnsweredQuestion
tagged with: conditional-statements
has answer: http://stackoverflow.com/a/21603757
tagged with: java
has body: Netbeans gives me The conditional statement is redundant warning for this: return (this.getId(person) == null) ? false : true; And if I comply with that, it changes to this: return (this.getId(person) != null); Are these two equal? How is the second one conditional?
type: Question
has answer: http://stackoverflow.com/a/21603686
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/21603757
possible better answer: http://stackoverflow.com/a/21603698

http://stackoverflow.com/comment/32733865
type: Comment
comment on: http://stackoverflow.com/a/21657557
has text: thanks Jigar. This really makes me feel stupid. But what i was trying to do was create an 2D array from aTwoD[1][1] to aTwoD[2][2]. That is why i was using "<=" and N = 2. Is there a special way of doing that ?
score: 0
type: AnswerComment

android-layout
tags question: http://stackoverflow.com/q/21600781
tags question: http://stackoverflow.com/q/21532709
tag name: android-layout
tags question: http://stackoverflow.com/q/21585756
tags question: http://stackoverflow.com/q/21637563
tags question: http://stackoverflow.com/q/21566442
tags question: http://stackoverflow.com/q/21628933
tags question: http://stackoverflow.com/q/21645259
tags question: http://stackoverflow.com/q/21531475
tags question: http://stackoverflow.com/q/21614602
tags question: http://stackoverflow.com/q/21586858
tags question: http://stackoverflow.com/q/21662397
tags question: http://stackoverflow.com/q/21568473
tags question: http://stackoverflow.com/q/21674729
type: Tag
tags question: http://stackoverflow.com/q/21522042
tags question: http://stackoverflow.com/q/21645681
tags question: http://stackoverflow.com/q/21610387
tags question: http://stackoverflow.com/q/21654482
tags question: http://stackoverflow.com/q/21639505
tags question: http://stackoverflow.com/q/21630840
tags question: http://stackoverflow.com/q/21671990
tags question: http://stackoverflow.com/q/21651060
tags question: http://stackoverflow.com/q/21589808
tags question: http://stackoverflow.com/q/21659892
tags question: http://stackoverflow.com/q/21534734
tags question: http://stackoverflow.com/q/21523192
tags question: http://stackoverflow.com/q/21602537

http://stackoverflow.com/comment/32488386
type: Comment
has text: Aside from what the answers already say, you should really check your braces (`{}`), they seem to be quite out of balance, which may also confuse your compiler.
type: QuestionComment
comment on: http://stackoverflow.com/q/21517956
score: 0

http://stackoverflow.com/a/21663074
has body: I figured it out. It seems the problem was with the database. getActivity in Frag_MainList would be called before the activity was actually created. Putting getActivity in the the "onActivityCreated" method allowed for getActivity to be properly called and seemed to take away all the problems it was causing. I think the reason it was showing a fragment error is because the fragment was faulty, making inflating in it impossible. Thanks everyone!
upvote count: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21655053
answers question: http://stackoverflow.com/q/21655053
type: Answer
downvote count: 0
score: 1

http://stackoverflow.com/q/21664875
answer count: 2
has answer: http://stackoverflow.com/a/21664931
upvote count: 1
tagged with: arrays
duplicate of: http://stackoverflow.com/q/529085
possible better answer: http://stackoverflow.com/a/21664931
tagged with: generics
has body: I recently started learning about JAVA generics. Everything made sense and I kinda understand them now. But one thing bugged me out - you cannot create array of the generic type. I wanted to implement Abstract Data Types such as queue and stack, but with some generic type as the underlying data stored in the stack. How would I get around that ? I am sure I am missing but what it is ? Thanks in advance.
type: AnsweredQuestion
downvote count: 0
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/21664946
has title: Java Generics. Array of the generic type
accepted answer: http://stackoverflow.com/a/21664946
score: 1
tagged with: java
tagged with: adt
linked to: http://stackoverflow.com/q/529085

http://stackoverflow.com/a/21530888
type: Answer
downvote count: 1
upvote count: 0
score: -1
has body: You can implement something like this. enum Pattern { DOT_BLUE, DOT_YELLOW, SQUARE_BLUE, SQUARE_YELLOW; Pattern fromString(String code) { for(Pattern p : values()) { if(p.toString().equals(code)) return p } return null; } } Perhaps better if you implement a NULL_PATTERN and return it instead. Also, if there are many values, you can cut the search time by creating an internal Map and do lookups.
answers question: http://stackoverflow.com/q/21530689

http://stackoverflow.com/q/21545887
answer count: 1
tagged with: class
accepted answer: http://stackoverflow.com/a/21546560
score: 0
tagged with: android
tagged with: field
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21546560
tagged with: java-native-interface
tagged with: java
type: Question
has body: Here is my scenario, I create a method in JNI that will be called in my java code. basically the method is getting the list of a Certificate. The method contains a certificate class parameter called CertInfo, it has fields (a byte array) called ckvalue and ckaid and I need to return the CertInfo class to the calling java method. My question is how can I pass the value "12345678" to the field ckvalue that is inside the CertInfo? jclass CertificateInfoClass = env-&gt;FindClass("CertInfo"); jbyte certval = env-&gt;GetFieldID( clazz, "ckvalue", "Ljava/lang/String;" ); Thanks in advance!:)
has title: Set Class fields in jni

http://stackoverflow.com/q/21551545
tagged with: swing
accepted answer: http://stackoverflow.com/a/21551644
score: 2
type: AnsweredQuestion
tagged with: java
has title: 2D ArrayList For DataBase Table
type: Question
downvote count: 0
answer count: 1
has body: I am currently stuck on a section of code. I have a database and would like to put the information into an arrayList. At a later stage this arrayList needs to be put into a JTable. At the moment I can get all the rows to print, however all the rows print as one line with all the information, instead of each row printing as its own row. Not sure if that makes sense, my code is below: ArrayList&lt;ArrayList&lt;String&gt;&gt; movies = new ArrayList&lt;ArrayList&lt;String&gt;&gt;(); ArrayList&lt;String&gt; movs = new ArrayList&lt;String&gt;(); while(rs.next()){ movs.add(rs.getString("movie_id")); movs.add(rs.getString("movie_name")); movs.add(rs.getString("description")); movies.add(movs); for(ArrayList&lt;String&gt; ls : movies) { System.out.println(Arrays.deepToString(ls.toArray())); } } Output is as follows: [1, The Place Beyond The Pines, A motorcycle stunt rider (Gosling) turns to robbing banks as a way to provide for his ex-lover (Mendes) and their newborn child.], 2, Riddick, Betrayed by his own kind and left for dead on a sun-scorched planet, Riddick fights for survival against alien beasts and becomes more powerful than ever before.] ETCETC [1, The Place Beyond The Pines, A motorcycle stunt rider (Gosling) turns to robbing banks as a way to provide for his ex-lover (Mendes) and their newborn child., 2, Riddick, Betrayed by his own kind and left for dead on a sun-scorched planet, Riddick fights for survival against alien beasts and becomes more powerful than ever before.] ETC ETC for the next 22 lines(thats the number of rows in my table in access) Other information: Just repeats all the rows in one line. Furthermore if any tips can be given on the JTable front, that would be brilliant. I am not sure how to get the above(in code) column names and the aforementioned rows to be part of the JTable. Many thanks and apologies in advance for my noobery! :> JTable code - JTable table = new JTable((TableModel) movies); JScrollPane spane = new JScrollPane(table); setCont…
tagged with: arraylist
tagged with: jtable
has answer: http://stackoverflow.com/a/21551644
tagged with: ms-access
favorite count: 0
upvote count: 2
has comment: http://stackoverflow.com/comment/32546763

http://stackoverflow.com/q/21667750
score: 1
tagged with: java
has title: Multiple spaces in Java documentation using Eclipse
tagged with: eclipse
type: Question
has comment: http://stackoverflow.com/comment/32752361
downvote count: 0
has body: For a method documentation I'd like to have multiple spaces between two words. Like this: Yet all I get is this in Eclipse using the @code and @literal tags: Is there a way to tell Eclipse not to remove those spaces? Because they matter to the documentation. Thanks Edit: Thanks to David Wallace's help I realized &lt;pre&gt; is the right tag to preserve spaces. &amp;nbsp; works too, but it incurs quite a bit of visual noise. Here's a screenshot of the different tags for comparison:
tagged with: documentation
has comment: http://stackoverflow.com/comment/32752393
favorite count: 0
answer count: 0
has comment: http://stackoverflow.com/comment/32752245
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32752192
upvote count: 1
has comment: http://stackoverflow.com/comment/32752200
has comment: http://stackoverflow.com/comment/32752169
has comment: http://stackoverflow.com/comment/32752308
has comment: http://stackoverflow.com/comment/32752303

http://stackoverflow.com/comment/32708057
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21642286
type: Comment
has text: Actually data is going to be available in real time, so users make requests and need to receive the most updated results. Therefore I need to make the request to all web services per users' requests.

http://stackoverflow.com/q/21592436
tagged with: eclipse
tagged with: post
tagged with: get
score: 0
has comment: http://stackoverflow.com/comment/32620631
answer count: 1
accepted answer: http://stackoverflow.com/a/21592550
has comment: http://stackoverflow.com/comment/32620591
type: AnsweredQuestion
has body: I'm trying to make java make a new addition to a url shortener, here's what I have: private void sendPost() throws Exception { String url = "http://shmkane.com/index.php?"; URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("POST"); con.setRequestProperty("User-Agent", USER_AGENT); con.setRequestProperty("Accept-Language", "en-US,en;q=0.5"); String urlParameters = "url=testingThis"; con.setDoOutput(true); DataOutputStream wr = new DataOutputStream(con.getOutputStream()); wr.writeBytes(urlParameters); wr.flush(); wr.close(); int responseCode = con.getResponseCode(); System.out.println("\nSending 'POST' request to URL : " + url); System.out.println("Post parameters : " + urlParameters); System.out.println("Response Code : " + responseCode); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); } I'd like for it to put something in "form1" and then "submit" I'm very new to this so any help would be great, possible tell me what I'm doing wrong or improving/fixing the code I currently have.
has comment: http://stackoverflow.com/comment/32620600
has title: Java - sending POST
has comment: http://stackoverflow.com/comment/32620567
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/21592550

http://stackoverflow.com/comment/32628967
comment on: http://stackoverflow.com/q/21597477
has text: I think you are missing the initialization for checkbyinternet and checkbysms.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32759717
has text: so its better to do what I do at the moment?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21672177
score: 0

http://stackoverflow.com/q/21565882
possible better answer: http://stackoverflow.com/a/21566015
tagged with: nullpointerexception
has answer: http://stackoverflow.com/a/21566015
has comment: http://stackoverflow.com/comment/32573495
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21565993
has comment: http://stackoverflow.com/comment/32574132
has comment: http://stackoverflow.com/comment/32573603
has comment: http://stackoverflow.com/comment/32573516
upvote count: 1
accepted answer: http://stackoverflow.com/a/21565993
type: Question
linked to: http://stackoverflow.com/q/218384
has title: Game display null pointer exception
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32573738
has body: I am trying to display a black window yet I keep getting null pointer exception on line 72 and 43. This is the base for my video game and I have been using tutorials to help me along since I am new to java. It started as an unreachable code error but I fixed that by return and then this problem immediately came up any help? Code: package com.tyler99b.platformer.window; import java.awt.Canvas; import java.awt.Color; import java.awt.Graphics; import java.awt.image.BufferStrategy; public class Game extends Canvas implements Runnable { private static final long serialVersionUID = 506346024107270629L; private boolean running = false; private Thread thread; public synchronized void start(){ if(running) return; running = true; thread = new Thread(this); thread.start(); } public void run() { long lastTime = System.nanoTime(); double amountOfTicks = 60.0; double ns = 1000000000 / amountOfTicks; double delta = 0; long timer = System.currentTimeMillis(); int updates = 0; int frames = 0; while(running){ long now = System.nanoTime(); delta += (now - lastTime) / ns; lastTime = now; while(delta &gt;= 1){ tick(); updates++; delta--; } render(); frames++; if(System.currentTimeMillis() - timer &gt; 1000){ timer += 1000; System.out.println("FPS: " + frames + " TICKS: " + updates); frames = 0; updates = 0; } } } private void tick() { } private void render() { BufferStrategy bs = this.getBufferStrategy(); if(bs == null); { this.createBufferStrategy(3); } Graphics g = bs.getDrawGraphics(); g.setColor(Color.black); g.fillRect(0,0, getWidth(), getHeight()); g.dispose(); bs.show(); } public static void main(String args[]){ new Window(800,600, "Platformer Prototype", new Game ()); } }
answer count: 2
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/32573448

http://stackoverflow.com/comment/32621322
type: AnswerComment
comment on: http://stackoverflow.com/a/21592930
type: Comment
has text: @Xbit I'm wondering that as well lol. The OP hasn't given us much to go on. I'm assuming that `letter` and `plusMinusSign` are strings (fair assumption) and he already has taken in the user input to get those strings.
score: 1

http://stackoverflow.com/q/21631052
has comment: http://stackoverflow.com/comment/34008461
has title: What does "eliminated" mean in a Java stack trace?
has comment: http://stackoverflow.com/comment/32688712
linked to: http://stackoverflow.com/q/771430
score: 22
upvote count: 22
accepted answer: http://stackoverflow.com/a/24515068
downvote count: 0
answer count: 1
favorite count: 0
has body: I'm looking at a thread dump of my Java application, and have noticed that sometimes instead of showing "locked", I see the keyword "eliminated", as seen below: "Worker [4]" prio=10 tid=0x00007fb1262d8800 nid=0x89a0 in Object.wait() [0x00007fb15b147000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) at java.lang.Object.wait(Object.java:503) at com.myapp.common.util.WaitableQueue.getAll(WaitableQueue.java:152) - eliminated &lt;0x00000004d0d28e18&gt; (a com.myapp.common.util.balq.SingleQueueQController$_WorkerQueue) at com.myapp.common.util.balq.SingleQueueQController$_WorkerQueue.getAll(SingleQueueQController.java:3527) - locked &lt;0x00000004d0d28e18&gt; (a com.myapp.common.util.balq.SingleQueueQController$_WorkerQueue) at com.myapp.common.util.AbstractWorker.read(AbstractWorker.java:678) at com.myapp.common.util.AbstractWorker.runBulk(AbstractWorker.java:541) at com.myapp.common.util.AbstractWorker.run(AbstractWorker.java:343) Surprisingly, I can't find anything on Google about this. What is the difference between the "locked" and "eliminated" keywords?
linked to: http://stackoverflow.com/q/7029326
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/37792715
tagged with: java
has answer: http://stackoverflow.com/a/24515068
has comment: http://stackoverflow.com/comment/32687237
type: Question

http://stackoverflow.com/a/21566982
answers question: http://stackoverflow.com/q/21561879
type: AcceptedAnswer
downvote count: 0
score: 1
type: Answer
has body: You are using an unsorted mixture of readUTF(), writeUTF(), readLine(), etc. They're not all interoperable. Settle on one of them. If you use writeUTF() you must use readUTF() at the other end. If you use readLine() you must write lines at the other end, with a line terminator such as \r\n or \n.
upvote count: 1
accepted answer of: http://stackoverflow.com/q/21561879

user-interface
tags question: http://stackoverflow.com/q/21637808
tags question: http://stackoverflow.com/q/21514872
tags question: http://stackoverflow.com/q/21605173
tags question: http://stackoverflow.com/q/21613321
tags question: http://stackoverflow.com/q/21626543
type: Tag
tags question: http://stackoverflow.com/q/21660132
tags question: http://stackoverflow.com/q/21530482
tags question: http://stackoverflow.com/q/21655167
tags question: http://stackoverflow.com/q/21565763
tags question: http://stackoverflow.com/q/21516770
tags question: http://stackoverflow.com/q/21545320
tags question: http://stackoverflow.com/q/21615990
tags question: http://stackoverflow.com/q/21531632
tags question: http://stackoverflow.com/q/21546732
tags question: http://stackoverflow.com/q/21535737
tags question: http://stackoverflow.com/q/21558916
tags question: http://stackoverflow.com/q/21675390
tags question: http://stackoverflow.com/q/21553106
tags question: http://stackoverflow.com/q/21545615
tags question: http://stackoverflow.com/q/21660694
tags question: http://stackoverflow.com/q/21588789
tags question: http://stackoverflow.com/q/21645917
tags question: http://stackoverflow.com/q/21562350
tags question: http://stackoverflow.com/q/21666156
tags question: http://stackoverflow.com/q/21569017
tags question: http://stackoverflow.com/q/21552417
tags question: http://stackoverflow.com/q/21668115
tags question: http://stackoverflow.com/q/21654300
tags question: http://stackoverflow.com/q/21663966
tags question: http://stackoverflow.com/q/21669117
tags question: http://stackoverflow.com/q/21640332
tags question: http://stackoverflow.com/q/21666662
tag name: user-interface
tags question: http://stackoverflow.com/q/21561357
tags question: http://stackoverflow.com/q/21589521
tags question: http://stackoverflow.com/q/21561295
tags question: http://stackoverflow.com/q/21614910
tags question: http://stackoverflow.com/q/21658491
tags question: http://stackoverflow.com/q/21563755
tags question: http://stackoverflow.com/q/21532245

http://stackoverflow.com/comment/32602541
has text: @Puce The actual data is stored along with the array for access at runtime, not in the bytecode. It is metadata only in the sense that it's not data, not in the sense that it's part of bytecode.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21582008
score: 0

http://stackoverflow.com/comment/32749146
type: Comment
has text: close() first flush()es.
comment on: http://stackoverflow.com/a/21666005
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32501975
comment on: http://stackoverflow.com/q/21525993
type: Comment
type: QuestionComment
has text: if(jarray.getJSONObject(i).has(ClassVariable.SUBMENU.SUBMENU)) { JSONArray jarraysubmenu =jarray.getJSONObject(i).getJSONArray(ClassVariable.SUBMENU.SUBMENU); Log.e("JarraySubmenu","----->"+jarraysubmenu); } why this is not work for check jsonarray (SUB_MENU) condition
score: 0

http://stackoverflow.com/comment/32621120
has text: Is there a way to only trigger the event when the mouse is clicked inside the rectangle displayed in the GameMenu frame? For example, when the mouse is pressed, get the coordinates of the mouse and check if they are inside the rectangle?
comment on: http://stackoverflow.com/a/21592836
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/21629529
downvote count: 0
score: 1
type: Answer
upvote count: 1
has body: public class PersonalGreeting { public static void main(String[] args) { String first_name = ""; String last_name = ""; if (args.length &gt; 0){ first_name = args[0]; if (args.length &gt; 1) last_name = args[1]; }else{ first_name = "parameters"; last_name = "are missing"; } System.out.println("Hello " + first_name + " " + last_name); } } try to catch errors
answers question: http://stackoverflow.com/q/21629258

http://stackoverflow.com/a/21638468
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32701248
has comment: http://stackoverflow.com/comment/32703225
type: Answer
has comment: http://stackoverflow.com/comment/32701901
has comment: http://stackoverflow.com/comment/32702636
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/32701872
has comment: http://stackoverflow.com/comment/32702156
has comment: http://stackoverflow.com/comment/32702866
has comment: http://stackoverflow.com/comment/32701940
has comment: http://stackoverflow.com/comment/32701372
accepted answer of: http://stackoverflow.com/q/21638199
has comment: http://stackoverflow.com/comment/32702805
has comment: http://stackoverflow.com/comment/32703196
upvote count: 2
has body: try this code : in this method public void startElement(String uri, String localName, String qName,Attributes attributes) add this code will return the url from the element : if ("enclosure".equals(qName)) { for (int i = 0; i &lt; attributes.getLength(); i++) if (attributes.getQName(i).equals("url")) String url = attributes.getValue(i); feed me back
answers question: http://stackoverflow.com/q/21638199

http://stackoverflow.com/comment/32518730
has text: Ah, I've been using the standard command system, I just didn't here for testing purposes. I've been doing Bukkit programming for about a year now, just never had to use a config.
comment on: http://stackoverflow.com/a/21522804
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/21667931
type: AnsweredQuestion
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21668308
accepted answer: http://stackoverflow.com/a/21668308
has title: How to print out specific parts of a string
score: 0
answer count: 1
has body: This is my code and What I need help on is that I do not know how to print out only certain part of string So what this code is supposed to do is that for example input is say &amp;&amp;&amp;&amp;&amp;&amp; and 456 then the output is supposed to be*** 456 so meaning &amp;&amp;&amp;&amp;&amp;&amp; = print 6 *'s and as many numbers there are meaning length the 's go away so * -> ***456 and if input contains "," for example input is &amp;&amp;&amp;,&amp;&amp;&amp;&amp;&amp;(anywhere is fine for ",") and 10000 then output is 10,000 and so on with "." that puts decimal point where it is placed and round up to that point and "$" just puts a dollar sign in front of the numbers so my problem is the "," part for example I input 1000000000 and &amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;,&amp;&amp;&amp;&amp; then it is supposed to print out **1,000,000,000 how would I do this? So how I am going to make my code is that I make it print out last 3 of the string so it would be 000 and then put a * with a for (int... statement and I need help how to make my code to read only the last 3 letters of a string(IT IS THE SECOND IF STATEMENT(else if (X.contains(",") &amp;&amp; !X.contains(".")) THIS ONE) But I don't think a for (int... is going to work any suggestions on about this I would appreciate it Thank you! import java.util.Scanner; public class printFormatting { // all the "//"s are to see if the each step works public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Enter the &amp;'s and ,'s"); String X = in.next(); //System.out.println(X); System.out.println("Enter the numbers"); String Y = in.next(); //System.out.println(Y); int lengthX = X.length(); //System.out.println("Print out length of X"); //System.out.println(lengthX); int lengthY = Y.length(); //System.out.println("Print out length of Y"); //System.out.println(lengthY); if (X.contains(",") &amp;&amp; X.contains(".")) { lengthX -= 2; for (int z = lengthX-lengthY; z &gt; 0;) { Syste…

http://stackoverflow.com/a/21634724
downvote count: 0
answers question: http://stackoverflow.com/q/21629975
has comment: http://stackoverflow.com/comment/32728223
upvote count: 2
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/32706958
type: AcceptedAnswer
has body: You could use dexlib2 to load the dex file, remove the classes you're not interested in, and then build a new dex file int api = 19; DexFile dexFile = DexFileFactory.loadDexFile(dexFilePath, api); List&lt;ClassDef&gt; classes = new ArrayList&lt;ClassDef&gt;(); for (ClassDef classDef: dexFile.getClasses()) { if (!classDef.getType().startsWith("Landroid/support/")) { classes.add(classDef); } } dexFile = new ImmutableDexFile(classes); DexFileFactory.writeDexFile(dexFilePath, dexFile);
has comment: http://stackoverflow.com/comment/32709729
accepted answer of: http://stackoverflow.com/q/21629975

http://stackoverflow.com/comment/32769741
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21678096
type: Comment
has text: I want to add Jpanel dynamically,so I use jp.setPreferredSize(new Dimension(500, 82*mpList.size()));

http://stackoverflow.com/a/21638731
answers question: http://stackoverflow.com/q/21637563
score: 0
type: Answer
has body: You should use in EditText component in layout.xml if you use scroll, android:overScrollMode="always" android:scrollHorizontally="false" android:scrollbarAlwaysDrawVerticalTrack="true" android:scrollbarStyle="insideInset" android:scrollbars="vertical"

http://stackoverflow.com/q/21609048
tagged with: properties
type: AnsweredQuestion
tagged with: sbt
score: 1
tagged with: java
has title: Scala library initialization design
type: Question
answer count: 2
accepted answer: http://stackoverflow.com/a/21611878
possible better answer: http://stackoverflow.com/a/21611002
upvote count: 1
has answer: http://stackoverflow.com/a/21611878
has comment: http://stackoverflow.com/comment/32652155
has body: I have started an open source Scala project named omniprop. The feature I'm currently exploring is how to allow users of the project to stack JVM-styled property providers. For instance, you may wish to look up properties in java.lang.System, Lift's util.Prop, and Typesafe's Config library. Due to some other constraints/features of omniprop, I need this stack configuration to reside in a known object, so other parts of the library can retrieve properties from this stack. In order for omniprop to work correctly, this configuration needs to be invoked by the user of the library before any properties are accessed. Hence any project which uses my library will need a bootstrap/initializer which can set up the provider stack. An example of this initial configuration code looks like this: import com.joescii.omniprop.providers._ PropertyProviders.configure(List( SystemPropertyProvider, LiftPropsProvider )) The challenge I'm facing is with testing in particular. In order for the test code for a project utilizing omniprop to work, it must somehow run the above code before any tests are run. Currently, I don't see a clean way to do this with sbt or any of the testing libraries I am familiar with such as scalatest, scalacheck, or specs2. As it is, one would need to call the above snippet in every test suite, which is certainly not ideal. Another approach this this problem is what Lift does, in which every project necessarily has a class called bootstrap.liftweb.Boot that the library invokes to set everything up. I find that to be a reasonable approach to a web framework such as Lift, but seems to be too much for a tiny property helper library. I really have two questions here: How can I have sbt invoke the above setup code with the correct classloader before all tests run? More importantly, is this the best design for a library which requires initialization, or is there a better approach?
tagged with: initialization
favorite count: 0
downvote count: 0
tagged with: scala
has answer: http://stackoverflow.com/a/21611002

http://stackoverflow.com/a/26475066
has body: I think you will get a lot of value by looking at a working Tetris (although it's in Java); http://bordiani.wordpress.com/2014/10/20/tetris-in-java-part-i-overview/; For example: GUI - "I decided to not mess around too much with the graphical part, so I used the “LED” model. What I mean is that I have a 2-D array of JPanels (20/10) and by coloring them – I display the figures." MODEL - "the most basic piece in the equation is the Block class which has the int values x and y" - "The Figure class has an ArrayList of 4 Block objects. The reason for not choosing a standard array is because the blocks will be eliminated as the game progresses." - "Board is the class which actually contains all the figures that appear on the screen. It has a separate Figure field which is called FreshFigure and represents the figure that "falls down" and is controlled by the user."
score: 0
has comment: http://stackoverflow.com/comment/41588047
answers question: http://stackoverflow.com/q/21640332
type: Answer

http://stackoverflow.com/q/21631167
linked to: http://stackoverflow.com/q/7663174
possible better answer: http://stackoverflow.com/a/21631717
has comment: http://stackoverflow.com/comment/32687387
has answer: http://stackoverflow.com/a/21631288
upvote count: 3
tagged with: jvm-hotspot
has title: Java Heap Space and the RAM
has body: I have a question that bothered me after reading an article on analyzing thread dumps. There was one paragraph which mentioned that the logical maximum heap size in a 32-Bit JVM is 4GB. This link states that the maximum heap size on a 32-bit Windows machine will be around 1.4 - 1.6 GB. My question is, say if you have RAM of say around 8GB, does this mean i can only utilize 1.4-1.6 GB of it if i were to you a 32-bit JVM? And what will be the maximum size allowed for a 64bit JVM? Appreciate your help regarding this as i am confused on the same.
tagged with: jvm
favorite count: 0
tagged with: heap-memory
answer count: 4
has comment: http://stackoverflow.com/comment/32687359
has comment: http://stackoverflow.com/comment/32687347
type: AnsweredQuestion
score: 3
downvote count: 0
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21631717
has answer: http://stackoverflow.com/a/21631367
has answer: http://stackoverflow.com/a/21631769
accepted answer: http://stackoverflow.com/a/21631769

http://stackoverflow.com/comment/32746333
type: Comment
type: QuestionComment
has text: By hand? yes. Analyse the logic and try to make sense of all the a's and b's. Can we do it automated? Not really.. You'd might wanna try Java Deobfuscator (JDO). It just makes the everything a little bit more readable.
comment on: http://stackoverflow.com/q/21664430
score: 0

http://stackoverflow.com/a/48398172
upvote count: 1
has body: In recent days, I am researching the fragment. the fragment life cycle is described as following: onAttach()--onCreate()---onCreateView()--onViewCreate()--onActiviyCreate(); then I look up the source code: @CallSuper public void onAttach(Context context) { mCalled = true; final Activity hostActivity = mHost == null ? null : mHost.getActivity(); if (hostActivity != null) { mCalled = false; onAttach(hostActivity); } } @Deprecated @CallSuper public void onAttach(Activity activity) { mCalled = true; } we found the onAttach() checks if the hostActivity has existed, but it can not make sure the activity exists. onActivityCreate() is called when fragment's activity has been created, and tells the fragment that is fully associated with the new activity instance. in other words, activity has completed its own Activity.onCreate(). so I suggest you do it on onActivityCreate() method.
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21523855
score: 1

http://stackoverflow.com/comment/32722970
comment on: http://stackoverflow.com/q/21651336
type: Comment
type: QuestionComment
score: 1
has text: Gnargh, and there goes our formatting. PLEASE don't ovverride edits ;)

http://stackoverflow.com/q/21658452
has title: programmatically simulate user input from one Android application to another
score: 0
answer count: 3
accepted answer: http://stackoverflow.com/a/21658476
tagged with: android
possible better answer: http://stackoverflow.com/a/28171094
linked to: http://stackoverflow.com/q/6194025
favorite count: 0
upvote count: 1
downvote count: 1
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21658492
tagged with: java
has answer: http://stackoverflow.com/a/21658476
type: Question
has body: Is there any way to programmatically simulate user input from one android application to another ? I'd like to create android application that will be send commands to another. For example - user touch screen action.
has answer: http://stackoverflow.com/a/28171094

http://stackoverflow.com/comment/32625699
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/21595393
has text: `this.maxValues = array1;` should precede `array1 = new double[12];` to prevent unintentional data loss.
score: 0

http://stackoverflow.com/q/21537458
tagged with: jaxb
has body: I'm trying to write a Spring controller that reads an xml post request. The root element of the xml that is getting posted looks like this: &lt;booksMessage version="2.0" notificationDate="2013-10-17T00:15:00-08:00" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="books:notification:v2.0"&gt; My java class that represents that element starts out like this: @XmlRootElement(name="booksMessage", namespace="books:notification:v2.0") @XmlAccessorType(XmlAccessType.FIELD) public class BooksMessage { When I try to make that post request with Jmeter like that, the object gets translated empty, though. If I take out xmlns="books:notification:v2.0 from the message being posted, and remove namespace="books:notification:v2.0" from my java annotations, it works great. I don't have control over the message that is being posted, though, so how do I get this to work properly when the xml post contains xmlns? Is there some other annotation I have to add?
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/21540064
tagged with: rest
accepted answer: http://stackoverflow.com/a/21540064
tagged with: http://stackoverflow.com/tag/xml
has title: xmlns in xml post body causes improper deserialization by Jaxb
type: AnsweredQuestion
type: Question
tagged with: java

http://stackoverflow.com/comment/32789104
comment on: http://stackoverflow.com/q/21658231
has text: Your `Kernel32` interface has default access (which means only members of the same package can access it). Put it in its own class and make it public, or nest it within the `Battery` class.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/51506745
score: 1
type: AnswerComment
has text: You can fix this problem, by correct library management via tomcat-settings and separate Folders for shared libraries!
type: Comment
comment on: http://stackoverflow.com/a/21639535

http://stackoverflow.com/a/21545290
upvote count: 3
answers question: http://stackoverflow.com/q/21545224
downvote count: 1
accepted answer of: http://stackoverflow.com/q/21545224
score: 2
type: AcceptedAnswer
type: Answer
has comment: http://stackoverflow.com/comment/32536514
has comment: http://stackoverflow.com/comment/32536057
has comment: http://stackoverflow.com/comment/32535933
has body: Your code says that the Year will be set to fours years back from now. so it should be year 2010

http://stackoverflow.com/q/21530476
has title: Android apache Poi ArrayAdapter
accepted answer: http://stackoverflow.com/a/21530703
tagged with: android
has body: I developed an Android application (I am a beginner), but I have a problem with a ArrayAdapater. I used an Array adapter in the first part of my code and there are no errors : final ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, arrList); testSpinner.setAdapter(adapter); But on the rest of the code there is an error for the creation of the second array adapter : testSpinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int pos, long id) { String var = arrList.get(pos); if(parent.getItemAtPosition(pos).toString().equals(var)) { ArrayList&lt;String&gt; arrListA = arrList2.get(pos); ArrayAdapter&lt;String&gt; adapter2 = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, arrListA); //error testSpinner2.setAdapter(adapter2); System.out.println(var); } }}); Eclipse said for the error : " The constructor ArrayAdapter(new AdapterView.OnItemSelectedListener(){},int,Array List) is Undefined "
type: AnsweredQuestion
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/21530703
score: 0
answer count: 1

http://stackoverflow.com/q/21647403
tagged with: android
has comment: http://stackoverflow.com/comment/32716183
tagged with: android-asynctask
has comment: http://stackoverflow.com/comment/32716091
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32716119
linked to: http://stackoverflow.com/q/14235287
has comment: http://stackoverflow.com/comment/32716132
type: Question
has comment: http://stackoverflow.com/comment/32715989
has comment: http://stackoverflow.com/comment/32716159
tagged with: java
has body: I'm loading a book as image in my android app when user presses the next page key, application downloads a new image (in asynctask) and set my new image in my imageview but after 8 pages ... :| (and I'm not saving previous pages in a variable) 02-08 18:03:17.340: E/AndroidRuntime(18781): FATAL EXCEPTION: AsyncTask #3 02-08 18:03:17.340: E/AndroidRuntime(18781): java.lang.RuntimeException: An error occured while executing doInBackground() 02-08 18:03:17.340: E/AndroidRuntime(18781): at android.os.AsyncTask$3.done(AsyncTask.java:299) 02-08 18:03:17.340: E/AndroidRuntime(18781): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352) 02-08 18:03:17.340: E/AndroidRuntime(18781): at java.util.concurrent.FutureTask.setException(FutureTask.java:219) 02-08 18:03:17.340: E/AndroidRuntime(18781): at java.util.concurrent.FutureTask.run(FutureTask.java:239) 02-08 18:03:17.340: E/AndroidRuntime(18781): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 02-08 18:03:17.340: E/AndroidRuntime(18781): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 02-08 18:03:17.340: E/AndroidRuntime(18781): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 02-08 18:03:17.340: E/AndroidRuntime(18781): at java.lang.Thread.run(Thread.java:856) 02-08 18:03:17.340: E/AndroidRuntime(18781): Caused by: java.lang.OutOfMemoryError 02-08 18:03:17.340: E/AndroidRuntime(18781): at android.graphics.BitmapFactory.nativeDecodeByteArray(Native Method) 02-08 18:03:17.340: E/AndroidRuntime(18781): at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:428) 02-08 18:03:17.340: E/AndroidRuntime(18781): at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:446) 02-08 18:03:17.340: E/AndroidRuntime(18781): at com.abc.cde.ShowChapterActivity$LoadChapterPages.doInBackground(ShowChapterActivity.java:233) 02-08 18:03:17.340: E/AndroidRuntime(18781): at com.abc.cde.ShowChapterActivity$LoadChapterPag…
score: 0
has comment: http://stackoverflow.com/comment/32716025
has title: Android : application crashes while loading many images
linked to: http://stackoverflow.com/q/14359024

http://stackoverflow.com/q/21673802
has answer: http://stackoverflow.com/a/21674058
has title: java.lang.NullPointerException error
type: UnansweredQuestion
downvote count: 2
has comment: http://stackoverflow.com/comment/32762215
has comment: http://stackoverflow.com/comment/32762102
has comment: http://stackoverflow.com/comment/32761975
type: Question
score: -2
has comment: http://stackoverflow.com/comment/32762023
has answer: http://stackoverflow.com/a/21673856
tagged with: java
has comment: http://stackoverflow.com/comment/32762014
has answer: http://stackoverflow.com/a/21673943
upvote count: 0
has comment: http://stackoverflow.com/comment/32762017
has body: Given a, b and c, return true if any one of them can be formed by a mathematical operation using the other two numbers. the mathematical operations permitted are addition, subtraction, multiplication and division. For e.g if a=12, b = 15, c = 3 output is true (15-12 = 3). i tried solving the problem, though the solution works most of the time but it does not work in case of '0,0,255' or ohers similar to this. My code :- public class CheckCombination { static int testcase11 = 0; static int testcase12 = 0; static int testcase13 = 512; public static void main(String args[]){ CheckCombination testInstance = new CheckCombination(); boolean result = testInstance.combine(testcase11,testcase12,testcase13); System.out.println(result); } //write your code here public boolean combine(int a, int b,int c){ boolean checkComb1 = a==(b/c)||a==(b+c)||a==(b-c)||a==(b*c)||a==(c-b)||a==(c/b); boolean checkComb2 = b==(a/c)||b==(a+c)||b==(a-c)||b==(c*a)||b==(c-a)||b==(a+c); boolean checkComb3 = c==(a/b)||c==(b/a)||c==(a-b)||c==(b-a)||c==(a*b)||c==(a+b); boolean finalCheck = checkComb1||checkComb2||checkComb3; return finalCheck; }} what am I doing wrong and what can changes can possibly correct this problem or I am just thinking wrong?
favorite count: 0
has answer: http://stackoverflow.com/a/21674097
has comment: http://stackoverflow.com/comment/32762076
has comment: http://stackoverflow.com/comment/32761993
has comment: http://stackoverflow.com/comment/32762130
answer count: 4
has comment: http://stackoverflow.com/comment/32762022
has comment: http://stackoverflow.com/comment/32762077

http://stackoverflow.com/comment/93867160
score: 0
type: Comment
has text: @Thom: which port to use while SSHing?
comment on: http://stackoverflow.com/a/21554743
type: AnswerComment

filereader
tags question: http://stackoverflow.com/q/21535827
tags question: http://stackoverflow.com/q/21569017
tag name: filereader
tags question: http://stackoverflow.com/q/21594118
type: Tag

http://stackoverflow.com/a/21574919
type: Answer
answers question: http://stackoverflow.com/q/21574696
score: 2
upvote count: 2
has body: You have declared your list as, it can be assigned to any sub type of Super class. So, assigning a Sub type list is OK, Compiler allows to compile. But that doesn't mean, you can add a specific Object type into it. &lt;? extends Super&gt; don't means, you can add any sub type of Super. It means, You can assign any sub type collection to it.
downvote count: 0

http://stackoverflow.com/comment/32791707
type: QuestionComment
comment on: http://stackoverflow.com/q/21665300
has text: @AshotKarakhanyan More detailed than 'maybe'? If you don't know the answer you should say so or probably just not comment. You don't need the OP's motivation to post the answer, if you know it.
score: 0
type: Comment

http://stackoverflow.com/q/21574154
type: UnansweredQuestion
tagged with: xslt
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/21575151
score: 0
answer count: 1
tagged with: xsd
tagged with: jdeveloper
tagged with: http://stackoverflow.com/tag/xml
has title: XSLT using JDeveloper Checking for conditions in source
has body: I'm trying to map two XSD's in J Developer to generate a transformation(XSLT). My Problem In my source XSD i want to check for a condition lets say if idNumberType =10 then i have to map PAN Number(in source XSD) to InIdNum(In Target XSD). If idNumberType =4 then i have to map Passport number(in source XSD) to InIdNum(In Target XSD) etc. Any suggestions/comments/edits will be welcoming. Thanks in advance.

http://stackoverflow.com/comment/32666766
has text: hey....it works...there was some problem in the device....it was not able to find the path of the file
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21617048

regex
tags question: http://stackoverflow.com/q/21532497
tags question: http://stackoverflow.com/q/21587389
tags question: http://stackoverflow.com/q/21627520
tags question: http://stackoverflow.com/q/21635681
tags question: http://stackoverflow.com/q/21545933
tags question: http://stackoverflow.com/q/21593278
tags question: http://stackoverflow.com/q/21647254
tags question: http://stackoverflow.com/q/21637509
tag name: regex
tags question: http://stackoverflow.com/q/21616614
tags question: http://stackoverflow.com/q/21660260
tags question: http://stackoverflow.com/q/21575452
tags question: http://stackoverflow.com/q/21555036
tags question: http://stackoverflow.com/q/21603932
tags question: http://stackoverflow.com/q/21629910
tags question: http://stackoverflow.com/q/21609146
tags question: http://stackoverflow.com/q/21669743
tags question: http://stackoverflow.com/q/21533651
tags question: http://stackoverflow.com/q/21524642
tags question: http://stackoverflow.com/q/21614916
tags question: http://stackoverflow.com/q/21523574
tags question: http://stackoverflow.com/q/21633109
tags question: http://stackoverflow.com/q/21629802
tags question: http://stackoverflow.com/q/21625223
tags question: http://stackoverflow.com/q/21569138
tags question: http://stackoverflow.com/q/21581573
tags question: http://stackoverflow.com/q/21533078
tags question: http://stackoverflow.com/q/21566956
tags question: http://stackoverflow.com/q/21643766
tags question: http://stackoverflow.com/q/21548534
tags question: http://stackoverflow.com/q/21675643
tags question: http://stackoverflow.com/q/21535811
tags question: http://stackoverflow.com/q/21601211
tags question: http://stackoverflow.com/q/21672061
tags question: http://stackoverflow.com/q/21563827
tags question: http://stackoverflow.com/q/21664585
tags question: http://stackoverflow.com/q/21577308
tags question: http://stackoverflow.com/q/21584216
tags question: http://stackoverflow.com/q/21676277
tags question: http://stackoverflow.com/q/21593718
tags question: http://stackoverflow.com/q/21576040
tags question: http://stackoverflow.com/q/21558677
tags question: http://stackoverflow.com/q/21604342
tags question: http://stackoverflow.com/q/21662444
tags question: http://stackoverflow.com/q/21528921
tags question: http://stackoverflow.com/q/21627544
tags question: http://stackoverflow.com/q/21628272
tags question: http://stackoverflow.com/q/21634739
tags question: http://stackoverflow.com/q/21518892
tags question: http://stackoverflow.com/q/21606246
tags question: http://stackoverflow.com/q/21643952
tags question: http://stackoverflow.com/q/21573636
tags question: http://stackoverflow.com/q/21524494
tags question: http://stackoverflow.com/q/21620183
tags question: http://stackoverflow.com/q/21599991
tags question: http://stackoverflow.com/q/21592979
tags question: http://stackoverflow.com/q/21653454
tags question: http://stackoverflow.com/q/21608029
tags question: http://stackoverflow.com/q/21515013
tags question: http://stackoverflow.com/q/21641003
tags question: http://stackoverflow.com/q/21627866
tags question: http://stackoverflow.com/q/21566679
tags question: http://stackoverflow.com/q/21565104
tags question: http://stackoverflow.com/q/21583474
tags question: http://stackoverflow.com/q/21673270
tags question: http://stackoverflow.com/q/21642157
tags question: http://stackoverflow.com/q/21628028
tags question: http://stackoverflow.com/q/21536621
tags question: http://stackoverflow.com/q/21641180
tags question: http://stackoverflow.com/q/21620329
tags question: http://stackoverflow.com/q/21677710
tags question: http://stackoverflow.com/q/21523551
tags question: http://stackoverflow.com/q/21586612
tags question: http://stackoverflow.com/q/21645155
tags question: http://stackoverflow.com/q/21607152
tags question: http://stackoverflow.com/q/21533702
tags question: http://stackoverflow.com/q/21595431
tags question: http://stackoverflow.com/q/21563891
tags question: http://stackoverflow.com/q/21636205
type: Tag

http://stackoverflow.com/a/21564430
has body: You are adding numbers to the list once, instead of looking for the unique numbers. That is the difference. (BTW: The reason why 0.0 is not in the output is because the array is full of zeros by default.) Basically you should have this: Read all the numbers in an array. Run over every number in that list, and check if it is unique. If so, add it to the final array. Checking wether an element is unique can simply be done by counting the occurrences of that element in the entire list by looping over it again.
type: Answer
upvote count: 2
accepted answer of: http://stackoverflow.com/q/21564331
score: 2
answers question: http://stackoverflow.com/q/21564331
has comment: http://stackoverflow.com/comment/32570591
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32570531
has comment: http://stackoverflow.com/comment/32570485

http://stackoverflow.com/q/21600626
tagged with: sqlite
answer count: 1
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/32634524
favorite count: 0
has body: I have developed an Android database application. The problem is that when I click the add button then a message shows that data was successfully added. But the data is not inserted into the database. I then open the database with SQLite viewer and there I can't find any of the data I inserted... Register page code : package com.example.dbapp; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; public class Register extends Activity { Button add; TextView b,c; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.register); add = (Button) findViewById(R.id.btnReg); b = (TextView) findViewById(R.id.etName); c = (TextView) findViewById(R.id.etOccu); add.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub try { String name = b.getText().toString(); String occ = c.getText().toString(); DataCon entry = new DataCon(Register.this); entry.open(); entry.createEntry(name, occ); entry.close(); Toast toast = Toast.makeText(getApplicationContext(), "Sucess", Toast.LENGTH_SHORT); toast.show(); } catch(Exception e) { String err = e.toString(); Toast toast = Toast.makeText(getApplicationContext(), err, Toast.LENGTH_SHORT); toast.show(); } } }); } Database Connection code : package com.example.dbapp; import android.content.ContentValues; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase.CursorFactory; import android.database.sqlite.SQLiteOpenHelper; public class DataCon { public static final String rowid = "_id"; public static final String name = "persons_name"; public static final String hot = "persons_hotness"; private static final String DB_NAME = "myDB"; private static final String DB_TABLE = "tbl_me"; private stati…
has answer: http://stackoverflow.com/a/21601022
has comment: http://stackoverflow.com/comment/32634550
tagged with: android
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32634257
upvote count: 1
type: Question
accepted answer: http://stackoverflow.com/a/21601022
tagged with: java
tagged with: database
has title: Data not inserted into SQLite database on android?

http://stackoverflow.com/q/21651990
has comment: http://stackoverflow.com/comment/32724159
has answer: http://stackoverflow.com/a/21652149
has comment: http://stackoverflow.com/comment/32724316
has comment: http://stackoverflow.com/comment/32724175
tagged with: inputstreamreader
tagged with: bufferedreader
downvote count: 5
has title: Java Input from console giving unexpected values
has body: In the given code, Input: 1 7 Output: 1 Output should be 7. What am I missing?? import java.io.*; import java.util.*; class compiler { public static void main(String args[] ) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int testcases = Integer.parseInt(br.readLine()); // System.out.println("If this statement is added it works as expected!") int n=Integer.parseInt(br.readLine()); System.out.println(n); } } *I also tried using scanner
has comment: http://stackoverflow.com/comment/32724315
answer count: 3
upvote count: 0
has answer: http://stackoverflow.com/a/21652050
accepted answer: http://stackoverflow.com/a/21652149
favorite count: 0
tagged with: java.util.scanner
tagged with: stdin
type: AnsweredQuestion
score: -5
possible better answer: http://stackoverflow.com/a/21652078
tagged with: java
has answer: http://stackoverflow.com/a/21652078
has comment: http://stackoverflow.com/comment/32724253
type: Question

http://stackoverflow.com/q/21656739
has title: IOException : spring-xml not found
tagged with: exception
has comment: http://stackoverflow.com/comment/32732775
has answer: http://stackoverflow.com/a/21657031
tagged with: spring
tagged with: netbeans
has body: I am new to Spring and writing my first code. I am getting following error while running code: Feb 09, 2014 1:21:23 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@64964f8e: startup date [Sun Feb 09 13:21:23 IST 2014]; root of context hierarchy Feb 09, 2014 1:21:23 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from class path resource [spring.xml] Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring.xml] cannot be opened because it does not exist I tried few combinations of moving spring.xml to different locations, same issue i found. Here is the ss of my folder structure:
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/7598623
has comment: http://stackoverflow.com/comment/32732645
has answer: http://stackoverflow.com/a/21656787
has comment: http://stackoverflow.com/comment/32732524
type: Question
tagged with: java
has comment: http://stackoverflow.com/comment/32732828
score: 0
answer count: 2

http://stackoverflow.com/comment/32495007
score: 0
type: AnswerComment
has text: How do I loop through the objects? I tried while (is.read()!=-1) but got a java.lang.ClassCastException. Thank you.
type: Comment
comment on: http://stackoverflow.com/a/21520393

http://stackoverflow.com/q/21534388
has title: Starting to learn java,program doesn't work as expected
has answer: http://stackoverflow.com/a/21534444
has body: I am learning java at the moment and I was trying to make a simple program that recieves a username and gives you an opurtunity to change that username...However,the program is always doing the same thing: It doesn't give me a chance to change my username.I am sure that the problem is in the function I made: public String change (String Accname) { String chg; System.out.println("Are you satisfied with this username: "+Accname+"?"); chg=in.nextLine(); if(chg=="yes"||chg=="Yes") { return Accname; } else if(chg=="no"||chg=="No") { System.out.println("What would you want your username to be?"); Accname=in.nextLine(); } return Accname; } I wrote this line at the main function: name.change(username); (of course,it's not the full code,I gave you the important line). After this line my program gives me the username without an opurtunity to change my username.It's like the program ignores the change function. This problem also happend a while ago in c while i was trying to make a simple program that switches between two numbers.At the end,nothing happens. If someone could help me,I would really appreciate it!
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32517402
tagged with: java
type: Question
duplicate of: http://stackoverflow.com/q/513832
score: 0
linked to: http://stackoverflow.com/q/513832
answer count: 1

http://stackoverflow.com/comment/32893393
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21659980
has text: No problem. Tell me if it works :)
score: 0

http://stackoverflow.com/a/21568086
type: Answer
has body: From the Javadoc for PrintWriter: Unlike the PrintStream class, if automatic flushing is enabled it will be done only when one of the println, printf, or format methods is invoked, rather than whenever a newline character happens to be output. These methods use the platform's own notion of line separator rather than the newline character. If you're using .print() you have to manually .flush(). Simply having \n or \r\n in your String does not do so which is what is causing the different behavior you see.
accepted answer of: http://stackoverflow.com/q/21568028
answers question: http://stackoverflow.com/q/21568028
downvote count: 0
has comment: http://stackoverflow.com/comment/32577628
score: 1
type: AcceptedAnswer
upvote count: 1

http://stackoverflow.com/q/21588107
tagged with: google-app-engine
accepted answer: http://stackoverflow.com/a/21595278
type: AnsweredQuestion
tagged with: java
has title: Datanucleus JDO map String to MySQL-type bigint in App Engine
tagged with: jdo
type: Question
tagged with: datanucleus
answer count: 1
tagged with: google-cloud-sql
score: 0
has answer: http://stackoverflow.com/a/21595278
has body: I am trying to access Datastore and Cloud SQL from my App Engine application via JDO. If I set primary key type as long, everything works well with Cloud SQL but Datastore doesn't work and if I set up primary key as String and want to convert it to JDBC-Type "Bigint" I get following error when trying to access Cloud SQL: javax.jdo.JDOUserException: Exception thrown while loading remaining rows of query at org.datanucleus.api.jdo.JDOAdapter.getUserExceptionForException(JDOAdapter.java:1085) at org.datanucleus.store.rdbms.query.ForwardQueryResult.closingConnection(ForwardQueryResult.java:273) at org.datanucleus.store.query.AbstractQueryResult.disconnect(AbstractQueryResult.java:108) at org.datanucleus.store.rdbms.query.AbstractRDBMSQueryResult.disconnect(AbstractRDBMSQueryResult.java:69) at org.datanucleus.store.rdbms.query.JDOQLQuery$2.transactionPreClose(JDOQLQuery.java:698) at org.datanucleus.store.connection.AbstractManagedConnection.transactionPreClose(AbstractManagedConnection.java:92) at org.datanucleus.store.connection.ConnectionManagerImpl$2.transactionPreRollBack(ConnectionManagerImpl.java:333) at org.datanucleus.TransactionImpl.internalPreRollback(TransactionImpl.java:523) at org.datanucleus.TransactionImpl.rollback(TransactionImpl.java:446) at org.datanucleus.api.jdo.JDOTransaction.rollback(JDOTransaction.java:180) at de.studienarbeit3.dokumente.DokumentListServlet.doPost(DokumentListServlet.java:82) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166) at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFil…

http://stackoverflow.com/comment/32729895
has text: even simpler, `Color c = (i % 2 == j % 2) ? DARK_COLOR : LIGHT_COLOR;`
score: 0
comment on: http://stackoverflow.com/a/21655120
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32665531
score: 0
has text: I did set them when I generated them, the name corresponds to the column number, which it turn ties it to an active player in my program.
type: Comment
comment on: http://stackoverflow.com/a/21618104
type: AnswerComment

http://stackoverflow.com/q/21526200
has comment: http://stackoverflow.com/comment/32502193
downvote count: 5
score: -3
tagged with: unicode
favorite count: 0
upvote count: 2
type: UnansweredQuestion
has body: I have always wanted to use greek variables. I've tried both Chinese and Greek. I have tried in emacs and Eclipse. Saved in utf-8. Nothing works. public class I18NTest { private static double π = 3.14159265358979； public static void main(String args[]) { System.out.println(π); } } There is a compiler error on the line with the pi.
has title: Java supposedly works with international variables. Why can't I make it work?
tagged with: internationalization
has answer: http://stackoverflow.com/a/21526302
has comment: http://stackoverflow.com/comment/32502290
tagged with: java
has comment: http://stackoverflow.com/comment/32708895
has answer: http://stackoverflow.com/a/21526292
type: Question
answer count: 2

http://stackoverflow.com/a/21592394
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21592269
accepted answer of: http://stackoverflow.com/q/21592269
has comment: http://stackoverflow.com/comment/32650668
score: 1
upvote count: 1
has body: According to the docs, you set port as an application argument not a system property: http://www.eclipse.org/jetty/documentation/current/quickstart-running-jetty.html java -jar start.jar jetty.port=9000

http://stackoverflow.com/comment/32607032
type: Comment
has text: well, i hope that the person who ask it want to know as much as he can. he don't have to use it. i am always keeping my {} in the codes but i know that i can drop them. well, you are right, it is just for knowladge :)
comment on: http://stackoverflow.com/a/21559781
score: 0
type: AnswerComment

http://stackoverflow.com/a/21633470
upvote count: 4
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21633384
has body: You can use a TreeMap which has a built-in method for that: TreeMap&lt;DateTime, BigDecimal&gt; map = new TreeMap&lt;&gt;(); //populate the map BigDecimal findNextSmaller(DateTime input) { return map.ceilingEntry(input).getValue(); //add exception checking as required } Note: you may want ceilingEntry or higherEntry depending on whether you want (resp.) &gt;= or &gt;.
accepted answer of: http://stackoverflow.com/q/21633384
score: 4

http://stackoverflow.com/q/21518148
tagged with: java
has body: I am looking for a simple way to extract set of numbers from a string in Java. For instance: String temp = "120.6 + 220.4"; I want to extract "220.4" from the string and assing it to a double variable. Can anyone help me with a simple solution for this?
has answer: http://stackoverflow.com/a/21518219
has answer: http://stackoverflow.com/a/21518182
accepted answer: http://stackoverflow.com/a/21518182
answer count: 3
downvote count: 3
has title: extracting specific set of number from a string in Java
linked to: http://stackoverflow.com/q/15894729
has answer: http://stackoverflow.com/a/21518159
favorite count: 0
linked to: http://stackoverflow.com/q/2367381
type: AnsweredQuestion
upvote count: 0
has comment: http://stackoverflow.com/comment/32515385
has comment: http://stackoverflow.com/comment/32488657
score: -3
has comment: http://stackoverflow.com/comment/32488674
possible better answer: http://stackoverflow.com/a/21518159
has comment: http://stackoverflow.com/comment/32488656
type: Question

http://stackoverflow.com/a/21661684
score: 0
answers question: http://stackoverflow.com/q/21661611
has comment: http://stackoverflow.com/comment/32741410
type: Answer
has comment: http://stackoverflow.com/comment/32741333
has body: There are a few problems here. First, since you never decrease oddCount and evenCount, the condition oddCount&gt;=0&amp;&amp;evenCount&gt;=0 will always be true. Second, you have an empty loop that loops endlessly, since it's condition is true and it has no body: while (temp&gt;0); I'd just take out the first loop, which is redundant, and use a do while loop: int oddCount = 0; int evenCount = 0; Scanner in = new Scanner(System.in); do { System.out.print("Enter an integer: "); int temp = in.nextInt(); if (temp &gt; 0) { if (temp % 2==0) { evenCount++; } else { oddCount++; } } } while (temp &gt; 0); System.out.println("Number of even integers: " + evenCount); System.out.println("Number of odd integers: " + oddCount);

http://stackoverflow.com/a/21528044
has body: Edit: The original answer is no longer valid, as the linked tutorial does not exist anymore and LibGDX has changed quite a bit since then. There is now an official documentation on how to setup the environment. Note, that Android Studio or IntelliJ is recommended, as it is the only IDE to officially support Android. I am posting it as an answer that you can mark it as solved and it can help others in future. If you are using Eclipse the setup in this tutorial should help you. If you are using intellij you can load the project in eclipse do this setup and then import it to intellij. I am sure that you can do the things also in intellij without eclipse but i don't know intellij so i can't help you with this.
has comment: http://stackoverflow.com/comment/93970818
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/93971213
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21524776
upvote count: 1
accepted answer of: http://stackoverflow.com/q/21524776

calendar
tags question: http://stackoverflow.com/q/21666357
tags question: http://stackoverflow.com/q/21665862
tags question: http://stackoverflow.com/q/21545224
tags question: http://stackoverflow.com/q/21523357
tags question: http://stackoverflow.com/q/21621735
tags question: http://stackoverflow.com/q/21568329
tag name: calendar
tags question: http://stackoverflow.com/q/21667616
tags question: http://stackoverflow.com/q/21563067
tags question: http://stackoverflow.com/q/21595438
tags question: http://stackoverflow.com/q/21531858
tags question: http://stackoverflow.com/q/21523935
tags question: http://stackoverflow.com/q/21575488
type: Tag
tags question: http://stackoverflow.com/q/21585892
tags question: http://stackoverflow.com/q/21606934

http://stackoverflow.com/a/21619719
score: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32709860
has body: If I understand your question properly, recipients must be case-insensitive, and they are to be used as keys in a HashMap. Why not just use the toLowerCase function on String, and use that version of the recipient as the key? That way, "PAUL", "Paul", and "paul" all get turned into "paul" for purposes of lookup. You'd apply this by lowercasing the name input at the beginning of any function that uses it.
type: Answer
accepted answer of: http://stackoverflow.com/q/21619657
answers question: http://stackoverflow.com/q/21619657
has comment: http://stackoverflow.com/comment/32709930
has comment: http://stackoverflow.com/comment/32710569
has comment: http://stackoverflow.com/comment/32709851

http://stackoverflow.com/q/21672673
answer count: 2
has body: I'm using Weka and have saved a model and I want to use the model to do some predictions. However, I have to use C++ for my GUI so every time I call the .jar file, I gonna re-read the model and this wastes a lot of time. How can I store the model in memory and directly use it from Java? Or are there any better ways to do this?
tagged with: shared-memory
has title: How to store a file in memory and directly use it in Java?
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21672865
tagged with: java
type: Question
tagged with: performance
has answer: http://stackoverflow.com/a/21673106
score: 0

http://stackoverflow.com/a/21588604
downvote count: 0
answers question: http://stackoverflow.com/q/21572656
has body: You need to start a JTA transaction before invoking JPA: use @Resource UserTransaction userTran, and then use userTran.begin()/userTran.commit() around the calls to JPA.
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/a/21546989
has body: NullPointerException can only be thrown if your array is null. Check in the code that is calling the method. Other notes to improve your code: you do not need a new array to store values. You can do it in existing array itself. your inner for loop must be from 1 to the length of current row not the length of the array so it should be something like: for(int i=1;i&lt;array[row].length;i++) And use index i instead of i+1 in loop content.
type: Answer
score: 0
answers question: http://stackoverflow.com/q/21546645

http://stackoverflow.com/a/21677501
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32769042
has body: Where ever you getting the error in xml file. 1) Just delete that whole id and rename it again with new id name. 2) I can see you are also getting errors while setting styles and background resources. just delete and define it again in your xml file and clean your project. I hope this resolves your problem.....
type: Answer
score: 1
upvote count: 1
accepted answer of: http://stackoverflow.com/q/21676957
has comment: http://stackoverflow.com/comment/32769507
answers question: http://stackoverflow.com/q/21676957

http://stackoverflow.com/q/21668382
favorite count: 0
tagged with: file-io
type: Question
has title: NetBeans FileChooser. How do I use it to copy a file from one location to another defined in a string?
has answer: http://stackoverflow.com/a/21668614
tagged with: file
upvote count: 1
tagged with: swing
answer count: 1
tagged with: java
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32753168
downvote count: 0
score: 1
has body: I know how to perform simple operations with FileChooser within netbeans but when it comes to more complex ones, I'm getting a little stuck. So far I'm able to make use of a picture attained from the user's file system on the JFrame as below: But I don't know how to use it to copy a file from one location to another defined in a string? code: private void ImageAtattchActionPerformed(java.awt.event.ActionEvent evt) { int o = jFileChooser1.showOpenDialog(this); if (o == JFileChooser.APPROVE_OPTION) { File f = jFileChooser1.getSelectedFile(); jLabel1.setIcon(new ImageIcon("" + f)); }

identifier
tag name: identifier
type: Tag
tags question: http://stackoverflow.com/q/21667890

http://stackoverflow.com/q/21550916
tagged with: swing
linked to: http://stackoverflow.com/q/19209650
has body: I made a image lists like this in java: static String[] imageList1 = { "images/bgs/bg.png", "images/bgs/image1.png", "images/bgs/image2.png", "images/bgs/image3.png" }; I use the image in the image list as a background like this: JLabel background = new JLabel(new ImageIcon(imageList1[0])); The problem is when I run the program the whole frame was blank(supposedly the frame consists from only one picture image and one button) but if I minimize and then maximize or adjust the width or height of the frame, it suddenly shows the image and the button.
type: Question
has comment: http://stackoverflow.com/comment/32576155
score: 0
has comment: http://stackoverflow.com/comment/32545755
answer count: 1
tagged with: imageicon
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21551615
has title: imageIcon/image load in frame?
tagged with: java
has comment: http://stackoverflow.com/comment/32546412

http://stackoverflow.com/comment/32599588
type: AnswerComment
type: Comment
has text: @PeterLawrey That's what I'm saying, you won't have a E[] because it's an Object[], if you create a instance where the generic type is String and you do this: `return (E[]) new Object[0]` you'll cause an exception because Object[] cannot be cast to String[]. Again, did you try the test case?
comment on: http://stackoverflow.com/a/21577494
score: 0

http://stackoverflow.com/comment/32767650
type: Comment
type: QuestionComment
has text: @MehulRanpara edited vinayManeti I've tried to clean the project and 'Build Automatically' is checked but it doesn't solve my problem
comment on: http://stackoverflow.com/q/21676957
score: 0

http://stackoverflow.com/q/21673881
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/32762187
has body: Thread class is said to have a "IS-a" relation as well as "Has-a" relation with the runnable interface. What is the benefit of having both of these? Why do we give priority to "Has-a" relation?
type: UnansweredQuestion
tagged with: multithreading
has answer: http://stackoverflow.com/a/21673962
has title: questions regarding multi threading
downvote count: 0
score: 1
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32762097
upvote count: 1
has comment: http://stackoverflow.com/comment/32762484

http://stackoverflow.com/comment/32711804
has text: @AbhinavKumar : Indeed but as a beginner, I did not know this prior to this post. Thanks.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21644269

http://stackoverflow.com/comment/74360673
type: Comment
score: 2
comment on: http://stackoverflow.com/a/21793358
type: AnswerComment
has text: http://web.archive.org/web/20150109223825/http://www.sevenarmedsquid.com/help/robovmbinding

http://stackoverflow.com/q/21617573
downvote count: 2
has title: Can you go back to a specific line in your code?
has comment: http://stackoverflow.com/comment/32665164
has answer: http://stackoverflow.com/a/21618115
tagged with: java
has answer: http://stackoverflow.com/a/21618048
type: Question
score: -1
answer count: 3
has body: I'm trying to make an index basically and if someone messes up I want them to be able to return to the last menu or the last selection screen, or just restart. Is this possible? I'm using JCreator. It's my first program so I've kept it very simple; it's just a bunch of if-else statements. Looks a little something like this. edit: Would it be easier if I made a restart button in the program interface or whatever you would call it? public class Index { public static void main(String[] args) { Scanner key = new Scanner(System.in); System.out.println("What kind of sandwich are you looking for?"); System.out.println("1. Ham 2. Turkey 3. etc."); int meat = key.nextInt(); if (meat == 1) { System.out.println("What type of cheese would you like"?); System.out.println("1. Swiss 2. Cheddar 3. etc."); int cheese = key.nextInt(); if (cheese == 1) { System.out.println("Would you like lettuce and/or tomatoes?"); System.out.println("1. Just lettuce 2. Just tomatoes 3. Both 4. Neither"); int lOrT = key.nextInt(); } } if (meat == 2) { System.out.println("What type of cheese would you like"?); System.out.println("1. Swiss 2. Cheddar 3. etc."); int cheese = key.nextInt(); if (cheese == 1) { System.out.println("Would you like lettuce and/or tomatoes?"); System.out.println("1. Just lettuce 2. Just tomatoes 3. Both 4. Neither"); int lOrT = key.nextInt(); } } } }
has answer: http://stackoverflow.com/a/21618859
upvote count: 1
favorite count: 0
tagged with: return
type: UnansweredQuestion

mapping
tags question: http://stackoverflow.com/q/21654358
tags question: http://stackoverflow.com/q/21563011
tag name: mapping
tags question: http://stackoverflow.com/q/21631122
tags question: http://stackoverflow.com/q/21639755
tags question: http://stackoverflow.com/q/21674170
type: Tag
tags question: http://stackoverflow.com/q/21605070

http://stackoverflow.com/a/21551166
has body: You break out from the inner case, not from the outer. You have to put a break to the outer case also.
answers question: http://stackoverflow.com/q/21551106
score: 0
type: Answer

http://stackoverflow.com/comment/32761109
has text: Just googled "java rename" and got this http://stackoverflow.com/questions/1158777/renaming-a-file-using-java Please search before asking.
comment on: http://stackoverflow.com/q/21673265
score: 0
type: Comment
type: QuestionComment

jax-rs
tags question: http://stackoverflow.com/q/21556961
tags question: http://stackoverflow.com/q/21576502
tags question: http://stackoverflow.com/q/21628983
tags question: http://stackoverflow.com/q/21534965
tags question: http://stackoverflow.com/q/21632491
tags question: http://stackoverflow.com/q/21665693
type: Tag
tags question: http://stackoverflow.com/q/21547157
tags question: http://stackoverflow.com/q/21636186
tag name: jax-rs
tags question: http://stackoverflow.com/q/21568983

http://stackoverflow.com/comment/32620087
has text: Thanks a lot. I think this got it working. I'll have to fully test it later
type: Comment
comment on: http://stackoverflow.com/a/21591295
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32646080
has text: I checked getenv for other thread (from which on_log(..) was called)and it is working properly.. so vm should be correct.. You are not returning any int in onload.. m returning JNI version 2.. and thus in attach call I cannot use NULL according to invocation api docs
comment on: http://stackoverflow.com/a/21605241
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32632453
comment on: http://stackoverflow.com/q/21599450
has text: Tried to google it yet? Here's a link: http://stackoverflow.com/questions/261683/what-is-meant-by-thread-safe-code
score: 1
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32583874
type: AnswerComment
has text: @user838204 You can find much of the documents about disruptor here http://stackoverflow.com/questions/6933347/how-should-one-use-disruptor-disruptor-pattern-to-build-real-world-message-sys OR http://mechanitis.blogspot.sg/2011/08/dissecting-disruptor-why-its-so-fast.html
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21570297

http://stackoverflow.com/q/21594229
upvote count: 1
has body: Below is the code I am working with. I just need to store the input in an array and Im pretty lost! package Code.simpleInput; import edu.cmu.ri.createlab.terk.robot.finch.Finch; import java.util.Scanner; public class LEDSetter { private static Scanner sc; public static void main(final String[] args) { // Instantiating the Finch object Finch myFinch = new Finch(); sc = new Scanner(System.in); // Providing instructions to the user System.out.println("Enter the red, green, and blue intensity for the LED (values from 0 to 255)"); // Reading in the three integers System.out.print("Red: &lt;=200 "); int red = sc.nextInt(); System.out.print("Green: &lt;=250 "); int green = sc.nextInt(); System.out.print("Blue: &lt;=250 "); int blue = sc.nextInt(); /* Potential improvement here - check the user input to make sure that it is in range (0-255) */ // Setting the LED System.out.println("Thanks, the beak will now glow for 8 seconds according to your specifications"); myFinch.setLED(red,green,blue); myFinch.sleep(8000); // Always end your program with finch.quit() myFinch.quit(); System.exit(0); } }
type: Question
has answer: http://stackoverflow.com/a/21594303
has answer: http://stackoverflow.com/a/21594321
has answer: http://stackoverflow.com/a/21594382
has title: I am new to programming and need to store the below input in one array. Any suggestions?
has answer: http://stackoverflow.com/a/21594599
has answer: http://stackoverflow.com/a/21594367
has answer: http://stackoverflow.com/a/21594320
downvote count: 0
answer count: 7
score: 1
favorite count: 0
has answer: http://stackoverflow.com/a/21594298
accepted answer: http://stackoverflow.com/a/21594321
possible better answer: http://stackoverflow.com/a/21594298
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32623754
tagged with: java

http://stackoverflow.com/comment/32692445
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21633819
has text: How are you building your webservices? I use JAX-WS and it figures out the correct endpoint in the WSDL automatically.
score: 0

http://stackoverflow.com/q/21642170
has comment: http://stackoverflow.com/comment/32707383
possible better answer: http://stackoverflow.com/a/21642218
has title: Java: How do i get the int that i need??? by using something to split them?
tagged with: int
has answer: http://stackoverflow.com/a/21642289
upvote count: 1
has answer: http://stackoverflow.com/a/21642201
has comment: http://stackoverflow.com/comment/32707370
tagged with: string
favorite count: 0
has answer: http://stackoverflow.com/a/21642393
accepted answer: http://stackoverflow.com/a/21642393
tagged with: shapes
has comment: http://stackoverflow.com/comment/32707471
answer count: 4
has answer: http://stackoverflow.com/a/21642218
has body: int x1; int y1; int x2; int y2; String shape = " sequenceNumber &lt;Square&gt; 50 60 70 90 &lt;/Square&gt; " public splitThem(String s){ //I can't figure out how to extract the information i need... //... Do sometthing to extract splitThem(shape) int this.x1 = parseString("50"); int this.y1 = parseString("60"); int this.x2 = parseString("70"); int this.y2 = parseString("90"); } public void Graphics(graphic g){ g.drawRect(x1,y1,x2,y2); } I'm wondering if theres a way to extract the information that i need and parseString them to integer??? something like split method??
downvote count: 0
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32707356
type: Question
type: AnsweredQuestion
tagged with: split
has comment: http://stackoverflow.com/comment/32708060
has comment: http://stackoverflow.com/comment/32707414
has comment: http://stackoverflow.com/comment/32707395

http://stackoverflow.com/q/21544349
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21544390
type: Question
tagged with: java
has comment: http://stackoverflow.com/comment/32534556
has body: I'm having trouble multiplying the elements of a 2d string array by the element of another. Heres the code: public static String updateString(String[][] array, String[] prices) { String [][] newArray = new String[array.length][]; for(int row = 0; row &lt; prices.length; row++) { if (array[row][0].equals(prices[row])) { for(int i = 0; row &lt;array.length; row++) { newArray[row][i+1] = array[row][i+1] * prices[i+1]; } } } } Here are what the files look like: array: Omaha,104,1218,418,216,438,618,274,234,510,538,740,540 Saint Louis,72,1006,392,686,626,670,204,286,236,344,394,930 Des Moines,116,1226,476,330,444,464,366,230,602,260,518,692 Chicago,408,948,80,472,626,290,372,282,488,456,376,580 Kansas City,308,1210,450,234,616,414,500,330,486,214,638,586 Austin,500,812,226,470,388,488,512,254,210,388,738,686 Houston,454,1086,430,616,356,534,218,420,494,382,476,846 New Orleans,304,1278,352,598,288,228,532,418,314,496,616,882 prices array: Omaha,7.5 Saint Louis,10.5 Des Moines,8.5 Chicago,11.5 Kansas City,12.5 Austin,10.75 Houston,12.5 New Orleans,9.25 As you can see, the first column of each array lists the city, so if the cities match up, I need the 1st array's elements multiplied by omaha(7.5).
score: 0
has answer: http://stackoverflow.com/a/21544577
tagged with: arrays
has title: Method to multiply elements of 2d array by element of another 2d array JAVA
has answer: http://stackoverflow.com/a/21544660
accepted answer: http://stackoverflow.com/a/21544577
possible better answer: http://stackoverflow.com/a/21544430
linked to: http://stackoverflow.com/q/7469316
has answer: http://stackoverflow.com/a/21544430

http://stackoverflow.com/comment/32625066
has text: You can use static variable to pass data between class..
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/21595078
type: Comment

http://stackoverflow.com/comment/32535310
comment on: http://stackoverflow.com/a/21544602
has text: OP should note that 2g is the size of memory, change based on what you want to do.
score: 1
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32726402
comment on: http://stackoverflow.com/q/21653184
type: Comment
type: QuestionComment
has text: How are you running this? What IDE are you using? I imagine that you will need to change your IDE settings so that it does not print out this kind of information.
score: 1

http://stackoverflow.com/comment/32691486
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21633060
has text: You should if resources are html pages and are outside of WEB-INF
score: 0

http://stackoverflow.com/comment/32584758
score: 0
comment on: http://stackoverflow.com/q/21572407
has text: You can extend [`PlainDocument`](http://docs.oracle.com/javase/7/docs/api/javax/swing/text/PlainDocument.html) for that.
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21671084
upvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/21671051
downvote count: 0
score: 2
has body: Your Scanner is called inputFile2 not inputFile.

http://stackoverflow.com/q/21596096
tagged with: android
has answer: http://stackoverflow.com/a/21596266
upvote count: 3
type: UnansweredQuestion
type: Question
score: 3
tagged with: java
has body: i have a date and time picker in my app and I've just noticed that the time is wrong. the current time that the time picker displays is i hour delay and its am/pm is wrong like for example the current time is 2:55 pm it will show 1:55 am what seems to be the problem here is the code UPDATE:DATE AND TIME PICKER @Override public void onClick(View v) { if (v == btnCalendar) { // Process to get Current Date final Calendar c = Calendar.getInstance(); mYear = c.get(Calendar.YEAR); mMonth = c.get(Calendar.MONTH); mDay = c.get(Calendar.DATE)+1; // Launch Date Picker Dialog DatePickerDialog dpd = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { // Display Selected date in textbox txtDate.setText(dayOfMonth + "-" + (monthOfYear + 1) + "-" + year); } }, mYear, mMonth, mDay); dpd.show(); } if (v == btnTimePicker) { // Process to get Current Time final Calendar c = Calendar.getInstance(); mHour = c.get(Calendar.HOUR)+1; mMinute = c.get(Calendar.MINUTE); // Launch Time Picker Dialog TimePickerDialog tpd = new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { // Display Selected time in textbox txtTime.setText(hourOfDay + ":" + minute); } }, mHour, mMinute, false); tpd.show(); } } } UPDATE: what i did is to put +1 in mHour = c.get(Calendar.HOUR_OF_DAY)+1; there might be a set back on this method any ideas? unfixed is the AM/PM button is wrong it always shows am at start UPDATE:AM/PM doesn't start with am at all is wrong because now that its morning it show pm but during pm it show am UPDATE: there is also a problem in date.what i did is to put +1 in mDay = c.get(Calendar.DATE)+1; there might be a set back on this method any ideas?
has title: time picker ontimeset is wrong
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/21596536
favorite count: 0
tagged with: timepicker
tagged with: time

http://stackoverflow.com/comment/33391252
type: AnswerComment
has text: Or in short: Depends on how much more integration you are doing. If this is all, I'd not bother with Camel. If there's more, Camel may well be a very interesting option.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22025747

http://stackoverflow.com/q/21559141
linked to: http://stackoverflow.com/q/5539176
has title: Accesing request attribute in jsp not having direct access to request
tagged with: jsp
has body: I am using struts 1.2.In an action class I am getting result which i put in request as an attribute.i.e request.setAttribute("contarctNumber","123BB4"). Now the thing is that i am getting redirected to multiple other pages after setting this attribute which ultimately redirect to a JSP.I want to show this request attribute on this jsp but this does not have access to request object/attribute.How can i access this request attribute in my JSP?
type: UnansweredQuestion
tagged with: struts
has answer: http://stackoverflow.com/a/21559435
type: Question
answer count: 1
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/32560562

http://stackoverflow.com/comment/32688525
comment on: http://stackoverflow.com/a/21631736
type: Comment
has text: yes so that it will be easy for the calculation thats it and thus i can get the days
score: 0
type: AnswerComment

http://stackoverflow.com/a/21565230
score: 1
upvote count: 1
has body: You're not doing anything with your variables. Just calling them and then they're moving out of scope. You could either store the returned value in a global variable to use later. private double quarter, dime, total; public static void main(String[] args) { quarter = quarterDollarAmount(); dime = dimeDollarAmount(); total = (quarter + dime); s.o.p(total); } If you don't care about the value after printing it out you can either total them up with local variables or literally just total up your methods as follows. public static void main(String[] args) { s.o.p(quarterDollarAmount( ) + dimeDollarAmount( ) + ....); } To get your value to 2 decimal places use something like the following: DecimalFormat format = new DecimalFormat("#.00"); Double total_formatted = Double.parseDouble(format.format(total)); s.o.p(total_formatted); That enforces the value to have 2 decimal places with an optional amount of digits left of the decimal place. Final thing, you probably don't want to make everything static. It basically defeats the point of object orientation as static variable will persist throughout all objects of a class.
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/21565060

http://stackoverflow.com/comment/32733336
score: 0
has text: Thank you for the input. I have looked (and understood) the link tha thou sent me, but somehow I run into an issue because; when I am loading the images into a list (reference to the images that are to be used in the memory game) the references are all integers (refs to ints) but the resource used in the example from the link is a bitmap). My question now is how to convert the bitmap into something that could be used in the list - or maybe my question is intact, should I used something else than a list of int references to be able to use the bitmap as a reference?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21535360

http://stackoverflow.com/a/21545323
type: Answer
upvote count: 1
has body: If you add up all the red lines it equals 4. The left side of the tree actually goes to m(-2) but I didn't include it because it results in 0.
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/21545137

http://stackoverflow.com/comment/32642636
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21604746
has text: Yea i know, I just thought it should be done like this when both ends are connected to the samme network... So how do I get the ip adress of the receiving java program?
score: 0

http://stackoverflow.com/comment/32542429
score: 1
comment on: http://stackoverflow.com/q/21548989
has text: The current versions of Android are compatible with Java 6, not Java 7, so methods that were added in Java 7 or later are not available.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32755435
comment on: http://stackoverflow.com/q/21669503
score: 0
type: Comment
type: QuestionComment
has text: which kind of calculation you required. Arithmetic?

http://stackoverflow.com/q/21674463
tagged with: jsp
score: 0
tagged with: binding
has title: Spring jsp checkbox not binding
has body: I know this should be really easy to achieve but I've tried everything and still doesn't work. My JSP form is quite simple (code not fully posted): &lt;form:form id="form" class="form-horizontal" method="post" action="AddDoc" commandName="document" enctype="multipart/form-data"&gt; &lt;div id="divManual" class="checkbox"&gt; &lt;label id="labelManual"&gt; ${document.manual} &lt;form:checkbox id="chkManual" path="manual" label="This is a manual"/&gt; &lt;sf:errors path="manual" class="text-danger"/&gt; &lt;/label&gt; &lt;/div&gt; &lt;input id="submitForm" type="submit" class="btn btn-primary btn-lg" name="commit" value="Finish"&gt; &lt;/form:form&gt; The "document" object is just a simple POJO. When submitting the form the whole object goes through a validation process, then controller retrieves the same object if there are errors and each form parameter is properly binded, except for this "manual" parameter, which should be properly checked/unchecked, but it's always displayed unchecked, no matter if the user checked it before submitting. As you can see in the line ${document.manual} I print on the same page the parameter's value and I can tell you it is always correct, but for some reason form:checkbox doesn't get its value binded. Please, any ideas?
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21674622
tagged with: checkbox
tagged with: spring
has answer: http://stackoverflow.com/a/21676662
tagged with: java
type: Question
answer count: 2

http://stackoverflow.com/q/21589322
score: 1
tagged with: java
type: Question
answer count: 2
has title: How to return List of Object from server in GWT
has answer: http://stackoverflow.com/a/21589972
has body: I am using the tutorial explaining the usage of asyncdataprovider to create the celltable http://www.mytechtip.com/2010/11/gwt-celltable-example-using_8168.html. Tutorial mentioned that you can return the list of object from the server. // Associate an async data provider to the table AsyncDataProvider&lt;Contact&gt; provider = new AsyncDataProvider&lt;Contact&gt;() { @Override protected void onRangeChanged(HasData&lt;Contact&gt; display) { final int start = display.getVisibleRange().getStart(); int length = display.getVisibleRange().getLength(); AsyncCallback&lt;List&lt;Contact&gt;&gt; callback = new AsyncCallback&lt;List&lt;Contact&gt;&gt;() { @Override public void onFailure(Throwable caught) { Window.alert(caught.getMessage()); } @Override public void onSuccess(List&lt;Contact&gt; result) { updateRowData(start, result); } }; // The remote service that should be implemented remoteService.fetchPage(start, length, callback); } }; Could someone please tell me how can I return a list of object from the server.
possible better answer: http://stackoverflow.com/a/23044355
downvote count: 0
has answer: http://stackoverflow.com/a/23044355
accepted answer: http://stackoverflow.com/a/21589972
favorite count: 0
upvote count: 1
tagged with: gwt
type: AnsweredQuestion

http://stackoverflow.com/a/21642895
upvote count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/32716684
type: Answer
score: 1
has comment: http://stackoverflow.com/comment/32765812
has comment: http://stackoverflow.com/comment/32711760
answers question: http://stackoverflow.com/q/21636934
has body: I think you are looking for onException(). This feature of camel will catch any exception of the type you specify and will let you handle it the way you prefer. It seems that you want to catch that exception and the stop the route using the Control Bus component. It would be something like: onException(IllegalStateException.class). handled(true). to("controlbus:route?routeId=yourRouteId&amp;action=stop"); For more info, please take a look to: Apache Camel Exception Clause Apache Camel ControlBus Component

http://stackoverflow.com/q/21604947
has answer: http://stackoverflow.com/a/21605019
has body: I want to check if an activity is declared in the app's manifest. Some ads platform, like MMedia, Admob, etc need concret activities to be declared in your manifest. I want to automate a test that checks if those activities has been declared. Some of this libraries throws an exception if you forget to declare the activities, other just do not work. For example, checking if the activity com.google.ads.AdActivity is in my manifest Thanks
has comment: http://stackoverflow.com/comment/32641668
answer count: 1
accepted answer: http://stackoverflow.com/a/21605019
tagged with: android
has comment: http://stackoverflow.com/comment/32642152
type: AnsweredQuestion
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/32642094
type: Question
has title: Programmatically check if an Activity is declared in the AndroidManifest.xml
has comment: http://stackoverflow.com/comment/32642133

http://stackoverflow.com/a/21535275
score: 1
answers question: http://stackoverflow.com/q/21535228
upvote count: 1
downvote count: 0
has body: you can use equalIgnoreCase Method "Mike".equalsIgnoreCase(firstName) like if(firstName.equalsIgnoreCase("Mike") || firstName.equalsIgnoreCase("Diane")) { discount = true; }
type: Answer

http://stackoverflow.com/q/21558446
has title: remove escape characters from XML string in java
type: UnansweredQuestion
tagged with: html-escape-characters
tagged with: http://stackoverflow.com/tag/xml
score: 0
tagged with: java
has answer: http://stackoverflow.com/a/21558705
has comment: http://stackoverflow.com/comment/32572016
type: Question
has comment: http://stackoverflow.com/comment/32567084
has comment: http://stackoverflow.com/comment/32559581
linked to: http://stackoverflow.com/q/5084065
has comment: http://stackoverflow.com/comment/32559589
has body: I have inout XML with following format <Some_tag> this is >25000 </Some_tag> the actual XML is very big with +200KB. I am reading this XML in Java. I am getting it as String. What is solution to remove those > (Special char/escape char) from Tag values?
has comment: http://stackoverflow.com/comment/32559612
answer count: 2
has answer: http://stackoverflow.com/a/21558585

http://stackoverflow.com/q/21593606
type: Question
possible better answer: http://stackoverflow.com/a/21593650
has title: Customize text inside Edittext for chatting
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/21594293
has answer: http://stackoverflow.com/a/21594176
accepted answer: http://stackoverflow.com/a/21594176
linked to: http://stackoverflow.com/q/19238780
has answer: http://stackoverflow.com/a/21593650
tagged with: android
has body: I want to customize the text inside the edittext of my chatting app. I want to bold the username and normal font for his message. For example; usernamejay: Hi This is Jay. How are you? also make 1 space for reply after the message of usernamejay. i also want to change font color of username. Also if possible put message balloon for every message. Example: usernamejay: Hi This is Jay. How are you? usernameclark: I'm Fine. Can i call you now for a meeting? Can anyone help me how. This is the code for Java import java.io.UnsupportedEncodingException; import com.example.healthhelpv2.*; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; import android.database.Cursor; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnKeyListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; import at.vcity.androidim.interfaces.IAppManager; import at.vcity.androidim.services.IMService; import at.vcity.androidim.tools.FriendController; import at.vcity.androidim.tools.LocalStorageHandler; import at.vcity.androidim.types.FriendInfo; import at.vcity.androidim.types.MessageInfo; public class Messaging extends Activity { private static final int MESSAGE_CANNOT_BE_SENT = 0; public String username; private EditText messageText; private EditText messageHistoryText; private Button sendMessageButton; private IAppManager imService; private FriendInfo friend = new FriendInfo(); private LocalStorageHandler localstoragehandler; private Cursor dbCursor; private ServiceConnec…
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/comment/32498507
score: 0
type: AnswerComment
type: Comment
has text: i c changed but i have illegalArgumentExceptin
comment on: http://stackoverflow.com/a/21524032

http://stackoverflow.com/q/21628662
type: AnsweredQuestion
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32682923
has title: Adding children to a group whose elements are a string and list
score: 0
has comment: http://stackoverflow.com/comment/32682810
answer count: 1
accepted answer: http://stackoverflow.com/a/21628788
has comment: http://stackoverflow.com/comment/32682844
has comment: http://stackoverflow.com/comment/32682952
has body: I have a list of book objects, each book has a name and a author BooksObjects = {[Title 1, Author 1], [Title 2, Author 1] , [Title 3, Author 1], [Title 4, Author 2]...} I would like to create a relationship which groups the authors to a list of books i.e Groups = {[Author 1, {Title 1, Title 2, Title 3}, [Author 2, {Title 4, Title 5...} ...] i.e List&lt;String, List&lt;String&gt;&gt; groups How would i go about doing this? I don't want to use a HashMap because it doesn't store the entry by order.
has answer: http://stackoverflow.com/a/21628788

http://stackoverflow.com/a/21567775
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21566100
score: 1
upvote count: 1
has body: ask is a command, not a reporter. It does not report a value. (Nor does show.) Try changing your third line to: System.out.println(workspace.report("[pcolor] of patch 10 10"));

http://stackoverflow.com/a/21583446
downvote count: 0
answers question: http://stackoverflow.com/q/21583399
type: Answer
score: 2
upvote count: 2
has body: Short answer: Constructors are not inherited in Java. From the JLS: Constructor declarations are not members. They are never inherited and therefore are not subject to hiding or overriding. This means you have to declare the constructors needed for each subclass and call the corresponding super constructor. Even if it has the same signature it doesn't count as overriding.

http://stackoverflow.com/q/21583462
score: 4
tagged with: servlets
upvote count: 4
has answer: http://stackoverflow.com/a/21583515
has comment: http://stackoverflow.com/comment/32604260
answer count: 2
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/32608766
tagged with: jsessionid
type: UnansweredQuestion
has body: I am developing something using Servlets. I am creating cookies in this program, and a cookie named as JSESSIONID is being created, but when I comment out all the code even then the cookie is created. Here is my code: CookieDemoServlet.java: public class CookieDemoServlet extends HttpServlet { public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { /*String em = req.getParameter("email"); Cookie ck[] = req.getCookies(); if (ck != null) { if (ck.length != 0) { for (Cookie c : ck) { String cn = c.getName(); if (cn.equals("JSESSIONID")) { System.out.println("You are the Old User"); String cv = c.getValue(); String d = c.getDomain(); System.out.println(cn + "\t:" + cv + "\t:" + d); } } else { System.out.println("Sorry,No Cookies Found"); } } HttpSession session = req.getSession(); boolean b = session.isNew(); if (b) { System.out.println("You are the New user"); } else { System.out.println("You are the Old User"); } Cookie c1 = new Cookie("Email", em); res.addCookie(c1); Cookie c2 = new Cookie("Phone", "99999"); res.addCookie(c2);*/ RequestDispatcher rd = req.getRequestDispatcher("cookiedemo.jsp"); rd.forward(req, res); } } } What could be the reason?
has answer: http://stackoverflow.com/a/21583619
tagged with: java
linked to: http://stackoverflow.com/q/595872
has title: Why does my Servlet create a JSESSIONID cookie?
type: Question

http://stackoverflow.com/q/21526666
has comment: http://stackoverflow.com/comment/32505026
tagged with: java
tagged with: selenium
has body: In a site I have: testing the test String value = (String)((JavascriptExecutor) this).executeScript("return window.document.getElementById('tempid').value"); System.out.println("value is : " + value); I am getting null value or nothing. I want to get the test "testing the test" as output.
has comment: http://stackoverflow.com/comment/32505361
has comment: http://stackoverflow.com/comment/32505296
tagged with: selenium-rc
type: Question
tagged with: javascript
has comment: http://stackoverflow.com/comment/32511085
answer count: 3
downvote count: 3
has title: Not able to get visible text from some paragraph by using javascript executor and web driver
favorite count: 0
has answer: http://stackoverflow.com/a/73693851
type: UnansweredQuestion
score: -3
has answer: http://stackoverflow.com/a/21527870
has answer: http://stackoverflow.com/a/21531177
upvote count: 0

http://stackoverflow.com/comment/32551571
type: Comment
has text: Thats what i thought too. If i launch it with eclipse's internal tomcat-instance it works well, but not with `mvnDebug tomcat:run`.
score: 0
comment on: http://stackoverflow.com/q/21548506
type: QuestionComment

http://stackoverflow.com/a/21633060
has comment: http://stackoverflow.com/comment/32691722
has body: Have you tried dispatcher /foo/* Check this out Try with this. @RequestMapping(value = "/{id}") As /foo redirect to the servlet make /foo/1 will try to find /foo/foo/1
answers question: http://stackoverflow.com/q/21632996
has comment: http://stackoverflow.com/comment/32691428
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32690752
has comment: http://stackoverflow.com/comment/32690787
has comment: http://stackoverflow.com/comment/32691550
has comment: http://stackoverflow.com/comment/32691486
type: Answer
has comment: http://stackoverflow.com/comment/32691072
has comment: http://stackoverflow.com/comment/32691019
accepted answer of: http://stackoverflow.com/q/21632996
score: 1
has comment: http://stackoverflow.com/comment/32691972
upvote count: 1

http://stackoverflow.com/comment/32636788
score: 2
has text: Google GSON example consuming rest or similar, there's loads of documentation on this.
type: QuestionComment
comment on: http://stackoverflow.com/q/21602313
type: Comment

http://stackoverflow.com/comment/32707559
comment on: http://stackoverflow.com/a/21642056
score: 0
type: AnswerComment
has text: Alright, scratch what I just said. I input that code (where scan.nextInt(); and try catch are included), compiled and ran. If I put in letters, I still get a mismatch exception.
type: Comment

http://stackoverflow.com/q/21618302
score: 0
answer count: 2
possible better answer: http://stackoverflow.com/a/21618467
accepted answer: http://stackoverflow.com/a/21618335
tagged with: android
tagged with: facebook-sdk-3.0
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21618467
has answer: http://stackoverflow.com/a/21618335
tagged with: java
has title: Facebook SDK : Android, what is the class of Request
type: Question
linked to: http://stackoverflow.com/q/17426741
has body: I have took this code from internet, to post a message on facebook, from the android app : this is the link : How can l post on facebook from android app with API wall without checking? Request.Callback callback= new Request.Callback() { //some code } The problem is I don't know which Class should I import between : _ DownloadManager _ CORBA _ sun.misc Could you help me ? thanks you
tagged with: eclipse

http://stackoverflow.com/a/21677793
answers question: http://stackoverflow.com/q/21677126
score: 0
type: Answer
has body: The example above is a gridView with some pictures (mThumbIds) that are shown. Create a gridView via xml. Then get it in your code like this: GridView gv = (GridView) findViewById(R.id.gridView1); Then create a image Adapter , and set attach it to your GridView : imageAdapter = new ImageAdapter(this); gv.setAdapter(imageAdapter); Here the code for your ImageAdapter: The getView method is executed for each item in your grid. public class ImageAdapter extends BaseAdapter { private Context mContext; public ImageAdapter(Context c) { mContext = c; } public int getCount() { return mThumbIds.length; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } // create a new ImageView for each item referenced by the Adapter public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView; if (convertView == null) { // if it's not recycled, initialize some attributes imageView = new ImageView(mContext); imageView.setLayoutParams(new GridView.LayoutParams(85, 85)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(8, 8, 8, 8); } else { imageView = (ImageView) convertView; } imageView.setImageResource(mThumbIds[position]); return imageView; } // references to our images private Integer[] mThumbIds = { R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4, R.drawable.sample_5, R.drawable.sample_6, R.drawable.sample_7, R.drawable.sample_0, R.drawable.sample_1, R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4, R.drawable.sample_5, R.drawable.sample_6, R.drawable.sample_7, R.drawable.sample_0, R.drawable.sample_1, R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4, R.drawable.sample_5, R.drawable.sample_6, R.drawable.sample_7 }; }

http://stackoverflow.com/q/21641572
has title: What is the actual value of "line.separator"?
has answer: http://stackoverflow.com/a/21641583
answer count: 4
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21641574
tagged with: java
type: Question
score: 5
has body: I always think that line.separator do the same things as \n, and yes it is. but I noticed that both values are actually not the same(perhaps not even close?) when I test this code: String str1 = System.getProperty("line.separator"); String str2 = "\n"; System.out.println(str1.equals(str2)); // output:false (as expected) Then I checked the length of both: System.out.println(str1.length()); //output: 2 System.out.println(str2.length()); //output: 1 wondering why str1.length() is 2, I tried this: System.out.println("**"+str1.charAt(0)+"**"); output: ** System.out.println("##"+str1.charAt(1)+"##"); output: ## ## So I noticed that the actual newline character in line.separator is the second character. Then what is the value in first index, as when it supposed to print **** (atleast), its print ** instead?
upvote count: 5
downvote count: 0
has comment: http://stackoverflow.com/comment/32706437
tagged with: char
has answer: http://stackoverflow.com/a/21641574
has answer: http://stackoverflow.com/a/21641590
tagged with: string
possible better answer: http://stackoverflow.com/a/21641583
has answer: http://stackoverflow.com/a/32798066
favorite count: 0

http://stackoverflow.com/a/21571001
upvote count: 2
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21566818
accepted answer of: http://stackoverflow.com/q/21566818
type: Answer
score: 2
downvote count: 0
has body: In these cases of "refactoring" i use a simple find and replace approach. Notepad++ has a " find in files" feature but there are plenty of similar programs. Create a class which does the properties loading with a method probably with a name parameter for the property file. This can be a java singleton or a spring bean. Search and replace all "new Properties()" lines with an empty line. Replace all "load..." lines with a reference to your new class/ method. Notepad++ supports regex replacement, so you can use the filename as a parameter. Once this is done go to eclipse and launch a "cleanup" or "organize imports" and fix some compile errors manually if needed. This approach is quite straight forward and takes no more than 10min if you are lucky or 1 hour if you are unlucky, f.e. the code formatting is way of and each file looks different. You can make your replace simpler if you format the project once before with a line length of 300 or more so each java statement is on one line. This makes find and replace a bit easier as you dont have newlines to consider.

http://stackoverflow.com/comment/32487425
comment on: http://stackoverflow.com/a/21517452
has text: I'm still left with the error: "java: '.class' expected" On this line: total = sum(numbers[]);
type: AnswerComment
type: Comment
score: 0

http://stackoverflow.com/comment/32591116
type: Comment
type: QuestionComment
has text: possible duplicate of [Initialize SessionContext with principal when connecting to remote EJB](http://stackoverflow.com/questions/21556906/initialize-sessioncontext-with-principal-when-connecting-to-remote-ejb)
comment on: http://stackoverflow.com/q/21572957
score: 0

http://stackoverflow.com/comment/32668590
score: 0
has text: It will run in minimized mode. That's ok. Is there a way to completely hide it even not in minimized mode?
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21619476

http://stackoverflow.com/comment/86814341
comment on: http://stackoverflow.com/a/29430214
type: AnswerComment
score: 0
type: Comment
has text: This completely compiler error and the Android studio says "required `long[]` but found `java.lang.Long[]`"

http://stackoverflow.com/q/21672421
downvote count: 1
accepted answer: http://stackoverflow.com/a/21680663
favorite count: 0
has answer: http://stackoverflow.com/a/21680663
type: AnsweredQuestion
has body: I'm adding a static card to my google glass timeline. How can I dismiss this card after 2 seconds? Is it possible to delay-dismiss even if the activity which created this card has finished already?
tagged with: java
tagged with: google-gdk
type: Question
answer count: 1
score: 0
has title: how to dismiss a static card in Google glass after X seconds?
tagged with: google-glass
upvote count: 1
tagged with: android

http://stackoverflow.com/q/21542621
possible better answer: http://stackoverflow.com/a/21542895
accepted answer: http://stackoverflow.com/a/21542887
has answer: http://stackoverflow.com/a/21542895
tagged with: android-listview
tagged with: android
favorite count: 0
has comment: http://stackoverflow.com/comment/32532705
upvote count: 1
has answer: http://stackoverflow.com/a/21542887
type: AnsweredQuestion
has body: ArrayList&lt;HashMap&lt;String, String&gt;&gt; MemberList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); HashMap&lt;String, String&gt; item = new HashMap&lt;String, String&gt;(); item.put("asdf", "asdf"); MemberList.add(item); item.put("ffff", "ffff"); MemberList.add(item); SimpleAdapter simpleAdapter = new SimpleAdapter(MainActivity.this, MemberList, android.R.layout.simple_list_item_2, new String[] { "Name", "Level" }, new int[] { android.R.id.text1, android.R.id.text2 }); list.setAdapter(simpleAdapter); this is my java code. but.... there are just two empty blanks there is no Text in ListView what should I do ?
score: 1
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32532898
answer count: 2
has title: empty ListView in simple_list_item_2 mode
downvote count: 0

http://stackoverflow.com/a/21573256
score: 3
downvote count: 0
has body: Looks like dataSource is null because setDataSource is never called.
type: Answer
answers question: http://stackoverflow.com/q/21573193
upvote count: 3

http://stackoverflow.com/comment/32601279
comment on: http://stackoverflow.com/q/21581573
score: 0
has text: Ok, maybe not contradictory just badly worded
type: QuestionComment
type: Comment

http://stackoverflow.com/q/21630860
tagged with: apache-storm
has answer: http://stackoverflow.com/a/32156433
has answer: http://stackoverflow.com/a/21631615
type: Question
upvote count: 4
downvote count: 0
score: 4
has answer: http://stackoverflow.com/a/21644496
tagged with: slf4j
answer count: 4
tagged with: log4j
has title: Storm Topology not submit
favorite count: 0
accepted answer: http://stackoverflow.com/a/21644496
has answer: http://stackoverflow.com/a/34884424
tagged with: rabbitmq
type: AnsweredQuestion
tagged with: java
has body: i have configured my machine zookeeper,nimbus,supervisor are running properly and my topology working in LocalCluster LocalCluster cluster = new LocalCluster(); cluster.submitTopology("SendPost", conf, builder.createTopology()); Utils.sleep(10000000000l); cluster.killTopology("SendPost"); cluster.shutdown(); now i want try submit my topology bt it not working /usr/local/storm/bin$ ./storm jar /home/winoria/Desktop/Storm/storm-starter/target/storm-starter-0.0.1-SNAPSHOT-jar-with-dependencies.jar com.winoria.post.PostTopology Post i getting following error SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/usr/local/storm/lib/logback-classic-1.0.6.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/winoria/Desktop/Storm/storm-starter/target/storm-starter-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. Running: java -client -Dstorm.options= -Dstorm.home=/usr/local/storm -Djava.library.path=/usr/local/lib:/opt/local/lib:/usr/lib -Dstorm.conf.file= -cp /usr/local /storm/storm-netty-0.9.0.1.jar:/usr/local/storm/storm-console-logging-0.9.0.1.jar:/usr/local/storm/storm-core-0.9.0.1.jar:/usr/local/storm/lib/httpcore-4.1.jar:/usr/local/storm/lib/carbonite-1.5.0.jar:/usr/local/storm/lib/mockito-all-1.9.5.jar:/usr/local/storm/lib/commons-io-1.4.jar:/usr/local/storm/lib/commons-fileupload-1.2.1.jar:/usr/local/storm/lib/jgrapht-0.8.3.jar:/usr/local/storm/lib/ring-jetty-adapter-0.3.11.jar:/usr/local/storm/lib/jzmq-2.1.0.jar:/usr/local/storm/lib/asm-4.0.jar:/usr/local/storm/lib/logback-core-1.0.6.jar:/usr/local/storm/lib/tools.nrepl-0.2.3.jar:/usr/local/storm/lib/compojure-1.1.3.jar:/usr/local/storm/lib/json-simple-1.1.jar:/usr/local/storm/lib/ring-devel-0.3.11.jar:/usr/local/storm/lib/commons-logging-1.1.1.jar:/usr/local/storm/lib/httpclient-4.1.1.jar:/usr/local/storm/lib/reflectasm-1.07-shaded.jar…
possible better answer: http://stackoverflow.com/a/21631615

http://stackoverflow.com/comment/32742074
type: Comment
type: QuestionComment
has text: Are you trying to _open_ (unpack) the jar file, or are you trying to _use_ the jar file by putting it on the classpath and invoking a class from it, or are you trying to run its default class using the `java -jar` syntax? If the latter, you need to explicitly say which class should be used as the main class when you build the jar.
score: 0
comment on: http://stackoverflow.com/q/21662256

http://stackoverflow.com/q/21644682
has body: I am trying to use the jsp tag as following without jsp:useBean tag. Value being set in servlet and forwarded to a jsp: request.setAttribute("person", p); In jsp trying to get value: &lt;jsp:getProperty name="person" property="title"/&gt; Sometimes it gets the value and sometimes it throws the following exception: org.apache.jasper.JasperException: file:/index.jsp(17,0) jsp:getProperty for bean with name 'person'. Name was not previously introduced as per JSP.5.3 Kindly suggest why the behavior is not predictable?
tagged with: java
tagged with: tags
has title: JSP Get property | <jsp:getProperty
type: Question
has answer: http://stackoverflow.com/a/21644769
answer count: 1
tagged with: jsp
score: 0
accepted answer: http://stackoverflow.com/a/21644769
type: AnsweredQuestion

http://stackoverflow.com/a/21555060
score: 1
upvote count: 1
has body: On the server side you need some kind of collection to gather all the results. For example List&lt;String&gt; list = new LinkedList&lt;String&gt;(); //... while(rs.next()) { list.add(dname + ", " + dsurname); } Then return this list to the client. If you got my tiny example with the List of Strings to work you might want to continue to work on a List of Object of your own Class (for example Name).
has comment: http://stackoverflow.com/comment/32553550
answers question: http://stackoverflow.com/q/21554905
downvote count: 0
has comment: http://stackoverflow.com/comment/32553946
type: Answer
has comment: http://stackoverflow.com/comment/32553642
has comment: http://stackoverflow.com/comment/32552856

http://stackoverflow.com/q/21616234
downvote count: 0
has body: I am writing a web-service that heavily relies on a single large Map that is completely updated once every hour. The rest of the time many threads concurrently read the table. My question is: What is the most efficient construct to realize such a Map? The Map can be rather larger (100 - 500 MB). There is only read access except once an hour where the whole map is replaced. I was thinking about just using a Java HashMap and maybe using reflection to set the field final between the updates if this improves performance, but I have no clue how to make the JVM optimize for many concurrent reads.
has answer: http://stackoverflow.com/a/21616295
favorite count: 0
has answer: http://stackoverflow.com/a/21616323
tagged with: concurrenthashmap
answer count: 4
has comment: http://stackoverflow.com/comment/32662290
has answer: http://stackoverflow.com/a/28133620
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21616295
score: 7
tagged with: java
linked to: http://stackoverflow.com/q/1378310
has title: Concurrent read-only HashMap
upvote count: 7
possible better answer: http://stackoverflow.com/a/28133620
type: Question
tagged with: hashmap
has comment: http://stackoverflow.com/comment/32662401
has comment: http://stackoverflow.com/comment/32662279
has answer: http://stackoverflow.com/a/27805047

http://stackoverflow.com/comment/32677916
type: Comment
has text: where are your name,year_discovered,population fields in the child class or constructor? . you can't access those fields of the parent before it is created(i.e, before it's constructor is called.)
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21625868

http://stackoverflow.com/a/21580145
has body: URL url = new URL("file:/C:/projektoj/ĝeneralaj"); Path path = Paths.get(url.toURI()); C:\projektoj\ĝeneralaj If the URL points into a jar/zip ("jar:file:/... .zip!.../...") then one may use the Path in the zip FileSystem, see: java: change ZipEntry name
has comment: http://stackoverflow.com/comment/32627544
score: 2
downvote count: 0
upvote count: 2
has comment: http://stackoverflow.com/comment/32599950
answers question: http://stackoverflow.com/q/21578761
type: Answer

http://stackoverflow.com/a/22864979
has body: If your web application is accessed via an authentication step, it is possible that the Java plugins for Chrome and Firefox are unable to download the jar files - when they try to access the URL for the applet, they most probably are greeted by your login page. You could confirm this with Fiddler. This problem does not appear in IE, because the Java plugin is able to use the session held by the browser itself, so the applet loader is able to immediately download the jar file. If this is the case for you, the obvious solution is to allow unauthenticated access to the jar file. If you are using IIS, this is done by adding exceptions in web.config.
has comment: http://stackoverflow.com/comment/49599391
downvote count: 0
type: Answer
score: 2
answers question: http://stackoverflow.com/q/21529341
upvote count: 2

http://stackoverflow.com/comment/32504797
comment on: http://stackoverflow.com/q/21527523
type: Comment
type: QuestionComment
has text: It's not hex address... it's the result of invoking `hashCode()` in hex notation. As far as `Object#toString()` is concerned, it could be anything.
score: 3

http://stackoverflow.com/comment/32714202
score: 0
type: AnswerComment
has text: Ah so I encode the same way back ok then I understand
type: Comment
comment on: http://stackoverflow.com/a/21646234

http://stackoverflow.com/q/21562350
has comment: http://stackoverflow.com/comment/32566904
tagged with: user-interface
tagged with: jframe
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32567142
has title: GUI building and using different classes Java
has comment: http://stackoverflow.com/comment/32566832
tagged with: java
has answer: http://stackoverflow.com/a/21563782
has comment: http://stackoverflow.com/comment/32567045
type: Question
has answer: http://stackoverflow.com/a/21562820
has comment: http://stackoverflow.com/comment/32566757
tagged with: jpanel
has body: So I'm starting a new project and I was wondering how can I setup multiple classes for my different JPanels. It looks very messy in one class. Let me show you the example. I would like the JPanel for a menu screen in it's own class. import java.awt.EventQueue; public class TakeAwayLogin { private JFrame frmTakeAwaySystem; private JTextField textFieldId; private JPasswordField passwordField; /** * Launch the application. * @return */ public void login() { EventQueue.invokeLater(new Runnable() { public void run() { try { TakeAwayLogin window = new TakeAwayLogin(); window.frmTakeAwaySystem.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the application. */ public TakeAwayLogin() { initialize(); } /** * Initialize the contents of the frame. */ private void initialize() { frmTakeAwaySystem = new JFrame(); frmTakeAwaySystem.setTitle("Take Away System Alpha"); frmTakeAwaySystem.setBounds(100, 100, 450, 300); frmTakeAwaySystem.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frmTakeAwaySystem.getContentPane().setLayout(new CardLayout(0, 0)); final JPanel panelLogin = new JPanel(); frmTakeAwaySystem.getContentPane().add(panelLogin, "name_254735117500687"); panelLogin.setLayout(null); panelLogin.setVisible(true); final JLabel lblIncorrect = new JLabel("Incorrect login, try again"); lblIncorrect.setHorizontalAlignment(SwingConstants.CENTER); lblIncorrect.setFont(new Font("Tahoma", Font.PLAIN, 9)); lblIncorrect.setForeground(Color.RED); lblIncorrect.setBounds(148, 74, 139, 14); panelLogin.add(lblIncorrect); lblIncorrect.setVisible(false); final JPanel panelPassword = new JPanel(); frmTakeAwaySystem.getContentPane().add(panelPassword, "name_254738265432897"); panelPassword.setLayout(null); passwordField = new JPasswordField(); passwordField.setBounds(112, 157, 205, 41); panelLogin.add(passwordField); passwordField.setHorizontalAlignment(JPasswordField.CENTER); JButton btnNewButton = new JButton("Lock Application"); btnNewButton.addActionListe…
score: 0
answer count: 2

http://stackoverflow.com/comment/32617489
comment on: http://stackoverflow.com/q/21578482
has text: The title of the post contradicts the body. Is it Java-FX or Swing?
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32753741
has text: @user3289385 See GregS's comment below if you want to continue to encrypt directly. Alternatively, it might be easier to use CipherOutputStream and CipherInputStream. I've edited my answer to include a discussion on that.
comment on: http://stackoverflow.com/a/21658117
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32572979
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21565611
has text: Hi, Thanks for your inputs, I have to use BouncyCastle API is there any document that you can point me to where in I can get the same equivalent of the code that you just used.

http://stackoverflow.com/q/21629979
has comment: http://stackoverflow.com/comment/32685223
has comment: http://stackoverflow.com/comment/32685884
has answer: http://stackoverflow.com/a/21630108
type: Question
has comment: http://stackoverflow.com/comment/32685964
has comment: http://stackoverflow.com/comment/32685545
has comment: http://stackoverflow.com/comment/32685373
score: 0
tagged with: java
answer count: 1
has body: I have a few ENUMs that for each pair combination of them something must be done. For example I have: public enum Rank { High, MID, LOW } and public enum Time { BEFORE, NOW, AFTER } Now in my application I need to write something like this: if ( X == Rank.HIGH &amp;&amp; Y == Time.NOW ) { // Do something } This works, but as the list of items in my ENUMs gets bigger those combinations are cumbersome to write. Is there any better way?
has title: Good way to write combination of conditions
tagged with: enums
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32685241
tagged with: logical-operators

http://stackoverflow.com/q/21537699
type: UnansweredQuestion
tagged with: jackson
has comment: http://stackoverflow.com/comment/32523624
has title: Complex recursive JSON response in Java using jackson API
has answer: http://stackoverflow.com/a/21538084
type: Question
tagged with: java
tagged with: http://stackoverflow.com/tag/json
score: 0
has body: I am using jackson to map my java class to JSON. How can I write/design a complex response that contains recursive attributes? I don't know how deep will be my leaf from the tree. I can have a tree with 1 node and 1 value (easy), and a tree with N nodes. For example, we can have { "glossary_0": { "glossary_1": { "glossary_2": { [...] "glossary_N" : "value" } } } } Thank you for your advice
answer count: 1

http://stackoverflow.com/comment/32729526
has text: I added the super.paintComponent(), and I set the layout of my JFrame to a FlowLayout(), however, the Image in my JPanel is invisible now, no matter if the layout is null or Flow.
comment on: http://stackoverflow.com/a/21654805
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32599385
type: AnswerComment
has text: Thanks Lakshman but I have also tried updating the Spring version but got the same error.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21569044

http://stackoverflow.com/a/21603725
score: 0
has body: Use Collection instead of array: List&lt;Cow&lt;E&gt;&gt; cows = new ArrayList&lt;&gt;(); // in Java 7 Or List&lt;Cow&lt;E&gt;&gt; cows = new ArrayList&lt;Cow&lt;E&gt;&gt;(); //Java 6 and below More information will show why it is IMPOSSIBLE to have arrays whit generics. You can see here
type: Answer
answers question: http://stackoverflow.com/q/21603541

http://stackoverflow.com/comment/32484334
has text: You mean like `catch (InterruptedException, Exception e)`?
type: AnswerComment
comment on: http://stackoverflow.com/a/21515687
score: 0
type: Comment

http://stackoverflow.com/comment/32671921
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21621735
score: 0
has text: What is todayDate ? Joda DateTime?

http://stackoverflow.com/comment/32491871
comment on: http://stackoverflow.com/q/21518697
type: Comment
type: QuestionComment
has text: @SotiriosDelimanolis i posted the code.
score: 0

http://stackoverflow.com/a/21545285
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21545137
has body: Let's break it down: m(4) = m(2) + n(3); m(2) = m(0) + n(1); m(0) = m(-2) + n(-1); = 0 + 0 n(3) = 1 + n(2); n(2) = 1 + n(1); n(1) = 1 + n(0); = 1 + 0 n(1) = 2 Lets substitute all the values back: n(2) = 1 + n(1) = 2 n(3) = 1 + n(2) = 3 m(2) = 0 + 1; m(4) = 1 + 3 = 4

http://stackoverflow.com/a/21572551
has comment: http://stackoverflow.com/comment/32602040
type: Answer
answers question: http://stackoverflow.com/q/21565318
has body: new Thread() { @Override public void run() { YourActivity.this.runOnUiThread(new Runnable() { @Override public void run() { myView.setBackgroundColor(Color.parseColor( theColor )); } Thread.sleep( theDuration); YourActivity.this.runOnUiThread(new Runnable() { @Override public void run() { myView.setBackgroundColor(Color.parseColor( nextColor )); } Thread.sleep( nextDuration ); } }.start(); Put this in a method and call it.
upvote count: 2
score: 2
downvote count: 0

http://stackoverflow.com/a/21565647
has comment: http://stackoverflow.com/comment/32572913
answers question: http://stackoverflow.com/q/21565606
score: 4
has comment: http://stackoverflow.com/comment/32572996
has body: Add import android.location.LocationListener; to your list of imports. Also, your CAPS LOCK key seems to be broken. You might want a new keyboard.
type: Answer
upvote count: 4
downvote count: 0

http://stackoverflow.com/a/21669958
upvote count: 2
has body: A HashSet by definition doesn't sort its members. What you want is a TreeSet. If you have a hashset you can create a treeset from it, as long as the objects are Comparable: TreeSet ts = new TreeSet (hs);
answers question: http://stackoverflow.com/q/21669931
type: Answer
score: 2
downvote count: 0

http://stackoverflow.com/comment/32487558
type: Comment
type: QuestionComment
score: 2
comment on: http://stackoverflow.com/q/21517413
has text: What is queue? How is it created?

http://stackoverflow.com/comment/32570881
comment on: http://stackoverflow.com/a/21527060
score: 1
has text: @Cataclysm I actually only see a weird symbol for that letter (as does Alexei likely), but if Unicode says that it's a letter then Java will do so too and accept it as part of an identifier.
type: AnswerComment
type: Comment

http://stackoverflow.com/q/21667418
has body: I want add "permalink" feature to my web written in Spring. If user click to permalink bottom article, Spring must send to user browser page with this one (only one) article with id from url. For example: http://example.net/article/123 There is my broken code: @Controller public class ArticleController { @Autowired private ArticleManager am; @RequestMapping(value = "/article/{id}", method = RequestMethod.GET) public String showArticle(@PathVariable int id, Model model, final RedirectAttributes redirectAttributes) { String visited = "no"; try { visited = (String) model.asMap().get("visited"); } catch (Exception e) { e.printStackTrace(); } if (! visited.equals("yes")) { Article x = am.findById(id); model.addAttribute("article", x); redirectAttributes.addAttribute("visited", "yes"); return "/article/"+id; } return "redirect:/article/"+id; } } Update: Like on Facebook wall. If I click on publish date bottom the post, Facebook redirect me to page with only this post: https://www.facebook.com/9gag/posts/205093383022280
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32752093
has comment: http://stackoverflow.com/comment/32752252
has title: Spring controller: permanent link to article like on Facebook
tagged with: controller
score: 0
tagged with: permalinks
type: UnansweredQuestion
tagged with: facebook
tagged with: spring
answer count: 0

http://stackoverflow.com/a/21566152
has comment: http://stackoverflow.com/comment/32574014
has comment: http://stackoverflow.com/comment/32573990
has body: Reset n to zero after you get the height of the triangle. // ... Scanner input = new Scanner(System.in); System.out.println("Enter an odd number:"); i = input.nextInt(); n = 0; // &lt;- Here // ...
type: AcceptedAnswer
downvote count: 0
score: 1
type: Answer
accepted answer of: http://stackoverflow.com/q/21566030
answers question: http://stackoverflow.com/q/21566030
upvote count: 1

http://stackoverflow.com/q/21637293
has answer: http://stackoverflow.com/a/21637532
tagged with: out-of-memory
tagged with: http://stackoverflow.com/tag/csv
has comment: http://stackoverflow.com/comment/32699628
tagged with: hashtable
has body: I have two text files with comma delimited values. One is 150MB and the other is 370MB, so these guys have three million+ rows of data. One document holds information about, let's say soft drink preferences, and the next might have information about, let's say hair colors. Example soft drinks data file, though in the real file the UniqueNames are NOT in order, nor are the dates: "UniqueName","softDrinkBrand","year" "001","diet pepsi","2004" "001","diet coke","2006" "001","diet pepsi","2004" "002","diet pepsi","2005" "003","coca cola","2004" Essentially, there are too many lines of data to use excel, so I want to create Person objects using a Person class to hold the data about each person. Each Person object holds twenty array lists, two for each of ten years 2004-2013, e.g., ... private ArrayList&lt;String&gt; sodas2013= new ArrayList&lt;String&gt;(); private ArrayList&lt;String&gt; hairColors2013= new ArrayList&lt;String&gt;(); private ArrayList&lt;String&gt; sodas2014= new ArrayList&lt;String&gt;(); private ArrayList&lt;String&gt; hairColors2014= new ArrayList&lt;String&gt;(); ... I wrote a program to read the rows of a data file, one at a time, using a BufferedReader. For each row, I clean up the data (split on the commas, delete quote marks...), and then, if that particular uniqueID isn't in a Hashtable yet, I add it, as well as create a new Person object from my Person class, and then I store the data I want into the Person class' ArrayList as above. If the unique ID is already present, I just call a Person method to see if the soda, or hair color, is already in the array list for that particular year (as written in the csv file). The goal is to output twenty different csv files in the end, one tying people to sodas drunk in each year, one to hair colors for that year. They would look like this... 2004 file using above example input file: UID pepsi coca cola diet pepsi diet coke etc 001 false false true false etc 002 false false false false etc 003 false true …
accepted answer: http://stackoverflow.com/a/21637419
favorite count: 0
has comment: http://stackoverflow.com/comment/32699439
tagged with: large-files
upvote count: 2
has comment: http://stackoverflow.com/comment/32699657
answer count: 5
has title: Memory issue when Reading HUGE csv file, STORE as Person objects, Write into multiple cleaner/smaller CSV files
has comment: http://stackoverflow.com/comment/32699235
has answer: http://stackoverflow.com/a/21637916
type: AnsweredQuestion
score: 2
has answer: http://stackoverflow.com/a/21637581
tagged with: java
has comment: http://stackoverflow.com/comment/32699126
possible better answer: http://stackoverflow.com/a/21637513
type: Question
linked to: http://stackoverflow.com/q/1565388
has answer: http://stackoverflow.com/a/21637513
downvote count: 0
has comment: http://stackoverflow.com/comment/32698898
has answer: http://stackoverflow.com/a/21637419

http://stackoverflow.com/q/21671990
has body: bI have the following java code: Intent intent = getIntent(); CO2 = intent.getIntExtra("CO2", 0); TextView textCo2 = (TextView)findViewById(R.id.textRoadView1); textCo2.setText(String.valueOf("CO2 emissions: "+CO2+"g")); And the XML file: &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/textRoadView1" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".RoadDetails" &gt; &lt;TextView android:id="@+id/textRoadView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/textView2" android:layout_marginTop="38dp" android:text="Medium Text" android:textAppearance="?android:attr/textAppearanceMedium" /&gt; &lt;/RelativeLayout&gt; So when I try to set some text in the "textCo2" I get this weird exception "Android widget relativelayout cannot be cast to android widget textview." I tried removing the "R.java" file and cleaning the project but the problem continued. I think the mistake is somewhere in my code but I can find it. Could you help me out?
downvote count: 0
answer count: 1
tagged with: textview
favorite count: 0
tagged with: android
score: 2
type: AnsweredQuestion
upvote count: 2
tagged with: java
type: Question
tagged with: android-layout
has answer: http://stackoverflow.com/a/21672026
has title: Android widget relativelayout cannot be cast to android widget textview
accepted answer: http://stackoverflow.com/a/21672026
has comment: http://stackoverflow.com/comment/32758986

http://stackoverflow.com/q/21594025
score: 0
answer count: 1
has comment: http://stackoverflow.com/comment/32623570
tagged with: java
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32623454
has comment: http://stackoverflow.com/comment/32623374
has body: I am following the tutorial here and I have been trying to get this working for two days now. I get this error message when compiling FileData. FileData.java:13: error: cannot find symbol ReadFile file = new ReadFile(file_name); ^ symbol: class ReadFile location: class FileData FileData.java:13: error: cannot find symbol ReadFile file = new ReadFile(file_name); ^ symbol: class ReadFile location: class FileData Any assistance would be greatly appreciated. The code follows: package textfiles; import java.io.IOException; public class FileData { public static void main(String[] args) throws IOException { String file_name = "C:/test.txt"; try { ReadFile file = new ReadFile(file_name); String[] aryLines = file.OpenFile(); int i; for (i=0; i &lt; aryLines.length; i++) { System.out.println(aryLines[i]); } } catch (IOException e) { System.out.println( e.getMessage() ); } } } package textfiles; import java.io.IOException; import java.io.FileReader; import java.io.BufferedReader; public class ReadFile { private String path; public ReadFile (String file_path) //ReadFile Method { path = file_path; } public String[] OpenFile() throws IOException //OpenFile method { FileReader fr = new FileReader(path); BufferedReader textReader = new BufferedReader(fr); int numberOfLines = readLine(); String[] textData = new String[numberOfLines]; int i; for (i=0; i &lt; numberOfLines; i++) { textData[i] = textReader.readLine(); } textReader.close(); return textData; } int readLine() throws IOException //readLines Method { FileReader file_to_read = new FileReader(path); BufferedReader bf = new BufferedReader(file_to_read); String aLines; int numberOfLines = 0; while ((aLines = bf.readLine()) !=null) { numberOfLines++; } bf.close(); return numberOfLines; } }
type: Question
has title: I cannot find the error
has answer: http://stackoverflow.com/a/21594216

http://stackoverflow.com/comment/32593949
type: AnswerComment
comment on: http://stackoverflow.com/a/21577658
type: Comment
has text: Don't know what a constructor is. Well, in netbeans, I just go to properties and setIcon
score: 0

http://stackoverflow.com/comment/32708355
comment on: http://stackoverflow.com/a/21642618
score: 0
type: AnswerComment
has text: @user3108505 You can hold objects in ArrayList, and each object can in turn hold the elements. You may even use a HashMap as that object.
type: Comment

http://stackoverflow.com/q/21664925
tagged with: mysql
has answer: http://stackoverflow.com/a/21664992
accepted answer: http://stackoverflow.com/a/21664992
possible better answer: http://stackoverflow.com/a/63230697
type: Question
score: 3
has answer: http://stackoverflow.com/a/70111521
tagged with: tablename
tagged with: java
has body: I have 5 or table table to query from \ my syntax i like this String sql2 = "SELECT * FROM ? WHERE Patient_ID = ?"; pst = conn.prepareStatement(sql2); System.out.println("SQL before values are set "+sql2); System.out.println("The values of table/test name recieved in TestPrint stage 1 "+tblName); System.out.println("The values of test name recieved in TestPrint stage 1 "+key); // values are outputted correctly but are not getting set in the query pst.setString(1, tblName); pst.setLong(2, key); ResultSet rs2 = pst.executeQuery(sql2); while(rs2.next()){ String ID = rs2.getString("ID"); jLabel35.setText(ID); jLabel37.setText(ID); jLabel38.setText(ID); // them print command is initiated to print the panel } The problem is when i run this i get an error saying ".....you have and error in SQL syntax near ? WHERE Patient_ID = ?" When i output the sql using system.out.println(sql2); values are not set in sql2
has answer: http://stackoverflow.com/a/79007394
upvote count: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/32747105
has title: How to use dynamic table name in SELECT query using JDBC
has answer: http://stackoverflow.com/a/63230697
favorite count: 0
answer count: 4
type: AnsweredQuestion
tagged with: dynamic
tagged with: select
has comment: http://stackoverflow.com/comment/32747186

http://stackoverflow.com/comment/32614527
score: 0
has text: sounds promising, can you draft an example?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21588821

http://stackoverflow.com/q/21541183
downvote count: 5
has title: How to return data to a function?
answer count: 1
has comment: http://stackoverflow.com/comment/32530455
has answer: http://stackoverflow.com/a/21541421
has comment: http://stackoverflow.com/comment/32529798
favorite count: 0
score: -4
has comment: http://stackoverflow.com/comment/32530061
upvote count: 1
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32530490
tagged with: java
accepted answer: http://stackoverflow.com/a/21541421
type: Question
has comment: http://stackoverflow.com/comment/32529990
has body: Let's say I have the following code: MyFunction1(){ DoSomething (Value1); } MyFunction2(){ DoSomething(Value2); } DoSomething(int Amount) { int i = Amount; if (i &gt; 1) { i=0; } if (i&gt;2) { i=1; } if (i&gt;=3){ i = 2; } etc ... // how do I say i = Value; if I want to reuse this function to send Value1, Value2, Value3?? } How can I reuse to function to send this back to the calling function?

http://stackoverflow.com/a/21574728
has body: Here's a query that shows the level in vessel 2 between 5 and 26 seconds: select times.time_abs , sum( case when x1 = 'vessel2' and ([end] = 1 or times.time_abs = tt.time_abs) then r_m else 0 end - case when x0 = 'vessel2' and ([end] = 1 or times.time_abs = tt.time_abs) then r_m else 0 end ) as lvl from ( select distinct time_abs from testtable where time_abs between 5 and 26 ) times join testtable tt on tt.time_abs &lt;= times.time_abs and 'vessel2' in (tt.x0, tt.x1) group by times.time_abs To just display the maximum, you can: select max(lvl) from ( ...query from above... ) as SubQueryAlias Live example at SQL Fiddle.
answers question: http://stackoverflow.com/q/21573706
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32768307
accepted answer of: http://stackoverflow.com/q/21573706
has comment: http://stackoverflow.com/comment/32627841
type: Answer
has comment: http://stackoverflow.com/comment/32763107
has comment: http://stackoverflow.com/comment/32711562
has comment: http://stackoverflow.com/comment/32638999
has comment: http://stackoverflow.com/comment/32595795
score: 1
has comment: http://stackoverflow.com/comment/32600969
downvote count: 0
has comment: http://stackoverflow.com/comment/32810353

http://stackoverflow.com/comment/32571325
has text: Remember SimpleDateFormat construction is expensive, many had performance issue with it. And secondly it is not Thread Safe so use wisely! in your case I would go with DatePicker if UI allow.
score: 0
type: Comment
comment on: http://stackoverflow.com/q/21564389
type: QuestionComment

http://stackoverflow.com/comment/32697711
has text: Sorry, didn't notice the Log4j 2 requirement initially. Expanded answer.
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21633910

http://stackoverflow.com/a/21573049
score: 0
has comment: http://stackoverflow.com/comment/32586511
answers question: http://stackoverflow.com/q/21570517
type: Answer
has body: @gvmani: I think you are referring to an implementation similar to the one I have done below:- HashMap &lt;String,String&gt; mapBook = booksList.get(position); String strTitle = mapBook.get(KEY_TITLE); String strAuthor = mapBook.get(KEY_AUTHOR); Intent intent = new Intent(ListView.this,editList.class); intent.putExtra("title", strTitle); intent.putExtra("author", strAuthor); startActivity(intent);

http://stackoverflow.com/comment/32559155
comment on: http://stackoverflow.com/q/21557917
score: 0
has text: Why shouldn't you ever run a program with a compiler error?
type: QuestionComment
type: Comment

http://stackoverflow.com/q/21549105
upvote count: 1
has comment: http://stackoverflow.com/comment/32550090
answer count: 1
has comment: http://stackoverflow.com/comment/32550035
favorite count: 0
has title: JfreeChart not displaying before a click
has comment: http://stackoverflow.com/comment/32542656
type: UnansweredQuestion
downvote count: 0
has body: I have built an display a TabPanel. At this stage no Chart is displayed .When I click on a button, I build a new chart an add it to the panel. But nothing happens. I have to click on the panel to have the chart displayed at last. So I put a repaint() on the TabPanel which contains the ChartPanel but with no effect. Am I missing something here ? if(myChart==null){ myChart = new PortfolioChart(portfolioModel.getDataMatrix()); add(myChart.createPanel(), BorderLayout.CENTER); repaint(); }else{ myChart.setPortfolio(portfolioModel.getDataMatrix()); myChart.updateDataSet(); } May be I should put the repaint() instruction on something differrent ?
has comment: http://stackoverflow.com/comment/32544538
score: 1
tagged with: java
linked to: http://stackoverflow.com/q/15707496
tagged with: jfreechart
type: Question
has answer: http://stackoverflow.com/a/21552723

http://stackoverflow.com/q/21654342
has body: So I've recently learned exception handling for Java and I'm still trying to get used to it and all but I feel like I'm missing something. I was doing an assignment for my class and the compiler doesn't like my code. I'm supposed to be making a Calculator that takes in an operator and then a number, and if the operator (+, -, *, /) given is not one of the aforementioned four, then an exception is thrown. I used try-catch but for some reason the try and catch aren't recognizing each other unless I place them next to each other which isn't really what I want. My question is really: Is there a way for my try and catch to recognize each other without being right next to each other, so I can run code in-between them? Or is that impossible and I'm doing it all wrong? Here's my code so far: import java.util.*; public class Calculator { public static void main(String[] args) { String operatorInput; double numberInput; String userRedo = "Y"; double result = 0.0; Scanner input = new Scanner(System.in); System.out.println("Type in an arithmetic operator of your choice and press enter."); System.out.println("Then, please type in a number that will undergo the operation."); while((userRedo.toUpperCase()).compareTo("Y")==0) { try { operatorInput = input.nextLine(); if(operatorInput.compareTo("+")!=0||operatorInput.compareTo("-")!=0|| operatorInput.compareTo("*")!=0||operatorInput.compareTo("/")!=0) { throw new UnknownOperatorException("Unknown operator!"); } } numberInput = input.nextDouble(); if(operatorInput.compareTo("+")==0) { result += numberInput; } else if(operatorInput.compareTo("-")==0) { result -= numberInput; } else if(operatorInput.compareTo("*")==0) { result = result * numberInput; } else { result = result / numberInput; } System.out.println("\nresult "+operatorInput+" "+numberInput+"= "); System.out.println("Updated result: "+result); System.out.println("Again? (y/n)"); userRedo = input.nextLine(); catch(UnknownOperatorException e) { System.out.println(e.getMessage(…
has comment: http://stackoverflow.com/comment/32728374
has comment: http://stackoverflow.com/comment/32728406
has answer: http://stackoverflow.com/a/21654455
has answer: http://stackoverflow.com/a/21654560
type: Question
has answer: http://stackoverflow.com/a/21654384
tagged with: java
score: 0
has title: Java Exception Handling Assignment
tagged with: exception
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32728823
answer count: 4
has answer: http://stackoverflow.com/a/66926228

http://stackoverflow.com/comment/32747727
comment on: http://stackoverflow.com/a/21664996
type: Comment
has text: Ohhh, sorry I absolutely did not see the `T(position.add(offset), shape);` inside the method
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32568658
has text: I downvoted this answer for the same reasoning as for chrylis's answer - see the comments under it.
type: AnswerComment
comment on: http://stackoverflow.com/a/21563013
score: 0
type: Comment

http://stackoverflow.com/comment/32629966
has text: Use cron + script. Don't use java - it's the wrong tool.
score: 0
comment on: http://stackoverflow.com/q/21597416
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32645292
type: QuestionComment
has text: I know how to open a webpage, I want to know if its possible to add text onto this webpage via a String from my java program
comment on: http://stackoverflow.com/q/21607000
score: 0
type: Comment

http://stackoverflow.com/q/21551318
tagged with: android
has title: How to extend EditText/AutoCompleteTextView to show the last 'n' inputs?
has comment: http://stackoverflow.com/comment/32555091
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/2126717
tagged with: android-edittext
has answer: http://stackoverflow.com/a/21556753
linked to: http://stackoverflow.com/q/3200551
tagged with: java
has comment: http://stackoverflow.com/comment/32554857
type: Question
tagged with: autocomplete
answer count: 1
has body: I want to show a list of the last 'n' entries when the user taps on a text input. How can I do it? Right now I am extending EditText, incorporating the 'x' button to clear its content. So, my idea is incorporate this functionality to this widget
has comment: http://stackoverflow.com/comment/32546888
score: 0

http://stackoverflow.com/comment/32748692
comment on: http://stackoverflow.com/a/21653918
type: AnswerComment
has text: I´m confuse, because when I make this command `Folder folder = store.getFolder(senderAndMessages.getKey());`, got the folder destionation. So I move to them...Could show me what would be the correct way? My arraylist of messages are located in the inbox folder.
score: 0
type: Comment

http://stackoverflow.com/a/21596008
has comment: http://stackoverflow.com/comment/32626713
type: Answer
has body: Please check if you are using ADT version 17. If yes, see if the link below helps: http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17
has comment: http://stackoverflow.com/comment/32627819
answers question: http://stackoverflow.com/q/21595745
score: 0

output
tags question: http://stackoverflow.com/q/21602441
tag name: output
tags question: http://stackoverflow.com/q/21518177
tags question: http://stackoverflow.com/q/21640759
type: Tag
tags question: http://stackoverflow.com/q/21652483

http://stackoverflow.com/a/21659661
score: 1
answers question: http://stackoverflow.com/q/21658033
has body: String outString = new String(b); will not work. If you must treat cipher as a string then you have to encode it. You can use the printBase64Binary and parseBase64Binary methods in standard Java to convert to and from base64 strings. If you're on Android, you can instead use the android.util.Base64 class. Also, your encryptor's use of Cipher.doFinal(...) is a little suspicious to say the least. By treating each input as separate plaintext sequence you end up reusing the IV each time. Normally you want to encrypt each input piece with the Cipher.update(...) method, use doFinal(...) when you are all finished.
type: Answer
upvote count: 1
accepted answer of: http://stackoverflow.com/q/21658033
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/21539323
tagged with: swing
has body: I have a method that displays a DirectoryDialog. But I call it within a JFrame. When I call the method below, it opens up a "Shell", which is basically like another window, and then pops up the DirectoryDialog. How do I get rid of this JFrame-like shell. I already have a JFrame, and I want the JFrame to be the parent, not some random shell that I need to create additionally. In other words, I need to get rid of the additional window that pops up when I call this method. public File[] fileDialog(boolean folder){ if(folder){ Display display = new Display(); Shell shell = new Shell(display); shell.open(); DirectoryDialog dialog = new DirectoryDialog(shell); dialog.setFilterPath("C:\\"); // Windows specific String file = dialog.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); if(file == null) return new File[0]; else if(file.length() == 0) return new File[1]; else{ File[] files = new File[1]; files[0] = new File(file); return files; } } }
answer count: 0
tagged with: java
has title: DirectoryDialog hide shell in java
type: Question
tagged with: filedialog
has comment: http://stackoverflow.com/comment/32526539
score: 0
has comment: http://stackoverflow.com/comment/32526485
tagged with: shell
has comment: http://stackoverflow.com/comment/32529047
type: UnansweredQuestion

http://stackoverflow.com/a/21573253
score: 17
upvote count: 17
has comment: http://stackoverflow.com/comment/63821654
has comment: http://stackoverflow.com/comment/32600049
accepted answer of: http://stackoverflow.com/q/21561298
has body: I am trying to make something Like: this (Having bold and normal text on the same line). I've been using streams: The preferable way for creating bold (or otherwise styled) text is to use a font variant which has been created explicitly for that variant. If no such font is available, though, it is possible to artificially emulate those styles: artificially bold: use text rendering mode 2 to not only fill the letter area but also draw a line along its outline artificially outlined: use text rendering mode 1 to draw a line along the outline of the letter instead of filling it artificially italic (actually slanted: change the text matrix to skew the output. In code: PDRectangle rec = new PDRectangle(220, 120); PDDocument document = null; document = new PDDocument(); PDPage page = new PDPage(rec); document.addPage(page); PDPageContentStream content = new PDPageContentStream(document, page, true, true); content.beginText(); content.moveTextPositionByAmount(7, 105); content.setFont(PDType1Font.HELVETICA, 12); content.drawString("Normal text and "); content.setFont(PDType1Font.HELVETICA_BOLD, 12); content.drawString("bold text"); content.moveTextPositionByAmount(0, -25); content.setFont(PDType1Font.HELVETICA_OBLIQUE, 12); content.drawString("Italic text and "); content.setFont(PDType1Font.HELVETICA_BOLD_OBLIQUE, 12); content.drawString("bold italic text"); content.endText(); content.setLineWidth(.5f); content.beginText(); content.moveTextPositionByAmount(7, 55); content.setFont(PDType1Font.HELVETICA, 12); content.drawString("Normal text and "); content.appendRawCommands("2 Tr\n"); content.drawString("artificially bold text"); content.appendRawCommands("0 Tr\n"); content.moveTextPositionByAmount(0, -25); content.appendRawCommands("1 Tr\n"); content.drawString("Artificially outlined text"); content.appendRawCommands("0 Tr\n"); content.setTextMatrix(1, 0, .2f, 1, 7, 5); content.drawString("Artificially italic text and "); content.appendRawCommands("2 Tr\n"); content.drawStrin…
has comment: http://stackoverflow.com/comment/63822727
answers question: http://stackoverflow.com/q/21561298
has comment: http://stackoverflow.com/comment/63830218
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/63848273
has comment: http://stackoverflow.com/comment/63803605
type: Answer
has comment: http://stackoverflow.com/comment/32656640
has comment: http://stackoverflow.com/comment/63817750
has comment: http://stackoverflow.com/comment/32654095
has comment: http://stackoverflow.com/comment/63831177
has comment: http://stackoverflow.com/comment/63822283

http://stackoverflow.com/q/21515195
has body: I have the following JSON: [ { "id": 3589954, "type": "e", "pos": 1 }, { "id": 3837014, "type": "p", "pos": 2 } ] and the following Java Class: public class Business { private int idBusiness; private String type; private int pos; public Business(int idBusiness, String type, int pos) { this.idBusiness = idBusiness; this.type = type; this.pos = pos; } // getters &amp; setters ......... } and I am trying to read it as: businessList = mapper.readValue(strBusinessIDArrayJSON, new TypeReference&lt;List&lt;Business&gt;&gt;(){}); I am not able to read the JSON - I get businessList = null after the call. What is the correct way to do this.
tagged with: java
tagged with: http://stackoverflow.com/tag/json
possible better answer: http://stackoverflow.com/a/21515258
has answer: http://stackoverflow.com/a/21515258
type: AnsweredQuestion
has title: Jackson Array of Objects
tagged with: jackson
has answer: http://stackoverflow.com/a/21515241
type: Question
score: 0
answer count: 2
accepted answer: http://stackoverflow.com/a/21515241

http://stackoverflow.com/comment/32738698
comment on: http://stackoverflow.com/q/21660132
type: Comment
type: QuestionComment
has text: You code seems to have little to _no_ code relevent event programming, and this _does_ seem to be a event driven problem. All I see is an empty `actionPerformed` and another `actionPerformed` with an instantiation of a class that does not exist in your code. How are we supposed to deduce _anything_ from this? It's already bad enough your question is unclear. You need to **hand code** [**a Minimal, Complete, Tested and Readable example**](http://stackoverflow.com/help/mcve) so we can test it out, and do better job at explaining your problem.
score: 1

http://stackoverflow.com/comment/32746602
comment on: http://stackoverflow.com/a/21664503
score: 1
has text: If you code only in java, they might not have any value, but if you program in more than one language, in which there is a difference, yoda checks are quite important and quickly become a habit. Even more I find them more readable :)
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32695638
comment on: http://stackoverflow.com/a/21635486
score: 0
type: AnswerComment
type: Comment
has text: Thank you. Some further questions: How do i actually recieve / Send the messages? in the run method? if so, how do we separate the two run methods?

http://stackoverflow.com/comment/32553654
has text: PermGen is not the same thing as heap space. If you're exhausting the PermGen space, then you must be loading lots of libraries, or you have too many static variables.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21554848

http://stackoverflow.com/a/21648247
has comment: http://stackoverflow.com/comment/32717896
answers question: http://stackoverflow.com/q/21648079
has comment: http://stackoverflow.com/comment/32719134
score: 3
accepted answer of: http://stackoverflow.com/q/21648079
has body: First of all, you should pass a Class&lt;T&gt;, and not a Class&lt;T[]&gt;. That method will create an array T[][]. So, change your constructor to: public ArrayLists (Class &lt;T&gt; a) { array = (T[])Array.newInstance(a, DEFAULT_SIZE); } And pass String.class instead of String[].class. Now, the issue that you are having can be solved by using Class#getComponentType() method. That will get you the component type Class&lt;T&gt; of the array: // Why the type of tempSize is double? It should be `int` public void resize (int tempSize) { //create the temp array of size tempSize T[] temp = (T[]) Array.newInstance(array.getClass().getComponentType(), tempSize); System.arraycopy(array, 0, temp, 0, tempSize); array = temp; }
has comment: http://stackoverflow.com/comment/32719180
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32719076
has comment: http://stackoverflow.com/comment/32719450
type: Answer
has comment: http://stackoverflow.com/comment/32719269
upvote count: 3
has comment: http://stackoverflow.com/comment/32719118

http://stackoverflow.com/a/21653309
has body: Seems like this is a bug with the emulator, I've tried the exact same code with the Genymotion emulator and everything works perfectly. Haven't figured out how to fix it in the regular emulator except by not calling invalidate() more than once every 50 milliseconds or so.
has comment: http://stackoverflow.com/comment/47635505
answers question: http://stackoverflow.com/q/21566269
score: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21566269
type: Answer

http://stackoverflow.com/comment/32756265
type: QuestionComment
has text: Arraylist contains discrete elements, you don't "split" it, it is already "splitted". Just use `get()` with an index.
comment on: http://stackoverflow.com/q/21670258
score: 1
type: Comment

http://stackoverflow.com/a/21645317
answers question: http://stackoverflow.com/q/21645246
score: 0
type: Answer
has body: It means that instead of serving static html pages i.e. pages that are plain files in your disk and served to clients per request and the clients all view the same page, with servlets you can build pages at run time making customization and passing parameters as needed so clients see a different page

http://stackoverflow.com/comment/32666871
comment on: http://stackoverflow.com/a/21618327
has text: I tried using an Executor service and am still getting an issue. I updated the questions that shows the new source code an stack trace.
score: 0
type: Comment
type: AnswerComment

performance
tags question: http://stackoverflow.com/q/21635545
tags question: http://stackoverflow.com/q/21634411
tags question: http://stackoverflow.com/q/21530679
tags question: http://stackoverflow.com/q/21638330
tags question: http://stackoverflow.com/q/21541446
tags question: http://stackoverflow.com/q/21645849
tags question: http://stackoverflow.com/q/21555040
tags question: http://stackoverflow.com/q/21657454
tags question: http://stackoverflow.com/q/21657730
tags question: http://stackoverflow.com/q/21671725
tags question: http://stackoverflow.com/q/21565138
tags question: http://stackoverflow.com/q/21639405
tags question: http://stackoverflow.com/q/21571479
tags question: http://stackoverflow.com/q/21615780
tags question: http://stackoverflow.com/q/21672673
tags question: http://stackoverflow.com/q/21598558
tags question: http://stackoverflow.com/q/21594831
tags question: http://stackoverflow.com/q/21608646
tags question: http://stackoverflow.com/q/21569662
tags question: http://stackoverflow.com/q/21635989
tags question: http://stackoverflow.com/q/21625057
tags question: http://stackoverflow.com/q/21567248
tags question: http://stackoverflow.com/q/21572198
tags question: http://stackoverflow.com/q/21613746
tags question: http://stackoverflow.com/q/21539819
tags question: http://stackoverflow.com/q/21671791
tags question: http://stackoverflow.com/q/21519250
tags question: http://stackoverflow.com/q/21671993
tags question: http://stackoverflow.com/q/21568851
tags question: http://stackoverflow.com/q/21647988
tags question: http://stackoverflow.com/q/21519149
tags question: http://stackoverflow.com/q/21565552
tag name: performance
tags question: http://stackoverflow.com/q/21675709
type: Tag
tags question: http://stackoverflow.com/q/21549135
tags question: http://stackoverflow.com/q/21589159
tags question: http://stackoverflow.com/q/21613098
tags question: http://stackoverflow.com/q/21628265
tags question: http://stackoverflow.com/q/21608240
tags question: http://stackoverflow.com/q/21622911
tags question: http://stackoverflow.com/q/21555711
tags question: http://stackoverflow.com/q/21546961
tags question: http://stackoverflow.com/q/21583395

http://stackoverflow.com/q/21662618
has answer: http://stackoverflow.com/a/21662671
has comment: http://stackoverflow.com/comment/32742667
has body: I am trying to create a linked list implementation using inner class package linkedlist; public class linkedList { public class Node { int data; public Node next; public Node(int k) { this.data = k; this.next=null; } public Node addToHead(int data) { Node node = new Node(data); Node current = this; node.next=current; return node; } } public static void findn(Node head) { Node previous=head; Node current = head; int i =1; while(current!=null) { if (i==6) { //System.out.println(current.data); previous.next = current.next; break; } previous=current; current = current.next; i++; } } public static void main(String args[]) { linkedList list = new linkedList(); linkedList.Node tail = linkedList.new Node(0); // list.Node tail = list.Node(0); Node head = tail; for (int i=1;i&lt;=20;i++) { head = head.addToHead(i); } findn(head); while(head!=null) { System.out.println(head.data); head = head.next; } } } My question here in the main function i am trying to create a node using the outer class. But the syntax is throwing me an error even though i am following the right syntax. I want to know what is wrong with this statement "linkedList.Node tail = linkedList.new Node(0);"
has comment: http://stackoverflow.com/comment/32743390
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32742607
has comment: http://stackoverflow.com/comment/32742871
type: Question
has title: Inner Class vs Static Inner Class
tagged with: java
has answer: http://stackoverflow.com/a/21662682
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/32742623

http://stackoverflow.com/q/21548072
has title: RMI Communication between different JVM
has answer: http://stackoverflow.com/a/21548170
has body: We have written an RMI client application in Java 1.5 and same was integrated with a RMI server having java version 1.5. Now my server is updated to Java 1.7 but I want to use the same RMI client application which was compiled in Java 1.5 to integrate with new server? On the new server the stubs are not changed/updated but they have just complied in Java 1.7. OS: Sun-Solaris 10 Is it possible? Or is there any workaround to achieve this? Thanks in advance.
type: UnansweredQuestion
tagged with: rmi
tagged with: java
type: Question
score: 0
answer count: 1

http://stackoverflow.com/q/21610806
tagged with: eclipse-kepler
accepted answer: http://stackoverflow.com/a/21611228
type: AnsweredQuestion
score: 1
tagged with: java
has body: I'm pointing to the workbench's Save command using a menu command, because I want to change the icon and force the text underneath it. Icon works fine, but the text won't show (it should say Save below the icon, because I set the mode to FORCE_TEXT and have a label present). Is it a bug, or a limitation of the framework?
type: Question
answer count: 1
downvote count: 0
has title: Eclipse RCP CoolBar Action FORCE_TEXT
tagged with: eclipse-rcp
has answer: http://stackoverflow.com/a/21611228
favorite count: 0
tagged with: swt
upvote count: 1

http://stackoverflow.com/a/21979123
downvote count: 0
has comment: http://stackoverflow.com/comment/33311468
answers question: http://stackoverflow.com/q/21631510
upvote count: 2
has body: I'm sorry to hear that webstorage api has an issue on Android, because I will be using this in next few days. As you have investigated already, Android 4.4 uses a brandnew WebView which is based on the ChromeBrowser where lot of web technology such as webScoket etc other than localStorage api are already supported well. Having said that, reading your post claims localStorage api has an issue for android4.0-4.2 (which I also aim as target devices), I thought using FileSystem api instead. http://www.html5rocks.com/en/tutorials/file/filesystem/ However, looking at web, it is so uncertain if this api works well, and finally I found this. Using local storage on Android webview https://github.com/didimoo/AndroidLocalStorage
type: Answer
score: 2

http://stackoverflow.com/q/21525773
favorite count: 0
has comment: http://stackoverflow.com/comment/32726053
upvote count: 2
tagged with: smartcard
has answer: http://stackoverflow.com/a/21532208
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21532208
score: 1
tagged with: java
downvote count: 1
type: Question
tagged with: javacard
has body: I am new to Java Card development but until now I am using the Java Card development kit 2.2 and doing the Samples. I try to understand how can I actually use the java card Applets. For example I have the classic "Wallet" applet that is a wallet application managing credit and also debit operations on the Card. I use the jcwde tool to run the applets on the emulator. The APDU tool is sending apdu messages to the card and the card responds. Now my question is on practice how can I use this card? The apdu istructions that the terminal should send are predefined according to the methods the applet implements. The device that the customer should plug the card how should interact to the card? For example we don't expect the customers to send APDU commands. Is there a device with a screen that should be programmed too? The wallet application is similar to: working with Java Card Wallet The person question here is using the same approach. Testing the applet using apdu messages. Is this the way we should test our cards?
has title: Java Card Reader Terminal
linked to: http://stackoverflow.com/q/21284830
answer count: 1

http://stackoverflow.com/q/21562794
answer count: 1
downvote count: 0
has body: I'm a novice when it comes to Java programming. Hopefully you can provide me with an answer that can be implemented without too much difficulty. I'm writing a code that keeps track of how much money two persons are spending together. I'm using a text file as a database and I've managed to read the file properly. I have a main JFrame to which I add a JTabbedPane containing two JPanels. The JPanels are created with two separated methods that I have written in two individual classes. One panel has two JTextFileds in which the persons can write the amount spent after a purchase. The other JPanel is displaying the history and has a reset button that deletes all the data in the text file. I've added a KeyListener to the JTextFields and an ActionListener to the JButton. Each Listener is written in separated classes. Everything works just fine except the repainting of the main Frame. Now, I need to reopen the program to see the changes. I want to be able to repaint the main JFrame within the Listeners but I can't make it work. This is the main Frame: public class Frame extends JFrame { static JTabbedPane tabs = new JTabbedPane(); static JFrame frame = new JFrame("Reimbursment Control"); public Frame() throws FileNotFoundException { JPanel c = ControlTab.getControlTab(); JPanel h = HistoryTab.getHistoryTab(); JTabbedPane tabs = new JTabbedPane(); tabs.addTab("Overview", c); tabs.addTab("History", h); frame.getContentPane().add(tabs); //... This is how I add the Listeners to the JTextFields and JButton: ButtonClicked.addActionListener(button); KeyPressed.addKeyListener(textfield); These are the classes containing the Listener methods called upon above: public class ButtonClicked { public static void addActionListener(JButton button) { button.addActionListener (new ActionListener() { public void actionPerformed(ActionEvent click) { //Here's code that deletes all the data in the file //and it should be displayed right away but I don't //know how to update the main JFrame from h…
favorite count: 0
type: UnansweredQuestion
upvote count: 1
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32567428
has title: Can't update my main JFrame from Key/Action Listeners in other classes
type: Question
has comment: http://stackoverflow.com/comment/32567603
has answer: http://stackoverflow.com/a/21562953
has comment: http://stackoverflow.com/comment/32567358

http://stackoverflow.com/comment/32760856
type: Comment
type: AnswerComment
has text: What when we don't know the key !!? EDIT: Also, not a copy !!
comment on: http://stackoverflow.com/a/21672982
score: 0

http://stackoverflow.com/q/21667712
has title: De-serializing an object to class object
score: 0
tagged with: udp
answer count: 1
tagged with: serialization
has body: I'm working on a Token Ring network implementation, I'm trying to passing a token frame from the station to the ring using a DatagramPacket. I convert the frame object to a byte array using this: public static byte[] serialize(Object obj) throws IOException { ByteArrayOutputStream b = new ByteArrayOutputStream(); ObjectOutputStream o = new ObjectOutputStream(b); o.writeObject(obj); return b.toByteArray(); } and then converting it back using this: public static Object deserialize(byte[] bytes) throws IOException, ClassNotFoundException { ByteArrayInputStream b = new ByteArrayInputStream(bytes); ObjectInputStream o = new ObjectInputStream(b); return o.readObject(); } Each station is running two threads. public void go() { t.println("Sending to: " + main_host_address); t.println("Station Address: " + station_address); t.println("MAC Address: " + MAC_Address); DatagramSocket socket; InetSocketAddress saddr; try { saddr= new InetSocketAddress("localhost", main_host_address); socket= new DatagramSocket(station_address); // Create a socket and a datagram from the buffer data (new Thread(new receivingThread(socket))).start(); // start threads for receiving and sending (new Thread(new sendingThread(socket, saddr, frame))).start(); }catch(Exception e) { e.printStackTrace(); } } ..and they all receive from one address - the ring. Now in the Ring class, I'm trying to convert the byte array but it doesn't do anything, I'm running a while loop but it doesnt loop around once it tries to convert a byte array to a the Frame object. public void run() { byte [] buffer; DatagramPacket packet; //Receive the packet try{ buffer = new byte[5]; int i = 0; packet = new DatagramPacket(buffer, buffer.length); int recievedData = 0; while(true){ t.println("Recieving...."); socket.receive(packet); Thread.sleep(2000); recievedData = packet.getData()[0]; t.println("Reciever: " + recievedData); //here I'm trying a different way of getting the byte array //Before, I had; byte [] data = packet.getData…
type: UnansweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/21668010
type: Question
tagged with: network-programming

http://stackoverflow.com/q/21674120
has comment: http://stackoverflow.com/comment/32764565
tagged with: android
has title: I can't use the custom class after importing the jar file into the eclipse project
tagged with: java
has answer: http://stackoverflow.com/a/21674425
type: Question
has comment: http://stackoverflow.com/comment/32762719
tagged with: eclipse
score: 0
has body: I made a custom class. I wrote the class code and put it into mycustomclass.class. I put the .class file into a Winrar archive and then renamed the archive to mycustomclass.jar. this is the code i am just testing out to see how importing custom classes work. public class mycustomclass { int weight; int height; public int calculatebmi(int weight, int height){ int bmi = ((weight+height)*(weight+height))/(height*height); return bmi; } } the file structure is like this for this jar file: mycustomclass.jar&gt;mycustomclass.class(inside the jar file) I then added the jar file into the project by clicking on the "add external jar file" under java build path. I also checked the checkbox next to the jar file name in the order and export list of the java build path properites. When I goto add the class to the mainactivity.java file like this: import mycustomclass; it says mycustomclass cannot be resolved the jar file is under the referenced libraries folder and the mycustomclass.class file is under the "default package" like this: Refereneced Libraries&gt;default package&gt;mycustomclass.class I thought the custom class file has to be in a package heierarchy so I created a folder in the jar file called mycustomclassfolder and put the mycustomclass.class file in there. mycustomclass.jar&gt;mycustomclassfolder&gt;mycustomclass.class I then did this. import mycustomclassfolder.mycustomclass; error message: mycustomclassfolder.mycustomclass cannot be resolved this is how it is listed in the project files list: mycustomclass.jar&gt;mycustomclassfolder&gt;mycustomclass.class What do I have to do in addition to importing the files into the project so I can use the class in to the mainactivity.java file with import ... keyword? thanks.
answer count: 1
tagged with: jar
type: UnansweredQuestion

http://stackoverflow.com/comment/32655260
score: 0
type: AnswerComment
has text: Yes it works, thanks ever so much. I did go down the route of trying to convert it into ints but i wasn't quite sure how.
type: Comment
comment on: http://stackoverflow.com/a/21612578

http://stackoverflow.com/q/21614400
tagged with: java
tagged with: jpanel
possible better answer: http://stackoverflow.com/a/21614936
type: Question
has comment: http://stackoverflow.com/comment/32659643
has body: I've been trying to get the Graphics2d object to work without success. I've searched for an answer on both the Oracle tutorial site and Stackoverflow without finding an answer. The problem I have is that when I call the methods lineTo, fill, and drawRect, I get a blank grey square in my window, instead of the shapes that I want. package main; import java.awt.Canvas; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.GeneralPath; import java.awt.image.BufferedImage; import javax.swing.JFrame; import javax.swing.JPanel; public class GraphicsTesting extends JPanel { private static final long serialVersionUID = 6096199371167913312L; static BufferedImage buffImag = new BufferedImage(500, 500, BufferedImage.TYPE_INT_ARGB); static Graphics2D graff = buffImag.createGraphics(); Point2D.Double point = new Point2D.Double(10, 10); static Graphics gra = buffImag.createGraphics(); public void paint(Graphics g){ Graphics2D g2 = (Graphics2D) g; GeneralPath gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 4); gp.moveTo(30, 55); gp.lineTo(168, 384); gp.lineTo(462, 81); gp.lineTo(321, 423); gp.lineTo(269, 243); g2.setColor(new Color(112, 150, 134)); g2.fill(gp); g2.setColor(new Color(56, 112, 232)); g2.draw(gp); g2.setColor(new Color(152, 1, 210)); g2.drawRect(25, 152, 380, 405); g2.drawImage(buffImag, 0, 0, 500, 0, 0, 500, 500, 500, null); } public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(500,500); frame.setVisible(true); GraphicsTesting gT = new GraphicsTesting(); frame.setContentPane(gT); gT.paint(gra); } }
has comment: http://stackoverflow.com/comment/32705987
answer count: 2
has answer: http://stackoverflow.com/a/21614936
has comment: http://stackoverflow.com/comment/32659254
score: 0
tagged with: graphics2d
has answer: http://stackoverflow.com/a/21615129
accepted answer: http://stackoverflow.com/a/21615129
tagged with: swing
has title: Graphics2d methods produce no output
type: AnsweredQuestion

http://stackoverflow.com/comment/32661736
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21614832
has text: It looks like the logcat is pointing to cmd.setSuccess(tempVal); (line 47 in SAXXMLHandler) as the source of the crash (after making that change) http://pastebin.com/VPHjE6j3

http://stackoverflow.com/q/21628386
answer count: 1
has title: How to properly extract simple try/catch blocks that load resources in java?
has comment: http://stackoverflow.com/comment/32682340
has body: Currently there is a method that loads an image from an URL and then processes it like follows: BufferedImage tempImage; try { tempImage = ImageIO.read(url); } catch (IOException e) { return; } final BufferedImage image = tempImage; To clean the code up a bit, I would like to extract the try/catch block while preserving the functionality of exiting the method if the loading of the image fails. I have tried extracting the block as follows: final BufferedImage image = loadImageFromURL(); if (image == null) return; //-------------------------------------- private BufferedImage loadImageFromURL() { BufferedImage tempImage = null; try { tempImage = ImageIO.read(url); } catch (IOException e) { LogUtils.severe(e); } return tempImage; } The problem is that if the loading of the image fails, the method returns null, which does not make the code any cleaner, as I have to perform an additional null check. I have read through Clean Code: A Handbook of Agile Software Craftsmanship but all the examples seem to rethrow the exception in some form: is that the only/correct way to go?
accepted answer: http://stackoverflow.com/a/21628477
tagged with: loading
type: AnsweredQuestion
tagged with: refactoring
tagged with: java
has answer: http://stackoverflow.com/a/21628477
type: Question
tagged with: try-catch
score: 0

http://stackoverflow.com/comment/32608976
score: 0
comment on: http://stackoverflow.com/a/21574763
type: Comment
has text: He isn't doing if else. If you notice the question is asking about a single if statement with multiple arguments. Suppose he was trying to say "If object is a bar-owner, or a barrista, or a shop owner, then slap them in the face." Your switch case will have 3 "slap them in the face" commands which is hardly more efficient.
type: AnswerComment

http://stackoverflow.com/q/21565060
tagged with: java
tagged with: local-variables
tagged with: methods
type: Question
has title: Why do I have to enter in data twice?
score: 0
has answer: http://stackoverflow.com/a/21565233
answer count: 2
has answer: http://stackoverflow.com/a/21565230
tagged with: console
type: UnansweredQuestion
has body: I'm writing this program that will let you enter in an amount for each quarters, dimes, nickels and pennies and return their amount in $. After that, I want to be able to add up the dollar amounts they produce without having to enter in all of the coin amounts a second time. Any ideas? Thanks in advance. import java.util.*; public class HalfDollar { public static final Scanner CONSOLE = new Scanner(System.in); public static void main(String[] args) { quarterDollarAmount( ); dimeDollarAmount( ); nickelDollarAmount( ); pennyDollarAmount( ); totalDollarAmount( ); } public static double quarterDollarAmount( ) { System.out.print("Enter the number of quarters: "); int quarterDollar = CONSOLE.nextInt( ); double amount = quarterDollar * 0.25; System.out.println(quarterDollar + " Quarter are $" + amount); return amount; } public static double dimeDollarAmount( ) { System.out.print("Enter the number of dimes: "); int dimeDollar = CONSOLE.nextInt( ); double amount = dimeDollar * 0.10; System.out.println(dimeDollar + " Dimes are $" + amount); return amount; } public static double nickelDollarAmount( ) { System.out.print("Enter the number of nickels: "); int nickelDollar = CONSOLE.nextInt( ); double amount = nickelDollar * 0.05; System.out.println(nickelDollar + " Nickels are $" + amount); return amount; } public static double pennyDollarAmount( ) { System.out.print("Enter the number of pennies: "); int pennyDollar = CONSOLE.nextInt( ); double amount = pennyDollar * 0.01; System.out.println(pennyDollar + " Pennies are $" + amount); return amount; } public static double totalDollarAmount( ) { double quarter = quarterDollarAmount(); double dime = dimeDollarAmount(); double nickel = nickelDollarAmount(); double penny = pennyDollarAmount(); double total = quarter + dime + nickel + penny; System.out.println("Total amount is $" + total); return total; } }

http://stackoverflow.com/a/21631300
downvote count: 0
score: 1
has body: step 1 : create a class , like a bean class having fields as the columns of the CSV step 2 : write getters and setters for when you need them step 3 : read all your files and store every row in an object of the bean class step 4 : create an arraylist of the bean class type and store all the bean objects i the arraylist step 5 : write a comparator method for your bean class and sort it the way you want it
upvote count: 1
answers question: http://stackoverflow.com/q/21630992
type: Answer

http://stackoverflow.com/a/21632250
upvote count: 1
has body: First check to see if it is enabled to automatically do it. Go to Preferences &gt; Java &gt; Editor &gt; Content Assist and make sure Enable auto activation is checked. If that doesn't fix anything, you can try to manually get it to show up by pressing CTRL + SPACE. You should also check Content Assist &gt; Advanced and make sure that at the very least Java Proposals is checked.
accepted answer of: http://stackoverflow.com/q/21632071
answers question: http://stackoverflow.com/q/21632071
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/32692087
score: 1

http://stackoverflow.com/comment/32598636
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/21580301
type: Comment
has text: There are several errors: 1) There is no method `currentTimeInMillis`. 2) Strings can't mathematically add a long number.

http://stackoverflow.com/comment/32532059
score: 1
has text: So . . . what is the solution?
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21542256

http://stackoverflow.com/q/21654221
has comment: http://stackoverflow.com/comment/32728841
has title: Remove from Queue
answer count: 0
has comment: http://stackoverflow.com/comment/32729366
tagged with: priority-queue
type: Question
has comment: http://stackoverflow.com/comment/32728096
has comment: http://stackoverflow.com/comment/32729739
has body: public E remove() { if(top!=null){ E item = top.data; top=top.next; return item; } return null; } Trying to remove Node from queue without using java.util. Am I on the right track?
score: 0
tagged with: java
tagged with: queue
type: UnansweredQuestion

http://stackoverflow.com/comment/32522568
score: 0
has text: @maaartinus The repetition count *is* configurable, and I am using a very low setting for experimenting. It is good to use greater values to confirm when posting, though.
comment on: http://stackoverflow.com/a/21525039
type: AnswerComment
type: Comment

http://stackoverflow.com/a/25525659
has body: You can create a Properties class. In that class you need to add a function with BeforeClass Annotation public class Properties { public static WebDriver driver; @BeforeClass(alwaysRun=true) public void LaunchBrowser() { driver = new FirefoxDriver(); } } Then you have to inherit properties class in your test classes public class Flipkart1 entends Properties {} public class Flipkart2 entends Properties {}
answers question: http://stackoverflow.com/q/21618449
score: 0
type: Answer

http://stackoverflow.com/comment/32593673
type: Comment
type: QuestionComment
has text: Have you looked at Java Native Access instead? It may be more suitable. Regarding what to wrap, it depends on the particulars, but usually you'd make the Java API a client of the C shared library (DLL) just like any other program that uses it.
comment on: http://stackoverflow.com/q/21577576
score: 0

http://stackoverflow.com/comment/32618154
has text: So it's a matrix of Strings and you want to format it to a String with 8 characters? So if it's shorter, you want it padded with space and if it's longer, it is truncated? Can you give an example of the input and the expected output you want?
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/21590855

http://stackoverflow.com/a/21786428
score: 0
has body: You may be interested in Spring Batch. I'd recommend reading through the introduction chapter of their documentation to get an overview of its features: http://docs.spring.io/spring-batch/reference/html/spring-batch-intro.html To summarize: In addition to scheduling jobs, it also covers other aspects such as logging job statistics, transaction management, retry-handling, and splitting up jobs into smaller batches for potentially better performance. It also covers your requirements of acting as a stand-alone framework for running your jobs, and its exception handling capabilities seem sophisticated.
type: Answer
answers question: http://stackoverflow.com/q/21641431

http://stackoverflow.com/q/21676143
has title: where do actual parameters in java store
tagged with: string
linked to: http://stackoverflow.com/q/4918399
linked to: http://stackoverflow.com/q/14150628
duplicate of: http://stackoverflow.com/q/14150628
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21676422
has answer: http://stackoverflow.com/a/21676426
tagged with: java
tagged with: memory
has comment: http://stackoverflow.com/comment/32766063
type: Question
has comment: http://stackoverflow.com/comment/32766080
score: 0
answer count: 3
has body: If I pass a String literal to some metohd as: String s=new String("stack"); String s2=s.concat("overflow"); where string "overflow" will be stored. one of my friends arguing that it is created in String constant pool and I'm opposing him. please let me know Thanks in advance.
has answer: http://stackoverflow.com/a/21676313

http://stackoverflow.com/a/21604060
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21602667
answers question: http://stackoverflow.com/q/21602667
score: 5
type: AcceptedAnswer
has body: If I understood your requirement correctly, you want to use HQL while having a consistent name for both DB column and the entity field, like this: SELECT t.test_id FROM Test t instead of SELECT t.testId FROM Test t There is only one way to do that - renaming the field to test_id. HQL works on entities, not on DB tables, so you must use proper field names in the query. Since test_id contradicts the usual Java coding conventions, I would advise against it. EDIT: Getting the annotation attribute value with reflection would work along this outline: Field field = MyEntity.class.getDeclaredField("testId"); Column a = field.getAnnotation(Column.class); String columnName = a.name();
upvote count: 5
has comment: http://stackoverflow.com/comment/32640649
type: Answer
has comment: http://stackoverflow.com/comment/32640820
has comment: http://stackoverflow.com/comment/32641620

http://stackoverflow.com/comment/32640037
score: 0
type: Comment
has text: As for the book: why are you asking me to do something illegal? I don't like people who ask me to break the law! I'm pretty sure my Publisher would sue me if I provided a download link. I've already given you a link to the sample chapter that is relevant.
type: AnswerComment
comment on: http://stackoverflow.com/a/21600731

http://stackoverflow.com/q/21614945
score: 0
has comment: http://stackoverflow.com/comment/32659993
has comment: http://stackoverflow.com/comment/32659942
answer count: 1
has title: ArrayList saved to textfile
tagged with: text-files
has comment: http://stackoverflow.com/comment/32660038
has comment: http://stackoverflow.com/comment/32659901
type: UnansweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/21615238
type: Question
has body: I want to save the contents of my arraylist to a textfile. What I have so far is shown below, however instead of adding x.format("%s%s", "100", "control1"); to the textfile, I want to add objects from an arraylist, how do I go about this? import java.util.*; public class createfile { ArrayList&lt;String&gt; control = new ArrayList&lt;String&gt;(); private Formatter x; public void openFile() { try { x = new Formatter("ControlLog.txt"); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error: Your file has not been created"); } } public void addRecords() { x.format("%s%s", "100", "control1"); } public void closeFile() { x.close(); } } public class complete { public static void main(String[] args) { createfile g = new createfile(); g.openFile(); g.addRecords(); g.closeFile(); } }
tagged with: arraylist

http://stackoverflow.com/a/21564091
score: 6
type: Answer
upvote count: 6
has comment: http://stackoverflow.com/comment/32569728
has comment: http://stackoverflow.com/comment/32569709
accepted answer of: http://stackoverflow.com/q/21564033
answers question: http://stackoverflow.com/q/21564033
has comment: http://stackoverflow.com/comment/32569773
type: AcceptedAnswer
downvote count: 0
has body: It are post-increment (§15.14.2) (++) and post-decrement (§15.14.3) (--) operations. These will change the values for the next iteration in your while loop. You basically have this: while (left &lt;= right) { // ... if (left &lt; right) { swap(array, left, right); left++; right--; } } As you can see, the "post" means that the values are not affected for that particular statement. After evaluating the post increment operation, it will the variable will be increased, but the value passed to the method was still the old one. For the advanced readers, you could write the post-increment operator like this (pseudo code): public int operator this++() { int temp = this; ++this; // regular pre-increment (JLS §15.15.1) return temp; } For a read about the pre-increment operator, you can check JLS §15.15.1.

http://stackoverflow.com/q/21544319
possible better answer: http://stackoverflow.com/a/21546935
tagged with: liferay-theme
has answer: http://stackoverflow.com/a/25802401
upvote count: 2
has answer: http://stackoverflow.com/a/21598211
accepted answer: http://stackoverflow.com/a/21598211
downvote count: 1
favorite count: 0
tagged with: multilingual
has answer: http://stackoverflow.com/a/21546935
tagged with: liferay-6
has body: I am creating theme using liferay 6.2. I need to add language support in my theme. For this I try to add language portlet by using $theme.language() in portal_normal.vm. By this portlet is added to theme but it did not work. Also I tried by $velocityPortletPreferences.setValue("portletSetupShowBorders","false") &lt;menu class="nav-horizontal" id="language-navigation"&gt; &lt;ul&gt; &lt;li&gt;$theme.runtime("82", "", $velocityPortletPreferences.toString())&lt;/li&gt; &lt;/ul&gt; &lt;/menu&gt; $velocityPortletPreferences.reset() Also I noticed that language portlet does not work for guest (unauthorized) user. The issue has been logged here. My requirement is whenever guest user comes to site he can change the language and accordingly Theme/site pages/admin/web content should change to the respective language. Can anyone suggest a workaround to develop this functionality?
answer count: 4
type: AnsweredQuestion
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32534624
type: Question
tagged with: liferay
has answer: http://stackoverflow.com/a/21552464
has title: Add language support in liferay theme

http://stackoverflow.com/q/21594981
tagged with: sql
has answer: http://stackoverflow.com/a/21595247
has answer: http://stackoverflow.com/a/21596127
has body: I have a need to form an SQL string for searching data. I have a very long list of variables such as: String id, String fName, String city, int custType, .... and my table in DB have all these columns (ID, Fname, LName, City...) I want to search data based on the info from provided variables, but only Non-Empty variables should be used in the SQL string. Ex1 if the variables are like the following: String id="22"; String fName=""; String LName="Tom"; String city=""; int custType=0; Then String sql="Select * from Customer "; String where=" where id=? and LName=?"; sql+=where; //then call DB Ex2 if the variables are like the following: String id=""; String fName=""; String LName="Tom"; String city="Ny"; String postcode="211"; Then String where=" where LName=? and city=? and postcode=?"; If there is only 1 variable that is not empty &amp; all others are empty then no need AND, ex String where=" where LName=?" I am thinking to put all varibles into a List, but some varibles have int type. I also don't know what is the best logics for forming string like that. Can you come up any good solution?
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21597144
tagged with: java
tagged with: mysql
type: Question
score: 0
answer count: 3
has title: Given a series of variables (A, B, C ...), How to form the Sql String Ex "A=? and B=?...." but only taking into account for Non-Empty variables?

http://stackoverflow.com/comment/32655117
score: 0
type: Comment
has text: Yes you are right how would i go about that part? Processing the strings in a list, when i store the values in list it looks like [a b c d 4, e f g h 2] i want it to read the a b c d 4 as one list and retrive the nth value and so on till there is no line
type: AnswerComment
comment on: http://stackoverflow.com/a/21612249

http://stackoverflow.com/a/21628403
has comment: http://stackoverflow.com/comment/32759116
has body: First you'll have to learn a lot about the internals of HotSpot, in particular the fact that your code is first interpreted, then at a certain point compiled into native code. A lot of optimizations happen while compiling, based on results of both static and dynamic analysis of your code. Specifically, in your code, String s = "test"; is a clear no-op. The compiler will emit no code whatsoever for this line. All that remains is the loop itself, and the whole loop may be eliminated if HotSpot proves it has no observable outside effects. Second, even the code String s = new String("test"); may result in almost the same thing as above because it is very easy to prove that your new String is an instance which cannot escape from the method where it is created. With your code, the measurements are mixing up the performance of interpreted bytecode, the delay it takes to compile the code and swap it in by On-Stack Replacement, and then the performance of the native code. Basically, the measurements you are making are measuring everything but the effect you have set out to measure. To make the arguments more solid, I have repeated the test with jmh: @OutputTimeUnit(TimeUnit.NANOSECONDS) @BenchmarkMode(Mode.AverageTime) @Warmup(iterations = 1, time = 1) @Measurement(iterations = 3, time = 1) @Threads(1) @Fork(2) public class Strings { static final int ITERS = 1_000; @GenerateMicroBenchmark public void literal() { for (int i = 0; i &lt; ITERS; i++) { String s = "test"; } } @GenerateMicroBenchmark public void newString() { for (int i = 0; i &lt; ITERS; i++) { String s = new String("test"); } } } and these are the results: Benchmark Mode Samples Mean Mean error Units literal avgt 6 0.625 0.023 ns/op newString avgt 6 43.778 3.283 ns/op You can see that the whole method body is eliminated in the case of the string literal, while with new String the loop remains, but nothing in it because the time per loop iteration is just 0.04 nanoseconds. Definitely no String instances are alloc…
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32682897
upvote count: 10
type: Answer
accepted answer of: http://stackoverflow.com/q/21628265
answers question: http://stackoverflow.com/q/21628265
has comment: http://stackoverflow.com/comment/32688983
score: 10
has comment: http://stackoverflow.com/comment/32682593

http://stackoverflow.com/a/21568203
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/21568109
has body: The most popular and fully featured python module is tweepy, available at https://github.com/tweepy/tweepy. I'd recommend it over the similar python-twitter module as tweepy has increased functionality, including increased oauth customization and the ability to edit user profiles. To get started, read its documentation. Here's some example code: # Posts a tweet from a user. import tweepy auth = tweepy.BasicAuthHandler('username', 'password') api = tweepy.API(auth) api.update_status('hello from tweepy!')
type: Answer
upvote count: 1

nullpointerexception
tags question: http://stackoverflow.com/q/21591867
tags question: http://stackoverflow.com/q/21528485
tags question: http://stackoverflow.com/q/21625214
tags question: http://stackoverflow.com/q/21520853
tags question: http://stackoverflow.com/q/21635386
tags question: http://stackoverflow.com/q/21596262
tags question: http://stackoverflow.com/q/21566605
tags question: http://stackoverflow.com/q/21626948
tags question: http://stackoverflow.com/q/21625138
tags question: http://stackoverflow.com/q/21561942
tags question: http://stackoverflow.com/q/21662433
tags question: http://stackoverflow.com/q/21554772
tags question: http://stackoverflow.com/q/21592790
type: Tag
tag name: nullpointerexception
tags question: http://stackoverflow.com/q/21648997
tags question: http://stackoverflow.com/q/21529341
tags question: http://stackoverflow.com/q/21528504
tags question: http://stackoverflow.com/q/21607443
tags question: http://stackoverflow.com/q/21600799
tags question: http://stackoverflow.com/q/21612393
tags question: http://stackoverflow.com/q/21663225
tags question: http://stackoverflow.com/q/21565882
tags question: http://stackoverflow.com/q/21610449
tags question: http://stackoverflow.com/q/21618882
tags question: http://stackoverflow.com/q/21668567
tags question: http://stackoverflow.com/q/21575370
tags question: http://stackoverflow.com/q/21562432
tags question: http://stackoverflow.com/q/21597477
tags question: http://stackoverflow.com/q/21592897
tags question: http://stackoverflow.com/q/21516020
tags question: http://stackoverflow.com/q/21654581
tags question: http://stackoverflow.com/q/21546128
tags question: http://stackoverflow.com/q/21633232
tags question: http://stackoverflow.com/q/21570785

http://stackoverflow.com/comment/32721163
has text: Please format this better.
comment on: http://stackoverflow.com/q/21650276
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21569158
answer count: 3
has body: I'm trying to make a time-sheet app for myself that I can use at work. I've pasted the code for my two classes below. My conundrum is not having to pass or keep data just how to go back to the original view if I've opened a canvas object. Is it possible to use an intent to open an activity rather than just creating the "tv" object (in openTEV method)? That would mean that when I tap the "back" button on the bottom right of my Galaxy phone it will stop that activity and go back to the first one with the EditText objects that I've entered strings into. At the moment hitting the back button ends the entire app. Or am I misunderstanding how android works? MainActivity.java - public class MainActivity extends Activity { private MyTouchEventView tv; private EditText et1; private EditText et2; private EditText et3; private EditText et4; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); et1 = (EditText) findViewById(R.id.editText1); et2 = (EditText) findViewById(R.id.editText2); et3 = (EditText) findViewById(R.id.editText3); et4 = (EditText) findViewById(R.id.editText4); } public void processForm(View v) { String txt = et1.getText().toString(); Toast.makeText(this.getApplicationContext(), txt, Toast.LENGTH_LONG).show(); } @Override protected void onPause() { super.onPause(); Log.i("TAG", "Paused"); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bar items switch (item.getItemId()) { case R.id.action_save: saveCanvasImage(); return true; case R.id.action_sign: openTEV(); return true; default: return super.onOptionsItemSelected(item); } } public void saveCanvasImage() { tv.setDrawingCacheEnabled(true); Bitmap bm = tv.getDrawingCache(); String fPath = Env…
favorite count: 0
tagged with: android
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21569669
score: 3
downvote count: 0
tagged with: java
has title: Object vs Android Activity
type: Question
has comment: http://stackoverflow.com/comment/32579546
possible better answer: http://stackoverflow.com/a/21569935
has answer: http://stackoverflow.com/a/21596481
has answer: http://stackoverflow.com/a/21569669
has comment: http://stackoverflow.com/comment/32579502
has answer: http://stackoverflow.com/a/21569935
upvote count: 3

http://stackoverflow.com/comment/32628666
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21595360
type: AnswerComment
has text: What is your class extending from? `getInputMap` and `getActionMap` are methods of `JComponent` - Key bindings can only be applied to `JComponent`s and it's children...

http://stackoverflow.com/q/21628361
upvote count: 1
has title: Serializing java.io.Serializable instance into JSON with Spring and Jackson JSON
type: Question
has comment: http://stackoverflow.com/comment/32685830
tagged with: jackson
duplicate of: http://stackoverflow.com/q/20474374
answer count: 1
downvote count: 0
has body: I am getting an instance of Serializable out of some internal APIs. The Serializable instance is actually Long or String, etc. Is there a way to make a DTO that can handle this situation? Using private Serializable value; the JSON ends up with value: {}. UPDATE Here is a reduced example of the code in question: @Controller public class SomeController { //... public MyDto getInfo(Long id) { MyDto result = new MyDto(); Serializable obj = svc.getInfo(id); // obj is either Long, or String, or one of few more fundamental Java types result.setValue(obj); return result; } } public class MyDto { private Serializable value; public void setValue(Serializable info) { this.value = value; } public Serializable getValue() { return value; } } UPDATE 2 I have found the answer to my problem here: https://stackoverflow.com/a/20494813/341065
has answer: http://stackoverflow.com/a/21635570
favorite count: 0
tagged with: rest
type: UnansweredQuestion
tagged with: spring
linked to: http://stackoverflow.com/q/20474374
score: 1
tagged with: java
tagged with: http://stackoverflow.com/tag/json

http://stackoverflow.com/comment/32798481
comment on: http://stackoverflow.com/a/21678096
has text: thanks a lot :). it takes me learn a lot. and it will take me a lot to learn it well! thanks :)!!!
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/32713663
has text: Because you're ignoring what it returns. Will you finally post your code?
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21645960

http://stackoverflow.com/q/21565173
score: 0
answer count: 2
upvote count: 1
downvote count: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32572003
has body: I have a method in my switch statement explaining to print my arraylist (i.e - System.out.println(drinkList);) ArrayList&lt;String&gt; drinkList = new ArrayList&lt;String&gt;(); System.out.print("Please enter a drink information to add:\n"); inputInfo = scan.nextLine().trim(); drinkLink = DrinkParser.parseStringToDrink(inputInfo); drinkList.add(drinkLink.toString()); //Take in user data to parse into parts Then I called it using the code System.out.println(drinkList); My problem is the output prints the following as such: [ Data Entry 1 , Data Entry 2 ] I want to remove the brackets and the comma.
type: UnansweredQuestion
tagged with: arrays
favorite count: 0
has comment: http://stackoverflow.com/comment/32571975
type: Question
has answer: http://stackoverflow.com/a/21565508
has title: Properly formatting output of arraylist data?
has answer: http://stackoverflow.com/a/21565259

http://stackoverflow.com/q/21518917
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/21519010
possible better answer: http://stackoverflow.com/a/21518967
has title: How to perform a search in an SQL database with a java application?
has answer: http://stackoverflow.com/a/21518967
has answer: http://stackoverflow.com/a/21518971
accepted answer: http://stackoverflow.com/a/21518971
has body: I'm planning to build a very very simple java application done on Netbeans that accepts basic individual information like ID number, name, and address and stores it on an sql database. I want to put a search function on my program that accepts ID numbers. When the user inputs the ID number that is stored in the database, it will show the Name and address on a pop up message dialog. I know this is possible but can you link me to some guides or documentations about the search function? or maybe you could give me a very short example of a sample code done in the search button?
has comment: http://stackoverflow.com/comment/32490041
type: AnsweredQuestion
tagged with: java
tagged with: mysql
type: Question
tagged with: database
has comment: http://stackoverflow.com/comment/32490069
tagged with: search

http://stackoverflow.com/a/21599507
accepted answer of: http://stackoverflow.com/q/21599360
type: Answer
answers question: http://stackoverflow.com/q/21599360
score: 2
downvote count: 0
has body: Use resultset.getTimestamp() method while reading your dates instead of resultset.getDate().
upvote count: 2
type: AcceptedAnswer

http://stackoverflow.com/q/21627241
type: Question
has title: How to report a bug of Gdata API of Java
has body: service.getListFeed(worksheets.get(i).getListFeedUrl()).getEntries() is returing me empty list as there are records in my work sheet. I know what the problem is, I have done some RnD, all I want to know is, how to report a but to google.
tagged with: gdata-api
score: 0
accepted answer: http://stackoverflow.com/a/21627377
answer count: 1
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/21627377

http://stackoverflow.com/comment/32686647
type: Comment
type: QuestionComment
has text: did you try ```.toString()```?
comment on: http://stackoverflow.com/q/21628464
score: 0

http://stackoverflow.com/comment/32486425
has text: You're rounding in your hardcoded result...
score: 1
comment on: http://stackoverflow.com/q/21516811
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21662075
upvote count: 1
answer count: 1
has comment: http://stackoverflow.com/comment/32741748
downvote count: 0
has comment: http://stackoverflow.com/comment/32741931
has body: I have a bunch of Java methods that I can modify as I please. Let us call this group of methods for B. Then I have some auto-generated Java code that calls methods in B. Let us call this code for A. The B code calls methods in some other auto-generated code. Let us call this code for C. So call flow is: A -> B -> C, of which I can only modify B methods. The C methods may throw exceptions that I want to catch at B. My exception handling is the same for all C methods. I could duplicate my try-catch block at every call site in B calling a C method. But I have hundreds of methods and so I would like to keep common exception handling in a single place. An idea is to put C-calls in lambdas, and then pass the lambda to a common invoke(lambda) method which can execute the lambda in a try-catch block. Any other ideas? regards Mark
favorite count: 0
has comment: http://stackoverflow.com/comment/32742254
has comment: http://stackoverflow.com/comment/32741665
tagged with: exception
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32741591
tagged with: lambda
has comment: http://stackoverflow.com/comment/32742134
has answer: http://stackoverflow.com/a/46808427
has title: Avoid try/catch at every call site, in favor of single place
has comment: http://stackoverflow.com/comment/32741738
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32742475
type: Question
tagged with: try-catch
has comment: http://stackoverflow.com/comment/32741855
has comment: http://stackoverflow.com/comment/32741954
has comment: http://stackoverflow.com/comment/32742049
has comment: http://stackoverflow.com/comment/32742335

http://stackoverflow.com/a/27048129
type: Answer
answers question: http://stackoverflow.com/q/21639465
has body: Do you have an excessive number of breakpoints in Eclipse? Try removing some/all breakpoints.
score: 0

http://stackoverflow.com/a/21572689
answers question: http://stackoverflow.com/q/21572614
has body: Strings are immutable so each time you do a concatenation (. operator) you're creating a new String object in memory. With StringBuilder you're adding the text to the same object so a new ones do not need to be created.
score: 0
type: Answer

http://stackoverflow.com/a/21579401
score: 0
type: Answer
has body: ok you must extend you AndroidManifest.xml file, the reply function is too small for a full reply, so i'll post this solution :-~ <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <meta-data android:name="android.support.PARENT_ACTIVITY" android:value="MainActivity" /> having problems with R.Java not created/reCreated you should check Developing for Android in Eclipse: R.java not regenerating i guess this won't help you much, but it was supposed to be a mere reply (comment)
answers question: http://stackoverflow.com/q/21569325

http://stackoverflow.com/comment/45852234
comment on: http://stackoverflow.com/q/21528974
score: 0
type: QuestionComment
has text: Did you find a way to solve your problem? I am, like you, trying to communicate with a RFIDRW-E-232 using Java. I am developing an Android app for this though. I only get the byte values 1 and 96 which I dont know what to make of. Unlike you I have lots of code that claims an interface and then uses two endpoints to read and write. I have also tried doing the same in .Net but I get the exact same result.
type: Comment

http://stackoverflow.com/q/21658033
has answer: http://stackoverflow.com/a/21659661
type: Question
tagged with: java
has body: I am building a file encryption utility, here's my encryption code: Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding", "SunJCE"); SecretKeySpec key = new SecretKeySpec(encryptionKey.getBytes("UTF-8"), "AES"); cipher.init(Cipher.ENCRYPT_MODE, key,new IvParameterSpec(IV.getBytes("UTF-8"))); for(int i = 0; i &lt; input.size(); i++){ plainText = input.get(i); byte[] b = cipher.doFinal(plainText.getBytes("UTF-8")); String outString = new String(b); //to be written to file The strings to encrypt are read in from an array (the utility does other data processing) and then encrypted, and output in an array of strings to write to a file when ready. When decrypting, I get an error that my padding is wrong. I have been researching and gather that this is down to .getBytes() not returning the byte array exactly as it was. I am reading line by line from file that has been encrypted using my previous code. How can I ensure that my decryption function receives the correct byte array? Here is the code: public void decode(File f) throws Exception{ BufferedWriter out = new BufferedWriter(new FileWriter("Decrypted Archive "+f.getName()+".txt")); BufferedReader br = new BufferedReader(new FileReader(f)); String line; while((line = br.readLine())!=null){ byte[] b = line.getBytes("UTF-8"); line = Decoder.decrypt(b); out.write(line+newline); } br.close(); out.close(); And the decrypt function: public static String decrypt(byte[] cipherText) throws Exception{ Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding", "SunJCE"); SecretKeySpec key = new SecretKeySpec(encryptionKey.getBytes("UTF-8"), "AES"); cipher.init(Cipher.DECRYPT_MODE, key,new IvParameterSpec(IV.getBytes("UTF-8"))); return new String(cipher.doFinal(cipherText),"UTF-8"); } Encryption keys etc are all the same.
score: 0
answer count: 2
has title: Java: Bad padding error when decrypting from encrypted file
possible better answer: http://stackoverflow.com/a/21658117
accepted answer: http://stackoverflow.com/a/21659661
tagged with: arrays
has answer: http://stackoverflow.com/a/21658117
tagged with: cryptography
type: AnsweredQuestion
tagged with: encryption

http://stackoverflow.com/comment/75164709
score: 0
type: AnswerComment
type: Comment
has text: msvcr100.dll and jli.dll already exist in the bin folder of the jre (1.8.0_131).
comment on: http://stackoverflow.com/a/21614882

http://stackoverflow.com/q/21655719
answer count: 1
has comment: http://stackoverflow.com/comment/32760572
downvote count: 0
favorite count: 0
has body: I have a singleton object that implements some basic functionality in a common library. It's much more complicated than this, but for documenting the issue, below is the Singleton implementation, with all but one inner properties/objects removed: package mystuff.lib.common public class CommonSingleton { public final static CommonSingleton INSTANCE = new CommonSingleton(); private Cache&lt;String, Object&gt; cache = null; private CommonSingleton() { // Exists only to defeat instantiation. Initialize(); } private void Initialize() { cache = null; } public Cache&lt;String, Object&gt; getCache() { if (cache == null) { cache = new Cache&lt;String, Object&gt;(); } return cache; } public void Reload() { Initialize(); } } I have included that library in two SEPARATE projects. The library isn't installed on the machine where the code runs. The contents of the common library is included within each JAR when the artifacts are created in IntelliJ IDEA. Both projects (JAR files) load and run (as plugins) inside a parent application, so they're both loaded inside the same JVM. I expected each JAR to have its own copy of this common singleton, since they are, after all, separate JAR files. It is only included in a common library because many of my projects require the same functionality and I would rather include the library in my project than have multiple copies of the code floating around. Project/Module #1: TestPluginOne.JAR package mystuff.plugins.TestPluginOne; import mystuff.lib.common.CommonSingleton; import mystuff.lib.common.Objects.Cache; public class TestClassOne { public TestClassOne() { } public Boolean SaveItemInCache(String key, String content) { return CommonSingleton.INSTANCE.getCache().add(key, content, 30); } public void Reload() { CommonSingleton.INSTANCE.Reload(); } } Project/Module #2: TestPluginTwo.JAR package mystuff.plugins.TestPluginTwo; import mystuff.lib.common.CommonSingleton; import mystuff.lib.common.Objects.Cache; public class TestClassTwo { public…
has comment: http://stackoverflow.com/comment/32782987
linked to: http://stackoverflow.com/q/137975
has comment: http://stackoverflow.com/comment/32782870
has comment: http://stackoverflow.com/comment/32811760
accepted answer: http://stackoverflow.com/a/21656109
type: AnsweredQuestion
score: 3
upvote count: 3
tagged with: java
type: Question
has title: How can I make use of a Singleton in a common library, in multiple modules, without them conflicting?
tagged with: intellij-idea
tagged with: jar
has comment: http://stackoverflow.com/comment/32933785
has answer: http://stackoverflow.com/a/21656109
tagged with: singleton

variables
tags question: http://stackoverflow.com/q/21526799
tag name: variables
tags question: http://stackoverflow.com/q/21607011
tags question: http://stackoverflow.com/q/21584988
tags question: http://stackoverflow.com/q/21660329
tags question: http://stackoverflow.com/q/21653048
tags question: http://stackoverflow.com/q/21601010
type: Tag
tags question: http://stackoverflow.com/q/21592430
tags question: http://stackoverflow.com/q/21540761
tags question: http://stackoverflow.com/q/21587447
tags question: http://stackoverflow.com/q/21578853
tags question: http://stackoverflow.com/q/21645031
tags question: http://stackoverflow.com/q/21668759
tags question: http://stackoverflow.com/q/21613098
tags question: http://stackoverflow.com/q/21558977
tags question: http://stackoverflow.com/q/21563705
tags question: http://stackoverflow.com/q/21578771

http://stackoverflow.com/a/21541805
answers question: http://stackoverflow.com/q/21540974
upvote count: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21540974
type: Answer
downvote count: 0
score: 1
has body: As soon as put finishes, lock is released now lets assume put and take both are waiting on that lock again and its unfair lock then any of the methods Put/Take can get hold of lock and start. There is no ordered and alternate exchange of monitor(lock) unless specified. See the code by java. ArrayBlockingQueue ReentrantLock AbstractQueuedSynchronizer

http://stackoverflow.com/q/21662397
tagged with: java
has comment: http://stackoverflow.com/comment/118296152
has answer: http://stackoverflow.com/a/21668005
accepted answer: http://stackoverflow.com/a/21668005
type: Question
upvote count: 2
answer count: 1
has comment: http://stackoverflow.com/comment/118290008
has body: I have the following XML: &lt;FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/palette2" android:id="@+id/fl" &gt; &lt;ImageView android:id="@+id/iv" android:layout_width="10dp" android:layout_height="10dp" android:src="@drawable/esquare" /&gt; &lt;/FrameLayout&gt; Which gives the following image in my Android Phone How can I code so that user can drag the image anywhere in a layout and the ImageView will always stay within the layout? If X&lt;0 it will be X=(X+imageview.width()) If Y&lt;0 it will be Y=(Y+imageview.height()) If X&gt;layout.width() it will be X=(X-imageview.width()) If Y&gt;layout.height() it will be Y=(Y-imageview.height())? Something similar to this: So if the user drags outside of the view, the square image will stay in the last known location within the FrameLayout I convert the layout background to a bitmap so I can use it to get the X and Y coordinate and convert to RGB value for my app. f = (FrameLayout) findViewById(R.id.fl); f.setOnTouchListener(flt); iv = (ImageView) findViewById(R.id.iv); f.setDrawingCacheEnabled(true); f.buildDrawingCache(); bm = f.getDrawingCache(); I have the following code which works but every once in a while I get an error NPE for x must be &lt;= layout.width() or y must be &lt;= layout.height();. Sometime the app allows me to drag to the right or bottom out of the layout itself which shouldn't be happening because I have a condition for it to not allow it. @Override public boolean onTouch(View v, MotionEvent event) { int x = (int)event.getX(); int y = (int)event.getY(); if (x&lt;0) { iv.setX(0); iv.setY(y); x=0; Toast.makeText(getApplicationContext(), "x=0", 2000).show(); } if (y&lt;0) { iv.setY(0); iv.setX(x); y=0; Toast.makeText(getApplicationContext(), "y=0", 2000).show(); } if (x&gt;bm.getWidth()) { x=bm.getWidth()-20; iv.setX(x); iv.setY(y); Toast.makeText(getApplicationContext(), "x=bitmap.maxwidth(}", 2000).show(); } if (y&gt;bm.getHeight()) { …
tagged with: android
favorite count: 0
has comment: http://stackoverflow.com/comment/118292203
tagged with: android-framelayout
has title: How to keep an image within layout with drag and drop
type: AnsweredQuestion
score: 2
tagged with: android-layout
downvote count: 0
tagged with: motionevent

http://stackoverflow.com/comment/32886515
type: Comment
comment on: http://stackoverflow.com/a/21731002
type: AnswerComment
score: 0
has text: Ill check this out after work and then mark you for the credit. Thanks for the detailed answer.

format
tags question: http://stackoverflow.com/q/21669962
tag name: format
tags question: http://stackoverflow.com/q/21570987
type: Tag
tags question: http://stackoverflow.com/q/21652326
tags question: http://stackoverflow.com/q/21609803

http://stackoverflow.com/a/21538318
type: Answer
has comment: http://stackoverflow.com/comment/32527417
score: 0
has comment: http://stackoverflow.com/comment/32525403
answers question: http://stackoverflow.com/q/21537998
has comment: http://stackoverflow.com/comment/32524819
has comment: http://stackoverflow.com/comment/32525670
has body: Write it to a file instead of keeping it in memory?
has comment: http://stackoverflow.com/comment/32525496
has comment: http://stackoverflow.com/comment/32525755
has comment: http://stackoverflow.com/comment/32526548

http://stackoverflow.com/comment/32668260
type: Comment
score: 1
has text: Yeah, all really valid points - thanks for so much explanation. Just because you can do something doesn't mean you should, and especially not without considering the consequences.
type: AnswerComment
comment on: http://stackoverflow.com/a/21605986

http://stackoverflow.com/q/21621096
has answer: http://stackoverflow.com/a/21621244
score: 0
possible better answer: http://stackoverflow.com/a/21621171
has answer: http://stackoverflow.com/a/21621253
accepted answer: http://stackoverflow.com/a/21621253
has answer: http://stackoverflow.com/a/21621290
tagged with: jframe
answer count: 5
has answer: http://stackoverflow.com/a/21621258
type: AnsweredQuestion
has title: Difference between these Constructor calling Statements?
tagged with: java
has answer: http://stackoverflow.com/a/21621171
tagged with: swing
has body: public class StudentFormMain { public static void main(String[] args) { new StudentForm(); } } And 2ND Class public class StudentForm extends JFrame { public StudentForm(){ setTitle("Admission Form"); setSize(300,250); setVisible(true); } } My Question are What is the difference between these statements StudentForm studentform=new StudentForm(); and new StudentForm() First Statement Declare the Obj of that class and calls the Constructor, but in Second Statement only Constructor is calling. Note: Result are Same super(""); set the title of the frame because it is calling super class constructor. we can also set the title by using the setTitle("") method Please differentiate the methods also.
type: Question

http://stackoverflow.com/a/21555274
has comment: http://stackoverflow.com/comment/32598338
downvote count: 1
has comment: http://stackoverflow.com/comment/32553472
has comment: http://stackoverflow.com/comment/32553454
has body: Performance. In order to call the E... version of the method, the caller must allocate a new array. The caller only has to push the args on the stack to call the other methods.
has comment: http://stackoverflow.com/comment/32554296
answers question: http://stackoverflow.com/q/21555040
type: Answer
score: 2
upvote count: 3

http://stackoverflow.com/q/21575365
tagged with: java
accepted answer: http://stackoverflow.com/a/21576056
has body: I would like to automatically find and inject EJB instances from an EJB container to a List. Example: @EJBs List&lt;MyCommonInterface&gt; beans; or List&lt;MyCommonInterface&gt; beans; public MyClass() { beans = (List&lt;MyCommonInterface&gt;) context.findBeansByInterface(MyCommonInterface.class); } Is this possible?
type: Question
tagged with: jakarta-ee
type: AnsweredQuestion
tagged with: dependency-injection
tagged with: ejb
tagged with: jndi
answer count: 1
downvote count: 0
has answer: http://stackoverflow.com/a/21576056
favorite count: 0
has title: Inject EJBs to a List by common interface
score: 2
upvote count: 2

http://stackoverflow.com/a/21615788
has body: Please try to change your servlet-api dependency from: 'javax.servlet:servlet-api:2+' to: 'javax.servlet:javax.servlet-api:3.0.1' The ServletContext prior to JEE6 (Servlet spec 3.0) didn't have the API mechanism to register a listener. Also, 'org.jboss.spec.javax.servlet:jboss-servlet-api_3.0_spec:1+' should be providedRuntime (if any). It is probably the reason you didn't have an error in your IDE, but did have using gradle compile
answers question: http://stackoverflow.com/q/21615449
type: Answer
score: 0

http://stackoverflow.com/q/21622841
has answer: http://stackoverflow.com/a/56644445
has answer: http://stackoverflow.com/a/21623666
score: 38
has answer: http://stackoverflow.com/a/30352153
tagged with: java
tagged with: hibernate
accepted answer: http://stackoverflow.com/a/21623369
type: Question
has body: There are always so many questions related to issues with detached entities! First, they often cause LazyInitializationException in Hibernate. Yes, there are another persistence providers, which don't throw exceptions, but I think that they have some problems with consistency. Consider we have A and B entities that there is reference (@ManyToOne) from A to B that is required to be non-null. We started our session, loaded A instance and then closed session. After that we try to obtain a reference to B. And assume that another transaction just deleted both our A and B instances. So when we query from database we can't find appropriate B instance and get null! So our contract is violated. Some code that relies on fact that a.getB() returns an object will throw an NullPointerException. With persistent entities this is impossible because we have all lazy loading in the same transaction with obtaining object itself, so all operations are atomic (if we have a proper transaction isolation of course). Also there are problems when you want to store persistent and detached entities in one Set. It that case you should always override equals and hashCode, which usually looks awkward, as I can't see a really good way to do it. To get a detached entity back into EntityManager you should use merge which is glitchy. So my question is: is there is a reasonable scenario where detached entities are really needed? Furthermore, when do you have to mix detached and persistent entities and merge detached entities into a new EntityManager?
has title: Why need detached entities in JPA?
tagged with: jpa
downvote count: 0
has answer: http://stackoverflow.com/a/21625885
answer count: 6
upvote count: 38
has answer: http://stackoverflow.com/a/21623369
favorite count: 0
has answer: http://stackoverflow.com/a/21623363
has comment: http://stackoverflow.com/comment/32676725
has comment: http://stackoverflow.com/comment/32754552
possible better answer: http://stackoverflow.com/a/21623666
type: AnsweredQuestion

http://stackoverflow.com/a/21534813
has comment: http://stackoverflow.com/comment/32518284
has comment: http://stackoverflow.com/comment/32518500
has comment: http://stackoverflow.com/comment/33725011
has comment: http://stackoverflow.com/comment/32518417
has comment: http://stackoverflow.com/comment/32518825
has comment: http://stackoverflow.com/comment/32518190
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32518131
answers question: http://stackoverflow.com/q/21534352
accepted answer of: http://stackoverflow.com/q/21534352
type: Answer
has body: Are you connected to the same end point as in the console ? Sounds like you may be connected to a different region. Basically, use the same region where you have verified your sender's email address.
score: 2
has comment: http://stackoverflow.com/comment/33724053
has comment: http://stackoverflow.com/comment/33724185
upvote count: 2

http://stackoverflow.com/a/21609237
downvote count: 0
answers question: http://stackoverflow.com/q/21536320
type: Answer
has body: Currently New Relic isn't able to detect traffic that's delivered by any protocol other than HTTP, including WebSockets and JMS. If you're willing to do some customization, you can get transactions detected using some annotations and/or custom instrumentation via .XML The easiest way to sample how this would work is to add the New Relic @Trace annotation to your code and see what's recorded by New Relic https://docs.newrelic.com/docs/java/custom-java-transaction-traces I'd get in touch with New Relic support directly for further help with this. support.newrelic.com
score: 2
upvote count: 2

http://stackoverflow.com/a/21637780
score: 0
answers question: http://stackoverflow.com/q/21633984
type: Answer
has body: I suppose you have a class for coordinates: public class Coordinate { public double x; public double y; public Coordinate(int x, int y) { this.x = x; this.y = y; } } Let's suppose you have a class containing your Polygon coordinates: public class Polygon { protected Coordinate[] points; public Polygon(Coordinate[] points) { this.points = points; } protected doulbe getMaxHeight(double x) { double height = 0; for (int pointIndex = 0; pointIndex &lt; points.length; pointIndex++) { int nextIndex = (pointIndex + 1) % points.length; if ((points[pointIndex] &gt;= x) &amp;&amp; (points[nextIndex] &lt;= x) || (points[nextIndex] &gt;= x) &amp;&amp; (points[pointIndex] &lt;= x)) { height = Math.max(height, Math.max(points[pointIndex].y, points[nextIndex].x)); } } return height; } } The code is untested, but you can try that out and please let me know about the results.

http://stackoverflow.com/comment/50741778
type: Comment
has text: Can you explain its meaning as well?
score: 10
comment on: http://stackoverflow.com/a/27303504
type: AnswerComment

http://stackoverflow.com/a/21692801
downvote count: 0
has body: Generally it is a good idea to avoid putting config files inside jar files to avoid this exact problem. If you don't have a choice in the matter, you need to control the classpath such that the jar with the desired log4j2.xml precedes the jar with the undesired config file. Also, you can specify the location of the config file with a system property: http://logging.apache.org/log4j/2.x/faq.html#config_location
upvote count: 3
answers question: http://stackoverflow.com/q/21527343
type: Answer
score: 3

http://stackoverflow.com/comment/32621311
has text: Gotcha. This may seem like a silly question, but how do I access the deprecated parts of clojure.java.jdbc? I did this, but it did not work :require [clojure.java.jdbc.deprecated] FileNotFoundException Could not locate clojure/java/jdbc/deprecated/as__init.class or clojure/java/jdbc/deprecated/as.clj on classpath: clojure.lang.RT.load (RT.java:443)
type: AnswerComment
comment on: http://stackoverflow.com/a/21591897
score: 0
type: Comment

http://stackoverflow.com/a/21528697
downvote count: 0
upvote count: 2
answers question: http://stackoverflow.com/q/21528485
has body: Prior java 7 the general pattern of closable IO resources was like the following: Resource r = null; // either stream, reader, writer etc try { r = ... // create resource use resource r } catch(IOException e) { // some code } finally { if (r != null) { r.close(); } } The resource is used in finally block that guarantees that it will be closed whether the operation is done successfully or failed. null-check is needed to prevent NPE if IOException was thrown while creating the resource. Java 7 introduced new syntax that creates illusion that the resource is closed "automatically": try ( Resource r = // create resource ){ use resource r } catch(IOException e) { // some code } finally block is actually added here automatically by compiler. I hope this answers your question about automatic closing of BufferedReader.
type: Answer
score: 2

http://stackoverflow.com/comment/32537072
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21545503
has text: @ᴍaroun ᴍaroun it wont give a right answer.if you take eg abac ....in this when i=1 it enters j loop j=1 then i(1) =b,j(1)=b and hence b=b and count will increase.but as you can see only "a" is appearing twice in the eg.

http://stackoverflow.com/comment/32688164
score: 0
has text: Andre Thompson in java swing application only i didn't get my expected output but in command line am getting it whats the problem with that swing tag
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21631624

http://stackoverflow.com/q/21610684
possible better answer: http://stackoverflow.com/a/21610720
tagged with: java
linked to: http://stackoverflow.com/q/1437865
has body: This is the code I have checking for q while (!inputs.contains("q")) How can I add multiple characters in this.. such as q and Q Or if I had like 5 different letters. q w e r t Thanks!
type: Question
score: 0
has answer: http://stackoverflow.com/a/21611860
tagged with: string
has answer: http://stackoverflow.com/a/21610763
has answer: http://stackoverflow.com/a/21610720
has answer: http://stackoverflow.com/a/21610816
accepted answer: http://stackoverflow.com/a/21610816
answer count: 5
has comment: http://stackoverflow.com/comment/32651592
has comment: http://stackoverflow.com/comment/32651558
has title: java checking string for inputs in a line of code
has answer: http://stackoverflow.com/a/21610975
type: AnsweredQuestion

http://stackoverflow.com/q/21583301
upvote count: 1
type: Question
tagged with: primefaces
answer count: 2
has title: Spring security 3.2 - CSS display issue
has body: I am trying to include 'Spring security 3.2.0' into my existing web application which is built without spring and using Primefaces & EJB 3. When I started with the basic configuration, and tried access the page displays without CSS styles. The below logs have some information about the path. I am not sure what I am missing. Many thanks in advance. Application Logs:- 05-02-2014 16:05:58 INFO DispatcherServlet:472 - FrameworkServlet 'spring': initialization completed in 831 ms 05-02-2014 16:05:58 DEBUG DispatcherServlet:141 - Servlet 'spring' configured successfully 05-02-2014 16:05:58 DEBUG DispatcherServlet:823 - DispatcherServlet with name 'spring' processing GET request for [/myapp/resources/css/myapp.css] 05-02-2014 16:05:58 DEBUG DispatcherServlet:823 - DispatcherServlet with name 'spring' processing GET request for [/myapp/resources/images/bg_myapp_header.gif] 05-02-2014 16:05:58 DEBUG DispatcherServlet:823 - DispatcherServlet with name 'spring' processing GET request for [/myapp/resources/js/myapp.js] 05-02-2014 16:05:58 DEBUG DispatcherServlet:823 - DispatcherServlet with name 'spring' processing GET request for [/myapp/resources/images/2_arial_white_myapp_bg.png] 05-02-2014 16:05:58 DEBUG DispatcherServlet:823 - DispatcherServlet with name 'spring' processing GET request for [/myapp/resources/images/logo.png] 05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:209 - Looking up handler method for path /resources/css/myapp.css 05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:209 - Looking up handler method for path /resources/js/myapp.js 05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:219 - Did not find handler method for [/resources/js/myapp.js] 05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:209 - Looking up handler method for path /resources/images/bg_myapp_header.gif 05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:209 - Looking up handler method for path /resources/images/2_arial_white_myapp_bg.png 05-02-2014 16:05:58 DEBUG Re…
downvote count: 0
score: 1
favorite count: 0
type: UnansweredQuestion
tagged with: spring
tagged with: css
has answer: http://stackoverflow.com/a/21583383
has answer: http://stackoverflow.com/a/35000522
tagged with: java

http://stackoverflow.com/q/21642101
accepted answer: http://stackoverflow.com/a/21642132
tagged with: image
has body: My project include a folder named Image containing images.I want to get the total no of images from it also the name of the last saved image. Does anyone help?
has title: How to get the name of the last saved item from a folder?
answer count: 1
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/21642132
type: AnsweredQuestion
score: 1
tagged with: java
tagged with: file
upvote count: 1
tagged with: swing
type: Question

http://stackoverflow.com/comment/32769200
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/21677879
type: Comment
has text: How do you know? In question comments you say "debugging" but the debugger can confuse you by seemingly jumping to lines that are not executed. You can use logging for more clarity.

http://stackoverflow.com/comment/32511849
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21531299
has text: What do you mean by `How could i reach the specific file pomxt inside ModuleProjectNameThree?`

http://stackoverflow.com/comment/32761250
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21672982
has text: Yes this works !!! Cool ! thanks ... The for() loop works too... Can you brief the issue ?

http://stackoverflow.com/a/21595279
has comment: http://stackoverflow.com/comment/32625943
has comment: http://stackoverflow.com/comment/32625808
has body: You don't have to loop in order to print an array, just do: System.out.println(Arrays.toString(arrayList.toArray())); ArrayList doesn't have a mechanism to limit the size, if you want to do it - you'll have to implement it. Example: import java.util.ArrayList; /** * User: alfasin * Date: 2/5/14 */ public class RestrictedSizeArrayList&lt;E&gt; extends ArrayList&lt;E&gt; { private static final int limit = 6;//example @Override public boolean add(E e){ if(this.size() &gt; 5){ throw new IndexOutOfBoundsException("Can't add more than 5 elements to the ArrayList"); } boolean result = super.add(e); return result; } }
score: 0
has comment: http://stackoverflow.com/comment/32626011
has comment: http://stackoverflow.com/comment/32625668
answers question: http://stackoverflow.com/q/21595253
type: Answer

http://stackoverflow.com/q/21644107
possible better answer: http://stackoverflow.com/a/21644247
answer count: 2
upvote count: 1
has title: how to allow predefined amount of entries to java program
favorite count: 0
has answer: http://stackoverflow.com/a/21644153
has answer: http://stackoverflow.com/a/21644247
type: AnsweredQuestion
tagged with: command-line
downvote count: 0
score: 1
tagged with: java
has body: My program allows the user to enter 20 entries. each entry is entered as one entry then presses enter from command line. I would like to add the ability for the program to say "you have 20 entries left" then "you have 19 entries left" and so on... as the user enters more data in to the program. I would appreciate if someone could show me the simplest way to add this to my current code. import java.util.ArrayList; import java.util.Scanner; class project02Diaz { private static Double calculate_average( ArrayList&lt;Double&gt; myArr ) { Double sum = 0.0; for (Double number: myArr) { sum += number; } return sum/myArr.size(); } public static void main( String[] args ) { Scanner scan = new Scanner(System.in); ArrayList&lt;Double&gt; myArr = new ArrayList&lt;Double&gt;(); int count = 0; System.out.println("Enter one number at a time be averaged, you have 20 entries remaining:"); for (String inputs = scan.nextLine() ; !inputs.matches("[qQ]") ; inputs = scan.nextLine()) { if (count == 20) { System.out.println("You entered more than 20 numbers, you suck!"); break; } try{ myArr.add(Double.valueOf(inputs)); count++; System.out.println("Please enter another number or press Q for your average"); } catch (NumberFormatException e) { System.out.println("Try again you tard! You entered more than one number, or not a valid number at all."); continue; } } Double average = calculate_average(myArr); System.out.println("Your average is: " + average); } }
type: Question
has comment: http://stackoverflow.com/comment/32710681
accepted answer: http://stackoverflow.com/a/21644153

http://stackoverflow.com/comment/32713052
has text: Maybe you can elaborate on what you mean by "without any loss of data". Plain text format does not generally support things like hyperlinks, so how would you represent that concept in plain text without a loss of information?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21645426

http://stackoverflow.com/comment/32709279
comment on: http://stackoverflow.com/q/21643307
score: 0
type: Comment
type: QuestionComment
has text: @developerknownasInsane What is with adding `@` as a name suffix? It totally breaks the notifications mechanism it is designed for.

http://stackoverflow.com/comment/32609117
score: 0
has text: a,b=b,a+b in python works as a = b; followed by b = a+b..correct?
type: AnswerComment
comment on: http://stackoverflow.com/a/21585991
type: Comment

http://stackoverflow.com/a/21647746
has body: That's not how to get user input. Instead use a Scanner object. e.g., Scanner scanner = new Scanner(System.in); char c = scanner.nextLine().charAt(0); // or int i = scanner.nextInt();
type: Answer
score: 2
downvote count: 0
upvote count: 2
answers question: http://stackoverflow.com/q/21647729

http://stackoverflow.com/comment/33542230
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21666363
has text: I've changed the convention to the default for the entities, thanks for your insights

http://stackoverflow.com/a/21563597
score: 1
answers question: http://stackoverflow.com/q/21563581
type: AcceptedAnswer
downvote count: 0
type: Answer
upvote count: 1
has body: You have two Date types here with the same short name: Date. One is java.util.Date, the other one is java.sql.Date. This is the problem here. You are getting java.util.Date from parse and you are trying to cast it to java.sql.Date.
accepted answer of: http://stackoverflow.com/q/21563581

http://stackoverflow.com/q/21565712
tagged with: jbutton
type: Question
has comment: http://stackoverflow.com/comment/32573741
has comment: http://stackoverflow.com/comment/32573453
has body: Hello everyone I need to make Prev and next Jbutton to read lines from a csv file to JTextField I managed to make Load button but now I am stuck. This is for my homework. So if anyone could help it would be nice :D. This is the question in homework: The Next and Previous buttons display the next or previous order from the file. Use the String’s split method. Separate methods are needed for next, previous. Do not duplicate any significant amount of code. Guideline is 3 lines or less is OK to duplicate. import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.io.*; import java.util.*; import java.text.*; public class OrderSystem extends JFrame implements ActionListener { private JButton exit, cal, save, clear, load, prev, next; private JTextField text, text1, text2, text3; private int counter; //ArrayList&lt;String&gt; splitLine = new ArrayList&lt;String&gt;(); String[] textLine = new String[3]; public OrderSystem() { JFrame myFrame = new JFrame("{Your Name} Item Orders Calculator"); myFrame.setLayout(new BorderLayout(2, 2)); JPanel panel = new JPanel(); panel.setLayout( new GridLayout(0, 2)); panel.add( new JLabel("Item name: ", SwingConstants.RIGHT)); text = new JTextField("", 25); panel.add( text ); panel.add( new JLabel("Number of: ", SwingConstants.RIGHT)); text1 = new JTextField("", 20); panel.add( text1 ); panel.add( new JLabel("Cost: ", SwingConstants.RIGHT)); text2 = new JTextField("", 20); panel.add( text2 ); panel.add( new JLabel("Amount owed: ", SwingConstants.RIGHT)); text3 = new JTextField("", 20); text3.setEnabled(false); panel.add( text3 ); add(panel,BorderLayout.CENTER); JPanel panelS = new JPanel( new FlowLayout(FlowLayout.CENTER, 20,3) ); // Create some buttons to place in the south area cal = new JButton("Calculate"); save = new JButton("Save"); clear = new JButton("Clear"); exit = new JButton("Exit"); load = new JButton("Load"); prev = new JButton("&lt;prev"); next = new JButton("next&gt;"); exit.addActionListener(this); clear…
tagged with: java
has comment: http://stackoverflow.com/comment/32577284
linked to: http://stackoverflow.com/q/20112159
score: 0
has comment: http://stackoverflow.com/comment/32573053
upvote count: 1
answer count: 1
downvote count: 1
has answer: http://stackoverflow.com/a/21567209
favorite count: 0
type: UnansweredQuestion
tagged with: swing
has title: Need to make Prev and Next JButton Java

timer
tag name: timer
tags question: http://stackoverflow.com/q/21519233
tags question: http://stackoverflow.com/q/21515184
tags question: http://stackoverflow.com/q/21541991
tags question: http://stackoverflow.com/q/21652271
type: Tag
tags question: http://stackoverflow.com/q/21614544
tags question: http://stackoverflow.com/q/21539819
tags question: http://stackoverflow.com/q/21674152
tags question: http://stackoverflow.com/q/21591005
tags question: http://stackoverflow.com/q/21582590
tags question: http://stackoverflow.com/q/21533692
tags question: http://stackoverflow.com/q/21609207
tags question: http://stackoverflow.com/q/21617038
tags question: http://stackoverflow.com/q/21653372
tags question: http://stackoverflow.com/q/21620826
tags question: http://stackoverflow.com/q/21525383
tags question: http://stackoverflow.com/q/21531858
tags question: http://stackoverflow.com/q/21648765

http://stackoverflow.com/q/21544973
has comment: http://stackoverflow.com/comment/36721617
has comment: http://stackoverflow.com/comment/32535492
has body: I have a JSONObject with some attributes that I want to convert into a Map&lt;String, Object&gt; Is there something that I can use from the json.org or ObjectMapper?
has comment: http://stackoverflow.com/comment/32535715
type: Question
accepted answer: http://stackoverflow.com/a/21545023
score: 92
type: AnsweredQuestion
tagged with: http://stackoverflow.com/tag/json
has answer: http://stackoverflow.com/a/70144410
has comment: http://stackoverflow.com/comment/32535505
has answer: http://stackoverflow.com/a/48245094
has answer: http://stackoverflow.com/a/52401607
has answer: http://stackoverflow.com/a/23561086
has answer: http://stackoverflow.com/a/75572597
upvote count: 94
possible better answer: http://stackoverflow.com/a/52401607
favorite count: 0
has comment: http://stackoverflow.com/comment/36725314
has answer: http://stackoverflow.com/a/71556871
has answer: http://stackoverflow.com/a/21545023
has answer: http://stackoverflow.com/a/58068722
has answer: http://stackoverflow.com/a/71431806
answer count: 10
tagged with: dictionary
has answer: http://stackoverflow.com/a/23538261
has title: Convert JSONObject to Map
linked to: http://stackoverflow.com/q/41243880
tagged with: java
downvote count: 2

http://stackoverflow.com/comment/32588815
has text: I don't fully understand what you are trying to do: You want to check the applet (somehow) before it is started or do you want to start the applet and then check the Java version it was started with?
comment on: http://stackoverflow.com/q/21551391
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21601737
type: Answer
accepted answer of: http://stackoverflow.com/q/21601652
has body: I recommend using json-lib to serialize the JSON into a Java object. Then you can get the JSONArray from that object and stroe it in its own array. Example: JSONObject json = new JSONObject(jsonString); JSONArray owners = (JSONArray) json.get("owners"); Iterator&lt;String&gt; iterator = owners.iterator(); while (iterator.hasNext()) { System.out.println(iterator.next()); } Output: Wr3pWSGt54GlRiEL XJU7ZqZ3MYrQncIw Formatted JSON: { "_id":"XJTt3mXTOZpvgmOc", "cover_picture":"http://images.soundrop.fm/spaces/XJTt3mXTOZpvgmOg/5I3f6HGSSob6c1TTzK8vHg", "creator":"Wr3pWSGt54GlRiEL", "description":"Radio for Okicraft minecraft server!\nwww.okicraft.com", "display_name":"Molly's Bang'n Tunes FM AKA Okicraft Radio :D", "display_picture":"http://images.soundrop.fm/spaces/XJTt3mXTOZpvgmOg/AiTQDQBYGg1wesnhFVLao", "owners":[ "Wr3pWSGt54GlRiEL", "XJU7ZqZ3MYrQncIw" ], "parameters":{ "soundrop:chat":{ "version":2 }, "soundrop:membership":{ "version":2 }, "soundrop:playlist":{ "version":2, "mode":"open" } }, "presence":{ "soundrop:chat":{ }, "soundrop:membership":{ "members_live_count":0, "members_total_count":189, "members_max_count":8, "members_max_date":"2014-02-01T19:33:29Z", "members_summary":[ ] }, "soundrop:playlist":{ "current":{ "_id":"WPg2zdgdMsBxsge7", "title":"Son Of A Preacher Man", "artists":[ { "_id":"WgCuwalktE9Wl4bS", "display_name":"Dusty Springfield" } ], "sources":[ { "album":"At Her Very Best", "length":144241, "uris":[ "isrc:GBF086800754", "spotify:track:02hv6aR5wa2Vhw4Xo8DaN2", "spotify:track:3zRliQqUlisnnl3BguDkZM" ] }, { "album":"Dusty In Memphis", "length":149365, "uris":[ "deezer:track:1104538", "isrc:GBF086800754", "isrc:USAT20702465", "spotify:track:1IYeYU3r8CkP9ECrhdX9en", "spotify:track:1pWd0ar7Y77ex8fWfaAyiq", "spotify:track:26EuE0OC3dbqcpIyIvS13O", "spotify:track:28jBolSSfkXDYYOZWTcHDE", "spotify:track:3zRliQqUlisnnl3BguDkZM", "spotify:track:4UCIi4gRVUG7x4nFGQiKmo", "spotify:track:5TbLONSGZsR8cbhNEodCH6" ] }, { "album":"The Silver Collection", "length…
upvote count: 1
score: 1
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21601652

http://stackoverflow.com/q/21652017
type: UnansweredQuestion
score: 1
tagged with: java
upvote count: 1
tagged with: web-services
has comment: http://stackoverflow.com/comment/32736122
has comment: http://stackoverflow.com/comment/32766453
type: Question
has comment: http://stackoverflow.com/comment/32762964
has body: The above image shows the WSDL for web serice i have created and i am getting the soapAction as "URN:authentication" authentication is my method name I want to know the url for soapAction as i am getting null point exception while connecting to webservice using android. I have create web service using AXIS 2 . public class MainActivity extends Activity { EditText username, Password; private final String NAMESPACE = "http://nepal.blue_book.com"; private final String URL = "http://192.168.1.104:8088/Blue_Book/services/Login_service?wsdl"; private final String SOAP_ACTION = "urn:authentication"; private final String METHOD_NAME = "authentication"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button login = (Button) findViewById(R.id.btnLogin); login.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { loginAction(); } }); } public void loginAction() { username = (EditText) findViewById(R.id.textusername); Password = (EditText) findViewById(R.id.textpassword); if (username.getText().toString().equals("")) { Toast.makeText(getApplicationContext(), "Please Enter User Name", Toast.LENGTH_SHORT).show(); } else if (Password.getText().toString().equals("")) { Toast.makeText(getApplicationContext(), "Please Enter Password", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "login", Toast.LENGTH_SHORT).show(); SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); EditText userName = (EditText) findViewById(R.id.textusername); String user_Name = userName.getText().toString(); EditText userPassword = (EditText) findViewById(R.id.textpassword); String user_Password = userPassword.getText().toString(); Log.i("user name ", user_Name); Log.i("user password ", user_Password); //Pass value for userName variable of the web service PropertyInfo unameProp =new PropertyInfo(); unameProp.setName("userName");//Define the variabl…
has comment: http://stackoverflow.com/comment/32756144
has comment: http://stackoverflow.com/comment/32756151
has answer: http://stackoverflow.com/a/21674719
answer count: 1
tagged with: wsdl
downvote count: 0
has comment: http://stackoverflow.com/comment/32768787
has comment: http://stackoverflow.com/comment/32756104
has comment: http://stackoverflow.com/comment/32762228
favorite count: 0
has title: What will be my URL if soapAction is URN:something?
has comment: http://stackoverflow.com/comment/32756121
has comment: http://stackoverflow.com/comment/32736148
tagged with: android
has comment: http://stackoverflow.com/comment/32740393
has comment: http://stackoverflow.com/comment/32763167
tagged with: soap
has comment: http://stackoverflow.com/comment/32761505
has comment: http://stackoverflow.com/comment/32758804

http://stackoverflow.com/comment/32754643
type: Comment
has text: Yes, log also be in new line, every thing gone in new line if I press Ctrl+A and Ctrl + Shift + F. Why this?
type: QuestionComment
comment on: http://stackoverflow.com/q/21669235
score: 0

http://stackoverflow.com/q/21574468
upvote count: 4
has body: i'm trying to ensure an output File integrity in case of disk out of space , network problem ,or any anyException that might occur during the streaming to file process . is there a way to precalculate the FileStream checkSum before writing to disk then check if the file was written properly. it sounds a bit nonsensical for me , that a system validates the integrity of its own exported XML through checkSum , normaly it's the job of the other end to verify if the the consumed file lives up to the file produced by the other system . but it's a requirement i have to implement. her's the stream i write as a file : String xmlTransfer =""; File testFile = new File("testFile.xml"); InputStream in = new ByteArrayInputStream(xmlTransfer.getBytes("utf-8")); FileOutputStream out = new FileOutputStream(testFile) byte[] buffer = new byte[2048]; int bytesRead; while ((bytesRead = in.read(buffer)) != -1) { out.write(buffer, 0, bytesRead); } out.close(); in.close();
linked to: http://stackoverflow.com/q/304268
downvote count: 0
has answer: http://stackoverflow.com/a/21579572
favorite count: 0
has title: preCalculate file stream checksum
possible better answer: http://stackoverflow.com/a/21574724
has comment: http://stackoverflow.com/comment/32597032
answer count: 4
has answer: http://stackoverflow.com/a/21574724
tagged with: java.nio.file
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21579442
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21710105
score: 4
has comment: http://stackoverflow.com/comment/32603584
tagged with: java-io
accepted answer: http://stackoverflow.com/a/21710105
has comment: http://stackoverflow.com/comment/32601226

http://stackoverflow.com/q/21644248
type: Question
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has comment: http://stackoverflow.com/comment/32710715
score: 0
has comment: http://stackoverflow.com/comment/32711185
answer count: 1
has comment: http://stackoverflow.com/comment/32710910
has comment: http://stackoverflow.com/comment/32710724
has comment: http://stackoverflow.com/comment/32711221
has title: having error when trying to MYSQL server in Android
type: UnansweredQuestion
tagged with: android
has answer: http://stackoverflow.com/a/21644278
tagged with: php
has body: hello i am learning to connect android application with MYSQL using this tutorial.. Tutorial i want to login and add some comments to the MYSQL database in my hosting. i have done all the steps correctly. but when i try to load the application in the phone .that say "unfortunately the MYSQL has stopped working" and gives me the following error. can some one help me to fix this error please. thank you.... Full error stack 02-08 15:21:43.578: E/AndroidRuntime(9705): FATAL EXCEPTION: AsyncTask #1 02-08 15:21:43.578: E/AndroidRuntime(9705): java.lang.RuntimeException: An error occured while executing doInBackground() 02-08 15:21:43.578: E/AndroidRuntime(9705): at android.os.AsyncTask$3.done(AsyncTask.java:299) 02-08 15:21:43.578: E/AndroidRuntime(9705): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352) 02-08 15:21:43.578: E/AndroidRuntime(9705): at java.util.concurrent.FutureTask.setException(FutureTask.java:219) 02-08 15:21:43.578: E/AndroidRuntime(9705): at java.util.concurrent.FutureTask.run(FutureTask.java:239) 02-08 15:21:43.578: E/AndroidRuntime(9705): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 02-08 15:21:43.578: E/AndroidRuntime(9705): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 02-08 15:21:43.578: E/AndroidRuntime(9705): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 02-08 15:21:43.578: E/AndroidRuntime(9705): at java.lang.Thread.run(Thread.java:838) 02-08 15:21:43.578: E/AndroidRuntime(9705): Caused by: java.lang.NullPointerException 02-08 15:21:43.578: E/AndroidRuntime(9705): at lk.adspace.mysqltest.Login$AttemptLogin.doInBackground(Login.java:141) 02-08 15:21:43.578: E/AndroidRuntime(9705): at lk.adspace.mysqltest.Login$AttemptLogin.doInBackground(Login.java:1) 02-08 15:21:43.578: E/AndroidRuntime(9705): at android.os.AsyncTask$2.call(AsyncTask.java:287) 02-08 15:21:43.578: E/AndroidRuntime(9705): at java.util.concurrent.FutureTask.run(Futu…
has comment: http://stackoverflow.com/comment/32710836
tagged with: mysql

http://stackoverflow.com/comment/32676588
has text: i get it from xml stream. Yes i the format is always the same i logged it. For example : "Fri, 12 Oct 2012 06:57:39 +0200"
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21624213
type: Comment

http://stackoverflow.com/q/21557235
answer count: 0
tagged with: java
has body: So for my school project I have to make the game Lingo, it's a 5x5 wordgame. I made a very basic layout as you can see, I'm using a gridlayout and the squares are all labels, not Jlabels. Now my problem is, how can I add user input to the labels? One letter only. I already wrote a code to control the input, but I'm not sure how to code the input itself.
type: Question
has comment: http://stackoverflow.com/comment/32571773
score: 0
has comment: http://stackoverflow.com/comment/32557417
type: UnansweredQuestion
has title: Lingo game adding input to the gridlayout

http://stackoverflow.com/q/21641245
tagged with: window
has comment: http://stackoverflow.com/comment/32705997
has body: i'm making a program for my job, but when i click run to the already builded program nothing seems to happen, but when i go to the package VIEW , and left click the jFrame mainWindow.java and click run, appears the window and i can actually use the entire functions of the program my question is, how can i make the mainWindow appear with just running the builded program ?????????? Im using Netbeans as IDE and Java as the programming language sorry for my english it's not very good
has comment: http://stackoverflow.com/comment/32705952
answer count: 0
type: UnansweredQuestion
has title: JAVA - The Main Window doesn't appear i have to left click on the mainWindow.java and click run to see it
tagged with: java
type: Question
score: 0

http://stackoverflow.com/q/21642944
score: 0
accepted answer: http://stackoverflow.com/a/21643108
answer count: 1
has body: I am trying to get my whole program to loop again if the user presses yes but I am stuck on what I should be putting. I need it to loop infinitely until the user says no. Any help will be appreciated. public static void main(String[] args) { // TODO Auto-generated method stub String xString = JOptionPane.showInputDialog(null, "Please input the numbers you want to be converted into Roman numerals. " + "Must be between 1000 and 3000"); int input = Integer.parseInt(xString); String output = ""; String zero = "Sorry but the number must be between 1000 and 3000."; while (input == 0){ JOptionPane.showMessageDialog(null, zero); System.exit(0); } while (input &gt; 999 &amp;&amp; input &lt; 3001 &amp;&amp; input != 0) { while (input &gt;= 1000){ output += "M"; input -= 1000;} while (input &gt;= 900){ output += "CM"; input -= 900;} while (input &gt;= 500){ output += "D"; input -= 500;} while (input &gt;= 400){ output += "CD"; input -= 400;} while (input &gt;= 100){ output += "C"; input -= 100;} while (input &gt;= 90){ output += "XC"; input -= 90;} while (input &gt;= 50){ output += "L"; input -= 50;} while (input &gt;= 40){ output += "XL"; input -= 40;} while (input &gt;= 10){ output += "X"; input -= 10;} while (input &gt;= 9){ output += "IX"; input -= 9;} while (input &gt;= 5){ output += "V"; input -= 5;} while (input &gt;= 4){ output += "IV"; input -= 4;} while (input &gt;= 1){ output += "I"; input -= 1;} } String message, incorrect, tryagain; message = "The numerals are " + output +"."; incorrect = "Sorry but the number must be between 1000 and 3000."; if (input == 0) JOptionPane.showMessageDialog(null, message); else JOptionPane.showMessageDialog(null, incorrect); tryagain = "Would you like to try again?"; int again = JOptionPane.showConfirmDialog(null, tryagain, null, JOptionPane.YES_NO_OPTION); while (again == JOptionPane.YES_OPTION){ JOptionPane.showInputDialog(null, /*need help here*/); } while (again == JOptionPane.NO_OPTION){ JOptionPane.showMessageDialog(null, "Clos…
tagged with: while-loop
tagged with: joptionpane
type: AnsweredQuestion
tagged with: loops
type: Question
has title: Java JOptionPane Whole Program Loop
tagged with: java
has answer: http://stackoverflow.com/a/21643108

http://stackoverflow.com/a/21548517
type: Answer
score: 0
has body: Use StringUtils provided by apache StringUtils.equals(myString,comparisonObj.myString);
answers question: http://stackoverflow.com/q/21548440

http://stackoverflow.com/a/21577580
upvote count: 3
type: AcceptedAnswer
downvote count: 0
has body: In short, you can't/shouldn't do this, due to type erasure. Parametrized types exist as such only up to compilation and not during runtime. So you can't have type safety ensured by generics and parametrized types at runtime. They are there to ensure type safety while programming, but all such type information is gone by the time the program is running, as types are substituted as appropriate and what you are left with are non-parametrized normal classes. At best, you can do something like this: obj instanceof ArrayList to check whether obj is an instance of ArrayList and: obj.get(0) instanceof String to check whether the stored objects in the ArrayList are instances of String. Of course, you might want to check whether there are any elements first. Alternatively, you could use reflection (see for example getActualTypeArguments() from the ParametrizedType interface).
has comment: http://stackoverflow.com/comment/32594198
type: Answer
has comment: http://stackoverflow.com/comment/32593780
answers question: http://stackoverflow.com/q/21577430
has comment: http://stackoverflow.com/comment/32593712
accepted answer of: http://stackoverflow.com/q/21577430
score: 3

http://stackoverflow.com/a/21590298
has body: If c-t-e isn't present the c-t-e is binary (which is the same as 8bit and 7bit) and decoding is eeeasy.
answers question: http://stackoverflow.com/q/21586807
type: Answer
score: 0

http://stackoverflow.com/q/21530196
score: 3
upvote count: 3
tagged with: javafx
tagged with: java
type: UnansweredQuestion
has title: MouseDragReleased calling MouseDragExited
has comment: http://stackoverflow.com/comment/32607462
downvote count: 0
answer count: 0
has body: I'm currently working on a battleship game. To support moving the ships in the start up, I tried to add a drag and drop feature. So, I want to have a ship on the field and I drag it and drop it on an empty field to move it. public class DragDetectedHandler implements EventHandler&lt;MouseEvent&gt; { @Override public void handle(MouseEvent e) { System.out.println("drag detected"); PlayingfieldField field = (PlayingfieldField) e.getSource(); field.startFullDrag(); e.consume(); } } public class MouseDragEnteredHandler implements EventHandler&lt;MouseDragEvent&gt; { @Override public void handle(MouseDragEvent e) { System.out.println("drag entered"); e.consume(); } } public class MouseDragExitedHandler implements EventHandler&lt;MouseDragEvent&gt; { @Override public void handle(MouseDragEvent e) { System.out.println("drag exited"); e.consume(); } } public class MouseDragReleasedHandler implements EventHandler&lt;MouseDragEvent&gt; { @Override public void handle(MouseDragEvent e) { System.out.println("drag released"); e.consume(); } } Now, when I drag a ship to another field and drop it, I get the following output: drag detected //Detected drag in start field drag entered //I drag in the start field, so the drag event enters drag exited //I exit the start field drag entered //I enter the second field drag released //I release the mouse drag exited //??? So, as you see, after releasing the mouse, I always get the drag exited event. Does anbody know why, and how I can prevent this?
favorite count: 0
tagged with: drag-and-drop
type: Question

http://stackoverflow.com/comment/32741844
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21661625
score: 0
has text: Hahhaa yeah. Are you using google play game services? Using that with AdMob causes problems

http://stackoverflow.com/q/21588230
type: UnansweredQuestion
tagged with: android
has comment: http://stackoverflow.com/comment/32614323
has answer: http://stackoverflow.com/a/21590155
has comment: http://stackoverflow.com/comment/32613455
tagged with: java
has body: I am trying to read a file numbersmesa11 from my sd, but I have an error in the final while clause that im not sure what to do, i would appreciate any help! im truly stuck private void readVectorFromFile() { InputStreamReader flujo=null; BufferedReader lector=null; try { File ruta = Environment.getExternalStorageDirectory(); File fichero = new File(ruta.getAbsolutePath()+"/BioCasinoStats", "numerosmesa11.txt"); flujo= new InputStreamReader(new FileInputStream(fichero)); lector= new BufferedReader(flujo); String texto = lector.readLine(); while(texto!=null) { tbTexto.setText(texto); texto=lector.readLine(); } } catch (Exception ex) { Log.e("ivan", "Error al leer fichero desde tarjeta SD"); } finally { try { if(lector!=null) lector.close(); } catch (IOException e) { e.printStackTrace(); } } }
type: Question
has comment: http://stackoverflow.com/comment/32614228
has answer: http://stackoverflow.com/a/21590340
tagged with: android-sdcard
score: 0
answer count: 2
has title: code to read text from sd not working
has comment: http://stackoverflow.com/comment/32613423
has comment: http://stackoverflow.com/comment/32613428

http://stackoverflow.com/a/21594805
type: Answer
score: 2
downvote count: 0
has body: The below solution is based on ur question 'Now I want to call a method of a class in some other package from a class in another package.'Not according to the code Class -1 Package abc; Class A { public void demo() { ////////Code } } Class -2 Package def; import abc.A; Class B { public static void main(String arg[]) { A obj = new A(); obj.demo(); // Class A method is called from Class B which is in different package. } }
has comment: http://stackoverflow.com/comment/32624923
upvote count: 2
accepted answer of: http://stackoverflow.com/q/21594457
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21594457

http://stackoverflow.com/a/21540830
downvote count: 0
has body: This isn't returning ==, it's returning the result of length == entry.length. == is an operator which returns true when its left and right side are equal and false otherwise.
upvote count: 2
answers question: http://stackoverflow.com/q/21540804
type: Answer
score: 2

http://stackoverflow.com/a/21663715
has body: If I understand your question correctly, it would not quite make sense to define those as types. They should probably be functions or methods. Like this public class MathUtils { public static int factorialOf(int n) { ... } } But as a strictly legal matter, you can of course create classes called Factorial and Fibonacci that have public methods that presumably perform those operations like the one above.
upvote count: 1
downvote count: 0
score: 1
type: Answer
answers question: http://stackoverflow.com/q/21663627

http://stackoverflow.com/a/21546943
answers question: http://stackoverflow.com/q/21546904
upvote count: 1
type: Answer
has body: You need to initialize your Random with the different seed each time. Try Random random1 = new Random(System.currentTimeMillis()); When Random is initialized with the same seed, it returns the same sequence of random numbers reach time.
downvote count: 0
score: 1

http://stackoverflow.com/comment/32622956
type: QuestionComment
has text: If the `String` starts with `"bab"` or if it contains it? Why would you need recursion to see if it starts with it? You only need to check in one place, the beginning of the `String`.
comment on: http://stackoverflow.com/q/21593825
score: 0
type: Comment

http://stackoverflow.com/a/33476320
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/21565598
type: Answer
has body: You need tomcat websocket if you use jetty org.apache.tomcat.embed tomcat-embed-websocket 8.0.28
score: 0

http://stackoverflow.com/comment/32933785
type: Comment
type: QuestionComment
score: 0
has text: Yea. It's much more complicated than that though. All of the objects defined in the common library, make use of the common singleton and all of its objects. When the plugin fired up, I was passing an instance of the plugin into the common singleton, then referencing that instance from any of the common library functions. Now that I have discovered that there is no isolation between instances of the common singleton between each plugin, I will have to pass an instance of the plugin object into virtually every common library function and/or object instantiation. Can you say BARF!?!
comment on: http://stackoverflow.com/q/21655719

http://stackoverflow.com/comment/32696186
type: Comment
has text: Sorry about you, look for something different, this will not work.
comment on: http://stackoverflow.com/q/21635360
score: 0
type: QuestionComment

http://stackoverflow.com/a/29719606
upvote count: 25
type: Answer
has body: I know the OP uses IntelliJ IDEA, but Android Studio is based on IntelliJ IDEA, so I wanna say one more word. If you use Android Studio, command+;(for Mac) or File-&gt;Project Structure, then in the open window follow the settings:
has comment: http://stackoverflow.com/comment/65815413
score: 25
downvote count: 0
answers question: http://stackoverflow.com/q/21531377

http://stackoverflow.com/q/21640887
tagged with: signal-processing
type: Question
has answer: http://stackoverflow.com/a/21640963
has comment: http://stackoverflow.com/comment/32705378
answer count: 1
score: 0
tagged with: trigonometry
has comment: http://stackoverflow.com/comment/32705326
has body: I can't for the life of my wrap my head around this seemingly easy problem. I am trying to create a sine wave with upper and lower bounds for the amplitude (ie. highest point is 3 and lowest point is 0.4) Using regular math I am able to get a sine wave in an array from 1 to -1 but I don't know how to change those bounds. static int MAX_POINTS = 100; static int CYCLES = 1; static double[] list = new double[100]; public static void SineCurve() { double phaseMultiplier = 2 * Math.PI * CYCLES / MAX_POINTS; for (int i = 0; i &lt; MAX_POINTS; i++) { double cycleX = i * phaseMultiplier; double sineResult = Math.sin(cycleX); list[i]= sineResult; } for(int i=0;i&lt;list.length;i++){ System.out.println(list[i]); } } Any tips would be greatly appreciated.
favorite count: 0
accepted answer: http://stackoverflow.com/a/21640963
upvote count: 2
downvote count: 2
tagged with: audio
type: AnsweredQuestion
tagged with: java
has title: How to create a sin wave with upper and lower amplitude bounds

http://stackoverflow.com/q/21647265
accepted answer: http://stackoverflow.com/a/21650295
score: 0
tagged with: playframework
has title: Play!2.2.1 Java Ebean - Finder.select(String columns) doesn't work : all the columns are selected
has comment: http://stackoverflow.com/comment/32735219
answer count: 1
has body: I've got an issue with the select function of the Finder object by using ebean with Play! Framework (2.2.1). I've got my table AnneePromotion : CREATE TABLE AnneePromotion ( anneePromotion_ID INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('AnneePromotionSequence'), anneePromotion_libelle INTEGER NOT NULL ); My entity AnneePromotion : @Entity @Table(name = "AnneePromotion") @SequenceGenerator(name = "AnneePromotionSequenceGenerator", sequenceName = "AnneePromotionSequence") public class AnneePromotion extends Model { /** serial ID */ private static final long serialVersionUID = -2072489268439045171L; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AnneePromotionSequenceGenerator") @Column(name = "anneePromotion_ID") private Integer id; @Column(name = "anneePromotion_libelle") private String libelle; public Integer getId() { return id; } public String getLibelle() { return libelle; } public void setLibelle(String libelle) { this.libelle = libelle; } public static Finder&lt;Integer, AnneePromotion&gt; find = new Finder&lt;Integer, AnneePromotion&gt;( Integer.class, AnneePromotion.class); } And when I try to use the select function in order to just have libelle : List&lt;AnneePromotion&gt; listeDesAnneesdePromotion = AnneePromotionDao.find .select("libelle").orderBy("libelle asc").findList(); for (AnneePromotion anneepromotion : listeDesAnneesdePromotion){ System.out.println(anneepromotion.getId()+" "+anneepromotion.getLibelle()); } I received my objects with id and libelle columns : 1 2003 2 2004 3 2005 4 2006 5 2007 6 2008 7 2009 8 2010 9 2011 10 2012 11 2013 12 2014 13 2015 14 2016 I don't know with the select function doesn't work, if I made a stupid mistake or not :/ Hope you could help me. Regards, Anthony.
has answer: http://stackoverflow.com/a/21650295
tagged with: ebean
type: AnsweredQuestion
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32721151

http://stackoverflow.com/comment/89373571
comment on: http://stackoverflow.com/a/22290314
score: 1
type: AnswerComment
type: Comment
has text: Just tested this with HttpClient 4.5.2 and it is definitely fixed now. Make sure to set the socket config: `PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(); connManager.setDefaultSocketConfig(SocketConfig.custom().setSoTimeout(35000).build());`

http://stackoverflow.com/comment/32713334
type: AnswerComment
has text: java.lang.Error: Do not use FirstGui.add() use FirstGui.getContentPane().add() instead at javax.swing.JFrame.createRootPaneException(JFrame.java:465) at javax.swing.JFrame.addImpl(JFrame.java:491) at java.awt.Container.add(Container.java:518) at FirstGui.<init>(FirstGui.java:11) at FirstGui.main(FirstGui.java:18)
type: Comment
comment on: http://stackoverflow.com/a/21645448
score: 0

http://stackoverflow.com/q/21625214
upvote count: 7
tagged with: eclipse
has comment: http://stackoverflow.com/comment/32676890
type: Question
has answer: http://stackoverflow.com/a/21625572
has answer: http://stackoverflow.com/a/21625326
linked to: http://stackoverflow.com/q/67299
has body: Background Sometimes, functions return null on some cases, and yet whoever uses them wasn't aware of it, so NPE is inevitable . For example (and it's just an example, to show what I'm talking about) : public class Test { public static void main(final String[] args) { final int t=0; System.out.println("result:"+foo(t).toString()); // no warning here... } public static String foo(final int t) { if(t&gt;0) return "positive"; else return null; } } The problem Eclipse doesn't warn about such a thing, and it doesn't even have it on the settings. It can detect such problems only when there are no functions involved (see my edit below). Not only that, but I can't find an annotation that says that the returned value can be null. I think it has the opposite though. What I've tried So I thought that since Eclipse doesn't have some checks (and it's fine), I could use alternative static code analysis tools, like FindBugs and CodePro Analytix . Both failed to find such bugs. I've tried to contact both projects, but didn't get any answer yet. for CodePro I'm not even sure if I did it right... In fact, I think this project has been discontinued (last update on 2010...). The question Is there any tool that can help avoiding such bugs? EDIT: since many have thought that this is solvable by just changing the code, consider working in a huge team where some people might have forgotten about it (everyone can make mistakes). Or maybe you are even working on a project that uses an SDK (which could even be closed source) that can return null on some cases, but it's not documented because the creator of the SDK forgot about it. Such a thing can happen, no matter how good you are as a programmer. What I ask for is a way to overcome this by letting eclipse help. it should be able to warn me, at least on basic examples as i've written here. Eclipse should be able to do such checks, just like it can warn me about this example: int t=0; --t; String s="s"; if(t&lt;0) s=null; System.out.println(s.…
tagged with: nullpointerexception
answer count: 3
has comment: http://stackoverflow.com/comment/32677930
tagged with: static-code-analysis
has comment: http://stackoverflow.com/comment/32677340
has answer: http://stackoverflow.com/a/21626017
favorite count: 0
has title: How to get warned about NPE caused by functions returning null?
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32677917
score: 6
has comment: http://stackoverflow.com/comment/32676993
downvote count: 1
has comment: http://stackoverflow.com/comment/32677965
has comment: http://stackoverflow.com/comment/32677134
has comment: http://stackoverflow.com/comment/32677319
tagged with: java
has comment: http://stackoverflow.com/comment/32677237
tagged with: eclipse-jdt

http://stackoverflow.com/comment/32557758
has text: thanks for the tip, here my error:
type: Comment
comment on: http://stackoverflow.com/q/21557529
type: QuestionComment
score: 0

http://stackoverflow.com/q/21526431
has answer: http://stackoverflow.com/a/21849832
has comment: http://stackoverflow.com/comment/33074414
has body: I've faced with problem when I'm trying to call service method and check before that some condition @Path("service") public class MyService { @POST @Path("process") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.TEXT_PLAIN) public static Response process(@Context HttpServletRequest request, @FormParam("text") final String text) throws JSONException, IOException { boolean someCondition = true; // for example System.out.println("I'm here"); //* if (!someCondition) { return MyClass1.process(request, text); } else { return MyClass2.process(request, text); } } In class MyClass1 and MyClass2 I have next method signature public static Response process(@Context HttpServletRequest request, @FormParam("text") final String text) throws JSONException, IOException I get not found response on calling this method service, and even row with * comment wasn't printed. How I can resolve this problem?
type: UnansweredQuestion
tagged with: web-services
tagged with: java
type: Question
has title: Apache Wink 1.2.1 conditional call service method
answer count: 1
tagged with: apache-wink
score: 0
tagged with: rest

http://stackoverflow.com/comment/32723981
comment on: http://stackoverflow.com/q/21651816
score: 0
has text: Ah Javadoc, thanks, I'll start there.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32521053
type: Comment
comment on: http://stackoverflow.com/a/21536327
score: 1
type: AnswerComment
has text: You forgot about default access modifier (written without access modifier) which seems to be problem here.

http://stackoverflow.com/a/21636024
downvote count: 0
type: Answer
score: 1
has body: Instead of using a list you could use a Map, for example a HashMap - assuming your id is an int, it could look like: Map&lt;Integer, MyCustomObject&gt; objects = new HashMap&lt;&gt;(); //populate objects.put(someCustomObject.getId(), someCustomObject); //find an id: CustomObject obj = objects.get(someId); note: that assumes that the ids are unique.
upvote count: 1
answers question: http://stackoverflow.com/q/21635989

http://stackoverflow.com/a/21598861
has comment: http://stackoverflow.com/comment/32675195
has comment: http://stackoverflow.com/comment/32760124
has comment: http://stackoverflow.com/comment/32755907
has comment: http://stackoverflow.com/comment/32756708
has comment: http://stackoverflow.com/comment/32631780
has comment: http://stackoverflow.com/comment/32757625
upvote count: 1
has comment: http://stackoverflow.com/comment/32667640
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32667782
has comment: http://stackoverflow.com/comment/32766711
has comment: http://stackoverflow.com/comment/32631646
has comment: http://stackoverflow.com/comment/32756739
type: Answer
has comment: http://stackoverflow.com/comment/32667509
has comment: http://stackoverflow.com/comment/32755749
has comment: http://stackoverflow.com/comment/32675525
has comment: http://stackoverflow.com/comment/32675272
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21598778
has comment: http://stackoverflow.com/comment/32632572
score: 1
has comment: http://stackoverflow.com/comment/32766981
answers question: http://stackoverflow.com/q/21598778
has comment: http://stackoverflow.com/comment/32667752
has body: I think You have to map your servlet in the web.xml, and the servlet-url you have to provide in the page. Something like below whould work. <jsp:include page="/ServletCode" flush="true" > Servlet1 pack.exp.ServletCode Servlet1 /ServletCode UPDATE This is working for me SERVLET @WebServlet("/ServletCode") public class ServletCode extends HttpServlet { private static final long serialVersionUID = 1L; public ServletCode() { super(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String output= request.getParameter("username"); System.out.println(output); PrintWriter pw = response.getWriter(); pw.println("Hello " + output); } } JSP <jsp:include page="/ServletCode" flush="true"> <jsp:param name="username" value="Hello" /> </jsp:include>
has comment: http://stackoverflow.com/comment/32756774
has comment: http://stackoverflow.com/comment/32755865

http://stackoverflow.com/comment/32613556
comment on: http://stackoverflow.com/q/21587190
score: 0
type: Comment
type: QuestionComment
has text: You are referencing the Java perspective - have you include the JDT plugins so that this is available?

http://stackoverflow.com/comment/32493073
has text: i have two devices and i have registered them for both, in the database i have two different registeration ids now, But the app only sends message to the registration id associated with its own
score: 0
comment on: http://stackoverflow.com/q/21520011
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/32503935
type: QuestionComment
has text: Also note that "// A lot of code..." is not a good practice. You should separate your methods to small units. Your design sounds horrible.
score: 1
comment on: http://stackoverflow.com/q/21527099
type: Comment

http://stackoverflow.com/a/21617048
has comment: http://stackoverflow.com/comment/32664133
has comment: http://stackoverflow.com/comment/32664019
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/32664264
has comment: http://stackoverflow.com/comment/32664330
has comment: http://stackoverflow.com/comment/32663976
has comment: http://stackoverflow.com/comment/32666766
has body: What about private static Vector&lt;Point&gt; setupLetter(String letter){ try { JSONArray jsonArr = jsonObj.getJSONArray(letter); System.out.println("IS here"); //get array corresponding to letter if(jsonArr!=null){ Vector&lt;Point&gt; letterPoints = new Vector&lt;Point&gt;(); System.out.println("IS here"); for(int k = 0; k &lt; jsonArr.length(); k++ ){ JSONArray arr = jsonArr.getJSONArray(k); letterPoints.add(new Point(arr.getInt(0), arr.getInt(1))); System.out.println(letterPoints); }return letterPoints ; }else{ System.out.println("%s is null".format(letter)); } } catch (JSONException e){ // TODO Auto-generated catch block e.printStackTrace(); } return null; }
has comment: http://stackoverflow.com/comment/32664408
answers question: http://stackoverflow.com/q/21616939
has comment: http://stackoverflow.com/comment/32664057

http://stackoverflow.com/comment/32522409
has text: First, I don't think it matters what encoding the VC++ app uses in memory, it's what it sends over the Socket. So, the question is: Is it easier to change your Java app to send CP1252, or is it easier to change the VC++ app to send UTF-8. I would prefer the latter, as I am a *nix head and hate everything Windows. But, I think that is a complete and total opinion based solely on my hatred.
comment on: http://stackoverflow.com/a/21536853
type: AnswerComment
type: Comment
score: 1

http://stackoverflow.com/a/21552523
upvote count: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21539258
answers question: http://stackoverflow.com/q/21539258
type: Answer
has body: You don't seem to be maintaining both sides of your relationships in the code shown. Calling setSecondCustomerRelationship Will set one side of it, and this side controls the foreign key field in the db. But your java object model is out of sync with your changes unless you also add the customerRelationship to customerMainInformation's collection. JPA does not maintain your relationships for you, so if you change one side, you are responsible for keeping the other side insync. You can either set both sides, or force the customerMainInformation to be refreshed from the database after you commit. The first option is far more efficient.
downvote count: 0
score: 1

inheritance
tags question: http://stackoverflow.com/q/21609076
tags question: http://stackoverflow.com/q/21583399
tags question: http://stackoverflow.com/q/21655753
tags question: http://stackoverflow.com/q/21652761
tags question: http://stackoverflow.com/q/21669150
tag name: inheritance
tags question: http://stackoverflow.com/q/21561214
tags question: http://stackoverflow.com/q/21568253
tags question: http://stackoverflow.com/q/21652465
tags question: http://stackoverflow.com/q/21664959
type: Tag
tags question: http://stackoverflow.com/q/21523447
tags question: http://stackoverflow.com/q/21527976
tags question: http://stackoverflow.com/q/21591398
tags question: http://stackoverflow.com/q/21588671
tags question: http://stackoverflow.com/q/21556415
tags question: http://stackoverflow.com/q/21615337
tags question: http://stackoverflow.com/q/21612210
tags question: http://stackoverflow.com/q/21668288
tags question: http://stackoverflow.com/q/21632979
tags question: http://stackoverflow.com/q/21647562
tags question: http://stackoverflow.com/q/21605594
tags question: http://stackoverflow.com/q/21558363
tags question: http://stackoverflow.com/q/21672199
tags question: http://stackoverflow.com/q/21647271
tags question: http://stackoverflow.com/q/21670525
tags question: http://stackoverflow.com/q/21612365
tags question: http://stackoverflow.com/q/21623706
tags question: http://stackoverflow.com/q/21608411
tags question: http://stackoverflow.com/q/21618452

http://stackoverflow.com/q/21670627
score: 0
tagged with: oracle-database
has answer: http://stackoverflow.com/a/21670743
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21671012
has body: I'm using oracle 10g to create table but it is showing "ORA-00922: missing or invalid option" and in the query at bottom sequence line for .nextval it is showing red mark line, from long time searching for it. CREATE TABLE "TICKET_TABLE" ( "TKT_NUMBER" NUMBER NOT NULL ENABLE, "TKT_STATUS" VARCHAR2(10), "TKT_CLIENT" VARCHAR2(10), "TKT_ASSIGN" VARCHAR2(15), "TKT_PROJ" VARCHAR2(15), "TKT_SUB" VARCHAR2(100), "TKT_BODY" VARCHAR2(200), "USER_NAME" VARCHAR2(15) NOT NULL ENABLE, CONSTRAINT "TICKET_TABLE_PK" PRIMARY KEY ("TKT_NUMBER") ENABLE) / CREATE OR REPLACE TRIGGER "BI_TICKET_TABLE" before insert on "TICKET_TABLE" for each row begin select "TICKET_SEQ".nextval into :NEW.TKT_NUMBER from dual; end; / ALTER TRIGGER "BI_TICKET_TABLE" ENABLE /
has comment: http://stackoverflow.com/comment/32756943
has comment: http://stackoverflow.com/comment/32757301
tagged with: java
type: Question
answer count: 2
has title: Im using oracle 10g to create table but it is showing "ORA-00922: missing or invalid option" and in the query

http://stackoverflow.com/comment/32721840
type: AnswerComment
has text: @evildead even dexguard must store it's decryption secret within your app and (although that may not have happened so far because they are probably good at hiding it) that secret is within the hands of the attacker and can be found. An open source version of that would spoil all the secret way they use and just giving out such software for free is unlikely because you have to improve it in secret all the time - a few people working on hiding vs many people working on unhiding.
score: 0
comment on: http://stackoverflow.com/a/21647060
type: Comment

http://stackoverflow.com/q/21592269
answer count: 1
has answer: http://stackoverflow.com/a/21592394
accepted answer: http://stackoverflow.com/a/21592394
tagged with: jetty
has body: I'm working through some Spring MVC examples, and using Jetty jetty-9.1.1.v20140108 as my dev server. I have another server, JBOSS 5.1.0 listening on port 8080, so I tried to specify an alternate port for Jetty, however, it didnt seem to "stick". What am I doing wrong here? $ java -Djetty.port=9000 -jar start.jar ... INFO: FrameworkServlet 'spring-example': initialization completed in 142 ms 2014-02-05 17:27:50.369:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext@45ad71f0{/spring-example,file:/tmp/jetty-0.0.0.0-8080-spring-example.war-_spring-example-any-1672792505692467455.dir/webapp/,AVAILABLE}{/spring-example.war} 2014-02-05 17:27:50.374:WARN:oejuc.AbstractLifeCycle:main: FAILED ServerConnector@228643af{HTTP/1.1}{0.0.0.0:8080}: java.net.BindException: Address already in use java.net.BindException: Address already in use at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Net.java:444) at sun.nio.ch.Net.bind(Net.java:436) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:279) at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80) at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:218) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69) ... Maybe there is another port setting that takes priority, but I would think the command line would trump all. How do I set the port correctly?
type: AnsweredQuestion
has title: Jetty Seems to Ignore Port Argument
score: 0
tagged with: java
type: Question

http://stackoverflow.com/comment/32710448
has text: tried that too, but no luck. btw the source page is working now. can you please check if its working on your end
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21643704

http://stackoverflow.com/q/21658363
has comment: http://stackoverflow.com/comment/32735394
has answer: http://stackoverflow.com/a/21658382
tagged with: java
has comment: http://stackoverflow.com/comment/32735229
has answer: http://stackoverflow.com/a/21658388
has comment: http://stackoverflow.com/comment/32735232
score: 0
linked to: http://stackoverflow.com/q/4756558
has comment: http://stackoverflow.com/comment/32735399
possible better answer: http://stackoverflow.com/a/21658388
duplicate of: http://stackoverflow.com/q/4756558
has title: Is it possible to return more than one value in java function?
accepted answer: http://stackoverflow.com/a/21658382
has comment: http://stackoverflow.com/comment/32735393
has comment: http://stackoverflow.com/comment/32735333
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21658428
has body: Is it possible to return more than one value in java function? Like , public void retTest() { return (30,40,50); } //From Caller fun int a,b,c; (a,b,c) = retTest();
type: Question
has answer: http://stackoverflow.com/a/21658400

http://stackoverflow.com/comment/32538853
comment on: http://stackoverflow.com/a/21546995
type: Comment
has text: Thanks worked. but another error here i am getting AlertDialog alert = builder.create(); alert.setButton2("Exit", new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog, int which) { //close the program AndroidDetectInternetConnectionActivity.this.finish(); } });
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32741740
comment on: http://stackoverflow.com/a/21662135
type: AnswerComment
type: Comment
has text: It is essentially the same thing as the integer division `/2`, though.
score: 4

http://stackoverflow.com/a/21627394
answers question: http://stackoverflow.com/q/21627164
accepted answer of: http://stackoverflow.com/q/21627164
has comment: http://stackoverflow.com/comment/32687510
has comment: http://stackoverflow.com/comment/32685022
has body: It's probably something to do with the fact you have a local field called node and a class variable called node both of which are Node classes and both of which are mocks. I would remove the test local node altogether, or rename it if you really want a test-local mock node EDIT My previous answer was wrong, and should really have been a comment. The hidden objects weren't causing any problems. (Although I still think they should have been removed/renamed) The actual problem here is that the method you are trying to mock is final and as such, can't be mocked. When EasyMock mocks method/classes, it does so by extending and overriding them. So final classes and final methods cannot be mocked with EasyMock as they can't be overridden. The call to the getParentNode() method is not mocked and as such isn't registered during the record state within the expectation call.
upvote count: 0
type: AcceptedAnswer
type: Answer
score: -1
downvote count: 1

http://stackoverflow.com/a/21612608
type: Answer
score: 2
upvote count: 2
has body: Exception is because you are iterating as well as removing the element from the list for (Integer integer : list) { // Exception is here because you are iterating and also removing the elements of same list here if (integer.equals(2)) { list.remove(integer); }
downvote count: 0
answers question: http://stackoverflow.com/q/21612196

http://stackoverflow.com/comment/32549615
type: Comment
score: 0
comment on: http://stackoverflow.com/q/21529798
type: QuestionComment
has text: Have you got 2 differing versions of `xml-apis`?

http://stackoverflow.com/a/21668158
has comment: http://stackoverflow.com/comment/32752884
answers question: http://stackoverflow.com/q/21668126
has comment: http://stackoverflow.com/comment/32753040
upvote count: 1
has comment: http://stackoverflow.com/comment/32752864
type: Answer
has comment: http://stackoverflow.com/comment/32752911
downvote count: 0
score: 1
has body: No need to use array. It would be easy like this:(Assuming str value must contains one '.' ) int numDecimalDigits = str.split("\\.")[1].length(); Or you can do by subtracting str.length()-1 with indexOf(".") int numDecimalDigits = str.length()-1 - str.indexOf(".");

http://stackoverflow.com/q/21628461
has answer: http://stackoverflow.com/a/21628545
has title: How to replace a repeated char with some characters or string
score: 0
has body: I need to replace a repeated char with $% followed by the char followed by $%. e.g. "HELLO" will become "HE$%L$%O" The following code that I wrote gives "HE$%L$%LO". Please guide int index=0; String str1=""; String str2=""; String str4=""; String str5=""; for(int i=0;i&lt;str.length();i++) { char ch=str.charAt(i); index=str.indexOf(ch); if(index!=i) { str4="$%"+str.charAt(index)+ "$%"; str1=str.charAt(index)+str5; str2=str.replaceFirst(str1,str4); } } return str2;
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32682529
has answer: http://stackoverflow.com/a/21629609
type: Question
tagged with: java
answer count: 2

http://stackoverflow.com/comment/32498920
score: 1
comment on: http://stackoverflow.com/a/21524246
has text: I would also add that `sun.awt.windows.WToolkit` is an implementation for the Window platform on Windows. If you run that code on linux you get `sun.awt.X11.XToolkit`, which is the same thing but changes name according to the window manager :)
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32512375
has text: Yes. but keep in mind that if you want to use tomcat7w.exe the word from the file name before the "w" needs to be the name of your service [tomcat_service_name]w.exe (you can simply rename the file if it's not your case)
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21531656

http://stackoverflow.com/comment/32633835
has text: You have a sort method that you dont call anywhere, so even if it was correct, wouldnt do you much good. Also, you should read: http://docs.oracle.com/javase/tutorial/collections/algorithms/#sorting
comment on: http://stackoverflow.com/q/21600412
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32587684
type: Comment
type: QuestionComment
has text: Because the inflow streams are incremented untill finished. So `end=1` is the total mass of the old inflow. We only need this value as it contains all the information of the same flow where `end=0`.
score: 0
comment on: http://stackoverflow.com/q/21573706

http://stackoverflow.com/q/21590765
tagged with: java
has body: I'm trying to restore an Apache Derby Database via Java. While researching I found the following page http://db.apache.org/derby/docs/10.3/adminguide/tadminhubbkup44.html . As far as I understand I got to have a running connection to the server and use the given URL to make a restore happen. I'm not sure how to restart and restore the running server in Java using this URL.
has comment: http://stackoverflow.com/comment/32643693
type: Question
answer count: 1
tagged with: restore
tagged with: derby
score: 0
tagged with: jdbc
has answer: http://stackoverflow.com/a/21632295
type: UnansweredQuestion
has title: Restoring Derby-Database via Java

http://stackoverflow.com/q/21588671
has answer: http://stackoverflow.com/a/21591575
tagged with: abstract-class
type: AnsweredQuestion
score: 1
has answer: http://stackoverflow.com/a/21588755
tagged with: generics
favorite count: 0
type: Question
answer count: 2
possible better answer: http://stackoverflow.com/a/21588755
accepted answer: http://stackoverflow.com/a/21591575
upvote count: 1
tagged with: java
has body: Is it possible in an abstract class to have a method that 'generically' returns an instance of the class that extends it?
has title: Method in abstract class returning an instance of the class that implements it
downvote count: 0
tagged with: inheritance

http://stackoverflow.com/a/21658382
has body: No its not possible. But you can use return an object which encapsulates all your data.In that way coding,debugging and data extraction becomes easier as well as code enhancability is greatly increased.. such as :- class Resut{ int a,b,c; } retTest() { return new Result(); }
upvote count: 3
score: 3
accepted answer of: http://stackoverflow.com/q/21658363
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21658363
type: Answer

http://stackoverflow.com/comment/32599541
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21580052
has text: And after that, how must i replace my existing code in my adapter to have the global reference to the imageLoader instance ?
type: AnswerComment

http://stackoverflow.com/a/21530795
has comment: http://stackoverflow.com/comment/32510968
has comment: http://stackoverflow.com/comment/32511122
answers question: http://stackoverflow.com/q/21530411
has comment: http://stackoverflow.com/comment/32510828
has body: You seem to be missing the constraints package name in your code import org.hibernate.validator.constraints.Length;
accepted answer of: http://stackoverflow.com/q/21530411
has comment: http://stackoverflow.com/comment/32511220
downvote count: 0
score: 2
has comment: http://stackoverflow.com/comment/32513844
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32511955
has comment: http://stackoverflow.com/comment/32512119
upvote count: 2
type: Answer

http://stackoverflow.com/q/21657249
has body: I have constructed graphs with JUNG but I'm not sure how to add mouse action listeners to the vertices of the graph. Below is a sample section of my code that I think is the most relevant for the problem. layout = new FRLayout2&lt;GraphNode, GraphEdge&gt;(graph); visualizationViewer = new VisualizationViewer&lt;GraphNode, GraphEdge&gt;(layout, new Dimension(1000, 700)); visualizationViewer.getModel().getRelaxer().setSleepTime(500); visualizationViewer.setGraphMouse(new DefaultModalGraphMouse&lt;GraphNode, String&gt;()); visualizationViewer.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.AUTO); visualizationViewer.setForeground(Color.black); In particular, I want to detect single and double clicks on the vertices of a graph and act on them. Note: I have seen a couple of old SO links, but none of the answers seem to be helping me. If someone can just give me the pseudocode or point me to the right direction, it would be really helpful.
answer count: 1
downvote count: 0
favorite count: 0
has title: Mouse events on vertex of JUNG graph
has answer: http://stackoverflow.com/a/22054880
type: AnsweredQuestion
score: 3
upvote count: 3
tagged with: java
tagged with: jung2
type: Question
has comment: http://stackoverflow.com/comment/33444627
accepted answer: http://stackoverflow.com/a/22054880
tagged with: mouseevent

awt
tags question: http://stackoverflow.com/q/21579491
tags question: http://stackoverflow.com/q/21539847
tags question: http://stackoverflow.com/q/21658870
tags question: http://stackoverflow.com/q/21631276
tags question: http://stackoverflow.com/q/21646828
tags question: http://stackoverflow.com/q/21519093
tags question: http://stackoverflow.com/q/21608291
tags question: http://stackoverflow.com/q/21529667
tags question: http://stackoverflow.com/q/21623872
tag name: awt
tags question: http://stackoverflow.com/q/21587972
tags question: http://stackoverflow.com/q/21657886
tags question: http://stackoverflow.com/q/21546540
tags question: http://stackoverflow.com/q/21565810
tags question: http://stackoverflow.com/q/21542554
tags question: http://stackoverflow.com/q/21523883
tags question: http://stackoverflow.com/q/21573986
tags question: http://stackoverflow.com/q/21645565
tags question: http://stackoverflow.com/q/21592492
tags question: http://stackoverflow.com/q/21617162
tags question: http://stackoverflow.com/q/21597822
tags question: http://stackoverflow.com/q/21567901
tags question: http://stackoverflow.com/q/21531632
tags question: http://stackoverflow.com/q/21656940
type: Tag
tags question: http://stackoverflow.com/q/21648285
tags question: http://stackoverflow.com/q/21519250
tags question: http://stackoverflow.com/q/21646506

http://stackoverflow.com/q/21526647
answer count: 2
score: 0
tagged with: http-get
type: UnansweredQuestion
tagged with: android
tagged with: web-services
has answer: http://stackoverflow.com/a/21527051
has body: hello everyone I want to send two parameters to server android id installed app information I wrote a code to know installed app and print in logcat and also android_id but when I try to send installed app information on server I have a error code public class MainActivity extends Activity { String AppName; String android_id; PackageInfo packageInfo; String installedapps; StringBuilder sb; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); android_id = Secure.getString(MainActivity.this.getContentResolver(), Secure.ANDROID_ID); getInstalledApps(); } public void getInstalledApps() { List&lt;PackageInfo&gt; PackList = getPackageManager() .getInstalledPackages(0); sb = new StringBuilder(); for (int i = 0; i &lt; PackList.size(); i++) { PackageInfo PackInfo = PackList.get(i); if (((PackInfo.applicationInfo.flags &amp; ApplicationInfo.FLAG_SYSTEM) != 0) != true) { AppName = PackInfo.applicationInfo.loadLabel( getPackageManager()).toString(); Log.d("install ", AppName); sb.append(AppName + "\""); } } Toast.makeText(getApplicationContext(), sb.toString(), Toast.LENGTH_LONG).show(); Log.d("install232222222 ", sb.toString()); connectWithHttpGet(android_id, sb.toString()); } private void connectWithHttpGet(String diviceID, String InstalledApps) { class HttpGetAsyncTask extends AsyncTask&lt;String, Void, String&gt; { @Override protected String doInBackground(String... params) { String deviceId = params[0]; String list = params[1]; System.out.println("diviceID is :" + deviceId + " InstalledApps is :" + list); HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet( "http://************/api/***********.aspx?deviceId=" + deviceId + "&amp;list=" + list); try { HttpResponse httpResponse = httpClient.execute(httpGet); System.out.println("httpResponse"); InputStream inputStream = httpResponse.getEntity() .getContent(); InputStreamReader inputStreamReader = new InputStreamRea…
has answer: http://stackoverflow.com/a/21526886
linked to: http://stackoverflow.com/q/2659952
tagged with: java
has title: android send two parameters to server
type: Question

http://stackoverflow.com/comment/32578797
type: Comment
score: 0
type: QuestionComment
has text: Could you also upload an image with a signature?
comment on: http://stackoverflow.com/q/21561542

http://stackoverflow.com/q/21641431
tagged with: scheduled-tasks
favorite count: 0
has body: I have several Java applications that implements ETL helper function. They should run each X minutes. It's good task for cron, but I also need to monitor them - when previous run started, how much time it took, did it fail, when next one will starts etc. Could you advice some scheduling tool with described functionality? It will be also interesting for me to know what scheduling software is used in your company and what kind of problems does it solve. UPDATE. Guys, I need standalone application, not scheduling inside existent ones. I don't need to read tons of logs and investigate them - just know that something goes wring with scheduled job.
has answer: http://stackoverflow.com/a/21805990
accepted answer: http://stackoverflow.com/a/21805990
type: AnsweredQuestion
score: 3
downvote count: 0
has answer: http://stackoverflow.com/a/21797140
tagged with: java
has answer: http://stackoverflow.com/a/21699285
tagged with: etl
has answer: http://stackoverflow.com/a/21727308
possible better answer: http://stackoverflow.com/a/21698888
type: Question
has answer: http://stackoverflow.com/a/21698888
has answer: http://stackoverflow.com/a/21786428
has title: Scheduler with monitoring features
tagged with: scheduler
upvote count: 3
has answer: http://stackoverflow.com/a/21698983
answer count: 7

http://stackoverflow.com/a/28864504
type: Answer
has body: My example is searching for users of my application by name. I created one document for each user, and that document contains every possible string that you can search for. For example, the document for user "John Smith" has one string: search input delimited by spaces: "joh ohn smi smit mith (etc)". Here the code I used to get this to work. The "id" is the id for the user in my backend datastore. private void createSearchableUserDoc(String id, String displayName) { List&lt;String&gt; substrings = buildAllSubstrings(displayName); String combinedString = combine(substrings, " "); // The input for this looks like "CHR CHRI CHRIS HRI HRIS" etc... createUserDocument(id, combinedString); } private List&lt;String&gt; buildAllSubstrings(String displayName) { List&lt;String&gt; substrings = new ArrayList&lt;String&gt;(); for (String word : displayName.split(" ")) { int wordSize = 1; while (true) { for (int i = 0; i &lt; word.length() - wordSize + 1; i++) { substrings.add(word.substring(i, i + wordSize)); } if (wordSize == word.length()) break; wordSize++; } } return substrings; } private String combine(List&lt;String&gt; strings, String glue) { int k = strings.size(); if (k == 0) return null; StringBuilder out = new StringBuilder(); out.append(strings.get(0)); for (int x = 1; x &lt; k; ++x) out.append(glue).append(strings.get(x)); return out.toString(); } private void createUserDocument(String id, String searchableSubstring) { Builder docBuilder = Document .newBuilder() .setId(id) .addField( Field.newBuilder().setName("Display_Name") .setText(searchableSubstring)); addDocToIndex(docBuilder.build()); } private void addDocToIndex(Document document) { Index index = getUserDocIndex(); try { index.put(document); } catch (PutException e) { log.severe("Error putting document in index... trying again."); if (StatusCode.TRANSIENT_ERROR.equals(e.getOperationResult().getCode())) { index.put(document); } } } public static Index getUserDocIndex() { IndexSpec indexSpec = IndexSpec.newBui…
has comment: http://stackoverflow.com/comment/59190620
score: 3
downvote count: 0
upvote count: 3
answers question: http://stackoverflow.com/q/21523195

http://stackoverflow.com/q/21576670
downvote count: 1
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/21615667
has title: Executing script(.bat and .sh) inside the bundle
score: 0
tagged with: batch-file
has body: My bundle contains a script(.bat and .sh) in the Resources folder. It is necessary to execute this script inside the bundle. How could I achieve this in the OSGi world ? Example would be a.w.e.s.o.m.e
tagged with: shell
tagged with: exec
favorite count: 0
accepted answer: http://stackoverflow.com/a/21615667
tagged with: osgi
upvote count: 1
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32638254
possible better answer: http://stackoverflow.com/a/21588894
tagged with: java
linked to: http://stackoverflow.com/q/6474634
has answer: http://stackoverflow.com/a/21588894

http://stackoverflow.com/comment/32712296
score: 0
comment on: http://stackoverflow.com/q/21645206
has text: http://pastebin.com/ycKsF8hY thats the logcat
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32756755
comment on: http://stackoverflow.com/a/21670655
type: AnswerComment
type: Comment
score: 0
has text: You can probably also add a condition which checks if the lowBound is greater than upperBound and throw an exception for the same or ask the user to re-enter the values. (if you want it to be user-driven, otherwise you can proceed with hardcoded stuff).

http://stackoverflow.com/comment/32765954
score: 0
type: Comment
type: QuestionComment
has text: It would be easier if you provided a complete example (i.e. a populated array).
comment on: http://stackoverflow.com/q/21676189

http://stackoverflow.com/comment/32686748
type: AnswerComment
score: 0
has text: I have 4 - *xmlns:xsi xmlns:aop xmlns:util xmlns:context* at the begining of file and 3(beans util context) at the end. Is it normally?
type: Comment
comment on: http://stackoverflow.com/a/21630392

http://stackoverflow.com/comment/51528125
comment on: http://stackoverflow.com/a/21664992
type: Comment
score: 0
type: AnswerComment
has text: @Mureinik, How can I join the table where I am using table name as variable

http://stackoverflow.com/q/21633196
tagged with: file
has body: I created a program that has an array of values and asks the user to enter a value. It then checks the user input against the array values and displays if it's valid or not. The second part of the problem that I'm having trouble with is essentially doing the same thing, but reading the same values from a text file. Any help is very much appreciated! Here's my code for the first problem: import java.util.Scanner; public class ChargeAccount2 { public static void main(String[] args) { int results; int accountNum; int[] values={5658845,8080152,1005231,4520125,4562555,6545231,7895122,5552012,3852085,8777541,5050552,7576651,8451277,7825877,7881200,1302850,1250255,4581002}; Scanner keyboard = new Scanner(System.in); System.out.println("Enter a charge account #:"); accountNum = keyboard.nextInt(); results = ChargeAccountSearchArray.sequentialSearch(values,accountNum); if (results == -1) { System.out.println(accountNum + " is not valid."); } else { System.out.println(accountNum + " is valid."); } } } And here's the SearchArray program: public class ChargeAccountSearchArray { public static int sequentialSearch(int[] array, int value) { int index, element; boolean found; index = 0; element = -1; found = false; while (!found &amp;&amp; index &lt; array.length) { if (array[index] == value) { found = true; element = index; } index++; } return element; } }
type: Question
has comment: http://stackoverflow.com/comment/32691284
has comment: http://stackoverflow.com/comment/32692265
tagged with: java
has title: Read Text File Array to Check Value
has comment: http://stackoverflow.com/comment/32696956
tagged with: arrays
answer count: 1
has comment: http://stackoverflow.com/comment/32692750
has answer: http://stackoverflow.com/a/21633258
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32691349
score: 0

http://stackoverflow.com/comment/32617006
type: Comment
comment on: http://stackoverflow.com/q/21589971
has text: Generally I want my networking layer to let me read stuff straight out of its buffers.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/32727415
score: 3
comment on: http://stackoverflow.com/q/21653796
type: QuestionComment
type: Comment
has text: The stream classes couldn't have been designed like that, because they were designed before this feature was added (i.e., generics).

http://stackoverflow.com/comment/32690830
type: AnswerComment
has text: Correct, as I mentioned 'just to cater to your whim'. I completely agree cssSelector is best bet in this case, as it is faster than xpath.
type: Comment
comment on: http://stackoverflow.com/a/21631756
score: 1

http://stackoverflow.com/a/21609709
score: 1
upvote count: 1
has body: This line causes the error: IOThread.getInstance().removeAddedClient(client); You are removing client while looping through it. Use iterator.remove() instead.
downvote count: 0
answers question: http://stackoverflow.com/q/21609609
type: Answer

http://stackoverflow.com/a/21586389
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/21586244
downvote count: 0
has body: You need to import the junit Test class. Use this: import org.junit.Test; It would also be best to name your method something other than Test so as not to conflict with this import. Also, you can't use a static method as a Junit test method and your Junit tests shouldn't have arguments. You will get an exception stating that the test method should not be static, and the test method should not take parameters. The whole point of Junit Tests is that you have many individual tests that can be run independently of each other. You don't have any arguments passed into the test. Everything you need should be set up in the test or before the test using one of the @Before annotations. Try something like this: package test; import static org.junit.Assert.*; import org.junit.Test; public class TestClass { @Test public void myTestMethod() { // TODO Auto-generated method stub assertEquals(0, voidMethod(), 0); } static int voidMethod() { return 0; } }

http://stackoverflow.com/q/21639882
upvote count: 2
has comment: http://stackoverflow.com/comment/32703729
tagged with: java
has comment: http://stackoverflow.com/comment/32776227
has comment: http://stackoverflow.com/comment/32705493
has comment: http://stackoverflow.com/comment/32719802
tagged with: sql-like
type: Question
has comment: http://stackoverflow.com/comment/32705575
has comment: http://stackoverflow.com/comment/32703668
tagged with: sql
has body: I'm working on creating a Java interface for an SQL database. I'm using prepared statements to perform the search queries, however they only work with "=" statements and not with LIKE statements. The first sample code using "=" works successfully. The second sample, using a LIKE statement, does not work and just returns empty. WORKS: PreparedStatement SearchQuery = con.prepareStatement("Select * From Alumnus_A Where aFirstName = ? ORDER BY aLastName asc"); SearchQuery.setObject(1, FirstName); ResultSet rs=SearchQuery.executeQuery(); DOESN'T WORK: PreparedStatement SearchQuery = con.prepareStatement("Select * From Alumnus_A Where aFirstName LIKE ? ORDER BY aLastName asc"); SearchQuery.setObject(1, FirstName); ResultSet rs=SearchQuery.executeQuery(); Any help is much appreciated, also if you could explain it to me keeping in mind I'm very new to Java and don't have a lot of programming experience yet. The rest of my search button's code: private void button_SearchActionPerformed(java.awt.event.ActionEvent evt) { String FirstName = textField_FirstName.getText(); String LastName = textField_LastName.getText(); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:Alumni_DB"); Statement st=con.createStatement(); con.commit(); System.out.print(FirstName + " "); PreparedStatement SearchQuery = con.prepareStatement("Select * From Alumnus_A Where aFirstName LIKE ? ORDER BY aLastName asc"); SearchQuery.setString(1, FirstName); ResultSet rs=SearchQuery.executeQuery(); String aUID="",aFName="",aLName="",aMInitial="",aHomePhone="",aCellPhone=""; while(rs.next()) { aUID=rs.getString(1); aFName=rs.getString(2); aLName=rs.getString(3); aMInitial=rs.getString(4); aHomePhone=rs.getString(5); aCellPhone=rs.getString(6); System.out.println("UID " + aUID + " First Name " + aFName + " Last Name " + aLName + " Middle Initial " + aMInitial + " Home Phone " + aHomePhone + " Cell Phone " + aCellPhone); } } catch(Exception e) { System.out.p…
downvote count: 0
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32732404
tagged with: statements
has title: LIKE Statements Not Working in Java SQL Prepared Statement
score: 2
answer count: 0

selenium-webdriver
tags question: http://stackoverflow.com/q/21523199
tags question: http://stackoverflow.com/q/21635503
tags question: http://stackoverflow.com/q/21639902
tags question: http://stackoverflow.com/q/21606391
tags question: http://stackoverflow.com/q/21581038
tags question: http://stackoverflow.com/q/21523824
tags question: http://stackoverflow.com/q/21602125
tags question: http://stackoverflow.com/q/21558868
tags question: http://stackoverflow.com/q/21570201
tags question: http://stackoverflow.com/q/21672998
tags question: http://stackoverflow.com/q/21596106
tags question: http://stackoverflow.com/q/21548237
tags question: http://stackoverflow.com/q/21651033
tags question: http://stackoverflow.com/q/21638622
tags question: http://stackoverflow.com/q/21677258
tags question: http://stackoverflow.com/q/21668684
tag name: selenium-webdriver
tags question: http://stackoverflow.com/q/21587873
tags question: http://stackoverflow.com/q/21574679
tags question: http://stackoverflow.com/q/21519467
tags question: http://stackoverflow.com/q/21644457
tags question: http://stackoverflow.com/q/21591027
tags question: http://stackoverflow.com/q/21634417
tags question: http://stackoverflow.com/q/21558254
tags question: http://stackoverflow.com/q/21588900
type: Tag
tags question: http://stackoverflow.com/q/21515382
tags question: http://stackoverflow.com/q/21596647
tags question: http://stackoverflow.com/q/21554272
tags question: http://stackoverflow.com/q/21523606
tags question: http://stackoverflow.com/q/21625465
tags question: http://stackoverflow.com/q/21618449
tags question: http://stackoverflow.com/q/21628460

http://stackoverflow.com/a/21647603
upvote count: 6
has comment: http://stackoverflow.com/comment/32717480
has comment: http://stackoverflow.com/comment/32716737
has body: The constructor: public B(int x) { super.f(x); f(x); } is translated by the compiler to this: public B(int x) { super(); super.f(x); f(x); } I guess now you would understand, why it's 6.
accepted answer of: http://stackoverflow.com/q/21647562
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21647562
has comment: http://stackoverflow.com/comment/32716699
type: Answer
has comment: http://stackoverflow.com/comment/32716764
downvote count: 0
score: 6

http://stackoverflow.com/comment/32679251
type: Comment
has text: thanks Marko ,for making my understanding about super keyword correct.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/21625140

http://stackoverflow.com/a/21667404
upvote count: 1
answers question: http://stackoverflow.com/q/21667098
downvote count: 0
type: Answer
score: 1
has comment: http://stackoverflow.com/comment/32755988
has body: Maybe you can try to use ArrayLists and implement this code: import java.util.ArrayList; import java.util.List; import java.util.Random; public class oddeven { public static void main(String[] args) { List&lt;Integer&gt; l = new ArrayList&lt;Integer&gt;(); Random rd = new Random(); for (int i=0; i&lt;10;i++){ l.add(rd.nextInt(10)); } List&lt;Integer&gt; lsep = new ArrayList&lt;Integer&gt;(seperator(l)); System.out.println(l); System.out.println(lsep); } public static List&lt;Integer&gt; seperator(List&lt;Integer&gt; l) { List&lt;Integer&gt; sep = new ArrayList&lt;Integer&gt;(); int i = 0; int even=0, odd =0; int len = l.size(); for(i=0; i&lt;len; i++){ if(l.get(i) % 2 == 1) { odd = l.get(i); sep.add(odd); } } for(i=0; i&lt;len; i++){ if(l.get(i) % 2 == 0) { even = l.get(i); sep.add(even); } } return sep; } } Example, For a given input :[8, 9, 9, 2, 9, 5, 8, 3, 10, 6] It will return: [9, 9, 9, 5, 3, 8, 2, 8, 10, 6]

http://stackoverflow.com/comment/32621692
type: QuestionComment
has text: That is how I originally had it. I had the code the exact same except the class name was RandomShapes. I am taking this code directly from a text book thats why I do not understand why it is throwing this error
comment on: http://stackoverflow.com/q/21593014
score: 0
type: Comment

http://stackoverflow.com/a/21525969
answers question: http://stackoverflow.com/q/21525937
type: Answer
has comment: http://stackoverflow.com/comment/32502203
has comment: http://stackoverflow.com/comment/32503316
score: 0
has body: change: FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); to ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); also don't call: setContentView(tlMain); Assuming that you have a table layout in R.layout.act Try to change: TableLayout.LayoutParams rowLp = new TableLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); to: TableLayout.LayoutParams rowLp = new TableLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); My guess is that you have a table row with width Wrap_content and a Textview inside it with width fill_parent. This are contradictory statements and android is not able to draw it.

http://stackoverflow.com/comment/32782036
comment on: http://stackoverflow.com/a/21674540
score: 0
type: AnswerComment
type: Comment
has text: Maybe it's a dumb question, but may I ask you what the unit of the numbers listed under Linpack are? Does this mean that the lower the number is the faster the computation will be? Or the other way?

http://stackoverflow.com/comment/32493951
comment on: http://stackoverflow.com/a/21521355
type: AnswerComment
type: Comment
score: 2
has text: Could you please elaborate your answer to get your idea better

http://stackoverflow.com/a/21621874
type: Answer
has comment: http://stackoverflow.com/comment/32671332
upvote count: 4
answers question: http://stackoverflow.com/q/21621803
has comment: http://stackoverflow.com/comment/32671347
downvote count: 0
score: 4
has body: It's in the javadoc: returns the previous value associated with the specified key, or null if there was no mapping for the key

http://stackoverflow.com/comment/32643121
score: 0
type: Comment
type: QuestionComment
has text: What kind of object? and what fields are in it? I have done some JSON parsing with Jackson. Looks like you need to create your own `deserializer` class to that `defaultValue` field and maybe it should be `public Object defaultValue` then.
comment on: http://stackoverflow.com/q/21538160

http://stackoverflow.com/q/21619577
tagged with: java
has comment: http://stackoverflow.com/comment/32668342
score: 0
tagged with: random
accepted answer: http://stackoverflow.com/a/21619935
answer count: 1
tagged with: arrays
has title: Fastest way to populate a grid with elements randomly
has body: I have a grid: int[][] the_grid = new int[4][4]; and I want to randomly populate it with elements ?, +, -, *, !, /, #, % such that exactly two squares have one of the elements in them. What's the most succinct and efficient way to accomplish this task?
has answer: http://stackoverflow.com/a/21619935
linked to: http://stackoverflow.com/q/4040001
type: AnsweredQuestion
type: Question
has comment: http://stackoverflow.com/comment/32668486
has comment: http://stackoverflow.com/comment/32668422

http://stackoverflow.com/q/21626427
tagged with: java
tagged with: mapreduce
has comment: http://stackoverflow.com/comment/32683721
type: Question
tagged with: hadoop
has comment: http://stackoverflow.com/comment/32689651
has comment: http://stackoverflow.com/comment/32689239
has comment: http://stackoverflow.com/comment/32680976
has title: How to efficiently pass information from a reducer back to the job?
has comment: http://stackoverflow.com/comment/32689455
has body: In a project, I need to pass numeric information from the reducer(s) of a mapreduce task back to the job. The job basically consists on running a series of mapreduce tasks running on the same data, each one being configured by the result of the previous one. Let's have some example: I want to determine what the (possibly multi-field) keys are in a set of data. The fields are named A, B, C, and so on. The successive tasks would be: Calculate the cardinality of A. A is not a key. AB might be. Calculate the cardinality of AB. AB is a key. We can deduce that ABC is, too. But we have to calculate the cardinality of B, AC and BC. [...] Write all keys to a file. Basically, my first idea is to make each cardinality calculation task return a series of counters, one for each candidate, each being assigned exactly once in the reducer. These jobs would have a NullOutputStream for output. The problem with that approach is that the numbers of counters are limited, and the number of candidates for each step can possibly be quite huge. The second idea was to have the reducer output the different counters somewhere on HDFS, and have this passed to the next tasks. Which doesn't work either because the counters are used for the task configuration, but not as its input. Does anybody have a better idea of how I can make this work?
answer count: 0
type: UnansweredQuestion
score: 0
has comment: http://stackoverflow.com/comment/32687455

http://stackoverflow.com/q/21653372
accepted answer: http://stackoverflow.com/a/21654125
possible better answer: http://stackoverflow.com/a/21655763
has answer: http://stackoverflow.com/a/21655763
tagged with: timer
tagged with: swing
has title: Pipe Game - PipeObject in class PipeObject cannot be applied to given types
type: AnsweredQuestion
tagged with: list
score: 0
tagged with: java
linked to: http://stackoverflow.com/q/7143287
type: Question
linked to: http://stackoverflow.com/q/21689021
tagged with: graphics
answer count: 2
has body: I keep getting the error "PipeObject in class PipeObject cannot be applied to given types" public Pipes() { pipes.add(new PipeObject(x1, y1)); pipes.add(new PipeObject(x1 + 200, y2)); pipes.add(new PipeObject(x1 + 400, y3)); } I have an object class that I want to be added to a JPanel by a class that controls the objects and draws 3 instances of it to the screen. It needs to be able to give different values to the object class. My third class is the main() class and should add the class with the grouped objects to a JPanel in a cardLayout. There is also a menu screen with a play button on it, and the objects should not move until boolean playerIsReady = true. The pipe objects should only move after the event listener switches the panel to the game screen. Also, I wasn't able to get my timers in the Game class to work before. Maybe this will help towards getting that to work. I don't know where I can declare boolean playerIsReady, but I know that it needs to be set to true after the user clicks the play button. Here are all the class files Game.java import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.Timer; import javax.swing.border.EmptyBorder; import javax.swing.SwingUtilities; public class Game { public static void main(String[] args) { Runnable r = new Runnable() { @Override public void run() { // the GUI as seen by the user (without frame) final CardLayout cl = new CardLayout(); final JPanel gui = new JPanel(cl); // remove if no border is needed gui.setBorder(new EmptyBorder(10,10,10,10)); JPanel menu = new JPanel(new GridBagLayout()); JButton playGame = new JButton("Play!"); ActionListener playGameListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cl.show(gui, "game"); } }; playGame.addActionListener(playGameListener); Insets margin = new Insets(20, 50, 20, 50); playGame.setMargin(margin); m…
has answer: http://stackoverflow.com/a/21654125

http://stackoverflow.com/comment/32488946
comment on: http://stackoverflow.com/q/21518203
score: 0
type: Comment
type: QuestionComment
has text: Could you post the entire method

http://stackoverflow.com/comment/32586324
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21573193
has text: There isn't an inkling of evidence in your code that you have dealt with the concern of acquiring a dataSource by any mechanism. Advice: learn to use Spring.
score: 0

http://stackoverflow.com/comment/32571568
comment on: http://stackoverflow.com/a/21564933
has text: Just for future reference: How would I copy over all but one. I do know how to copy an array in several ways, but how would I leave out 1 option?
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/32537219
score: 0
type: QuestionComment
type: Comment
has text: @BasilBourque Well, if that is the case then the whole question is "premature optimization". We also create correlation IDs for logging. That does not mean that every ID gets logged. We concurrently process >10'000 events per second and the randomUUID() was a bottleneck for us (2ms is ages, really). Check out this [article](http://mechanitis.blogspot.ch/2011/07/dissecting-disruptor-why-its-so-fast.html) and other LMAX/disruptor related articles to find numbers about the cost of locking, with and without contention.
comment on: http://stackoverflow.com/q/21536572

http://stackoverflow.com/comment/32711930
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21644996
type: Comment
has text: easy answer - switch to jboss 8 (wildfly)

http://stackoverflow.com/comment/32546719
score: 0
type: Comment
type: QuestionComment
has text: i have tried related to this xml file
comment on: http://stackoverflow.com/q/21548436

android-actionbar
type: Tag
tags question: http://stackoverflow.com/q/21552969
tags question: http://stackoverflow.com/q/21576249
tags question: http://stackoverflow.com/q/21602537
tag name: android-actionbar
tags question: http://stackoverflow.com/q/21667484

http://stackoverflow.com/comment/32562213
type: Comment
type: QuestionComment
has text: Proper collection you can use for what?
comment on: http://stackoverflow.com/q/21559811
score: 0

http://stackoverflow.com/a/21610720
score: 1
upvote count: 1
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/21610684
has body: How about this ? while (!inputs.contains("q") || !inputs.contains("Q") || !inputs.contains("e")) { // Code Here..... } and so on for the rest of the terminating characters Or you can use regular expression (and the matches() method): while (!input.matches("[qwertQWERT]")

http://stackoverflow.com/comment/32724969
comment on: http://stackoverflow.com/q/21652237
score: 0
type: Comment
type: QuestionComment
has text: @JonSkeet: The question has been corrected to constant space and O(N) time. I'm not sure that makes more sense, unless space is pushed to O(MAX_INT).

http://stackoverflow.com/q/21597759
has title: Order ResultList of @ManyToMany connection
accepted answer: http://stackoverflow.com/a/21603904
type: Question
answer count: 1
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/32630930
has answer: http://stackoverflow.com/a/21603904
has comment: http://stackoverflow.com/comment/32631377
tagged with: jpa
has comment: http://stackoverflow.com/comment/32631666
tagged with: rest
type: AnsweredQuestion
has body: I have a @ManyToMany Connection with a temporary table. Table1 has 0..* Table2 and Table2 0..* Table1. When i ask for the Elements of Table1 and Serialize it. I get a Array of Table1 containing an Array of Table2. The Array of Table1 is sorted by the Primary Key. But the Array Table2 in Table 1 is randomly sorted. How can i sort the Array of Table2 in Table1 by its Primary Key? CODE: Table1 @Table(name = "Person") @Entity public class PersonDetail1 extends Person implements Serializable { private static final long serialVersionUID = 1L; @ManyToMany(fetch = FetchType.EAGER) @JoinTable(name = "PERSON_ITEM", joinColumns = {@JoinColumn(name = "PERS_FK", referencedColumnName = "PERS_PK")}, inverseJoinColumns = {@JoinColumn(name = "ITEM_FK", referencedColumnName = "ITEM_PK")}) private Set&lt;Item&gt; items; } Table2 @Entity public class Item implements Serializable { private static final long serialVersionUID = 1L; @Id @Column(name = "ITEM_PK") @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name = "PERSON_ITEM", joinColumns = {@JoinColumn(name = "ITEM_FK", referencedColumnName = "ITEM_PK")}, inverseJoinColumns = {@JoinColumn(name = "PERS_FK", referencedColumnName = "PERS_PK")}) private Set&lt;PersonDetail1&gt; personen; } get Table1 @Override public List&lt;PersonDetail1&gt; getPersonen() throws DetailException { TypedQuery&lt;PersonDetail1&gt; q = em.createQuery("SELECT x from PersonDetail1 x", PersonDetail1.class); return q.getResultList(); } get Serialized Object @GET @Path("/personen") @Produces(MediaType.APPLICATION_JSON) @Override public Response getPersonen(){ return Response.status(Response.Status.OK).entity(persService.getPersonen()).build(); }

http://stackoverflow.com/q/21629652
score: 3
upvote count: 3
tagged with: java
type: Question
tagged with: android-webservice
has answer: http://stackoverflow.com/a/21629886
tagged with: base64
has body: I got exception in base64 File Upload in Android. I refered so many thread in Stackoverflow, but no posts solves my problem. Please help me out from this issue as soon as possible. I'm pasting my logcat error here 02-07 19:18:11.536: E/AndroidRuntime(14445): FATAL EXCEPTION: AsyncTask #1 02-07 19:18:11.536: E/AndroidRuntime(14445): Process: com.ipage.fieldexecutive, PID: 14445 02-07 19:18:11.536: E/AndroidRuntime(14445): java.lang.RuntimeException: An error occured while executing doInBackground() 02-07 19:18:11.536: E/AndroidRuntime(14445): at android.os.AsyncTask$3.done(AsyncTask.java:300) 02-07 19:18:11.536: E/AndroidRuntime(14445): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) 02-07 19:18:11.536: E/AndroidRuntime(14445): at java.util.concurrent.FutureTask.setException(FutureTask.java:222) 02-07 19:18:11.536: E/AndroidRuntime(14445): at java.util.concurrent.FutureTask.run(FutureTask.java:242) 02-07 19:18:11.536: E/AndroidRuntime(14445): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 02-07 19:18:11.536: E/AndroidRuntime(14445): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 02-07 19:18:11.536: E/AndroidRuntime(14445): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 02-07 19:18:11.536: E/AndroidRuntime(14445): at java.lang.Thread.run(Thread.java:841) 02-07 19:18:11.536: E/AndroidRuntime(14445): Caused by: java.lang.IllegalArgumentException: Illegal character in path at index 76: /9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB 02-07 19:18:11.536: E/AndroidRuntime(14445): AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEB 02-07 19:18:11.536: E/AndroidRuntime(14445): AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCABiAGIDASIA 02-07 19:18:11.536: E/AndroidRuntime(14445): AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA 02-07 19:18:11.536: E/AndroidRuntime(1…
has comment: http://stackoverflow.com/comment/32684619
answer count: 1
downvote count: 0
favorite count: 0
has title: IllegalArgument Exception in Base64 File Upload in Android
type: UnansweredQuestion
tagged with: android

http://stackoverflow.com/comment/32570291
has text: Thank you very much for your answer! I have a question though. Why false and not true? The thing is that I am creating values 1 and 0 so there isn't any chance at all to have something different. Also I will use this method as a converter in another method, sth like `widget.getProperty(stringToBool("VALUE"))`
score: 0
comment on: http://stackoverflow.com/a/21564246
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32671633
has text: I think the wording of the question implies that the literal wasn't in the constant pool to start with.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/21621990
type: Comment

http://stackoverflow.com/comment/102043842
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21637522
has text: Fist time a thought was a converter or "generic" <T> problem, but wasn't. Your solution works like charm! At least for me, thx!
score: 0

http://stackoverflow.com/a/21604268
has comment: http://stackoverflow.com/comment/32640182
has comment: http://stackoverflow.com/comment/32640249
downvote count: 0
answers question: http://stackoverflow.com/q/21604132
score: 6
type: Answer
upvote count: 6
has comment: http://stackoverflow.com/comment/32640419
has body: When you pass a single argument - new GrupoSituacoesPermitidasDI(), the type parameter E of the generic method is inferred as GrupoSituacoesPermitidasDI, and thus it will return a List&lt;GrupoSituacoesPermitidasDI&gt;, which is not a subtype of List&lt;IGrupoSituacoesPermitidas&gt;, and hence the compiler error. Now, if you look at the signature of the overloaded method, it takes 2 arguments of type E. So, your arguments should be of same type. If it isn't, compiler infers the type as common super type of the argument you passed. So, since you pass 2 difference arguments which are not same, the type parameter is inferred as the common super type of those types, which I guess is IGrupoSituacoesPermitidas, and hence the list return is List&lt;IGrupoSituacoesPermitidas&gt;, and that is fine. Here's a simple example, which reproduces that problem: class Vehicle { } class Car extends Vehicle { } class Bike extends Vehicle { } public static &lt;T&gt; List&lt;T&gt; of(T obj) { List&lt;T&gt; list = new ArrayList&lt;T&gt;(); list.add(obj); return list; } public static &lt;T&gt; List&lt;T&gt; of(T obj1, T obj2) { List&lt;T&gt; list = new ArrayList&lt;T&gt;(); list.add(obj1); list.add(obj2); return list; } public static void main(String... args) { List&lt;Vehicle&gt; vehicles = of(new Car()); // Doesn't work List&lt;Vehicle&gt; vehicles1 = of(new Vehicle()); // Works List&lt;Vehicle&gt; vehicles2 = of(new Car(), new Bike()); } That is how type inference works. If the two types are not same, then the common super type is inferred. Also, from the comments from @Marko, if suppose your classes also implemented Serializable, then the type parameter would have been inferred as: Vehicle &amp; Serializable And then again, that will fail, as List&lt;Vehicle&gt; is not super type of List&lt;T2&gt; where T2 has above two bounds. You can solve such problems by giving explicit type argument: private static List&lt;IGrupoSituacoesPermitidas&gt; grupoSituacoesPermitidas = ImmutableList.&lt;…
has comment: http://stackoverflow.com/comment/32640321

http://stackoverflow.com/comment/32580793
score: 1
has text: @AndrewThompson <face plant>
type: AnswerComment
comment on: http://stackoverflow.com/a/21569732
type: Comment

http://stackoverflow.com/comment/32534735
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21544485
score: 0
has text: `INSERT` statement will **insert** rows in a table, while `UPDATE` statement will **update** a row (or a group of rows) in a table.

http://stackoverflow.com/a/21564828
type: Answer
answers question: http://stackoverflow.com/q/21564757
upvote count: 1
has body: This is rather simple. String path = "..."; // Whatever the path may be File file = new File(path); if (file.isDirectory()) { // The path exists and it is a directory if (file.canWrite() { // The directory is writable } else { // The directory is not writable } } else { // The path is not a directory, or it does not even exist }
score: 1
accepted answer of: http://stackoverflow.com/q/21564757
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/21645838
has comment: http://stackoverflow.com/comment/32713393
has comment: http://stackoverflow.com/comment/32713521
type: Question
answer count: 1
has comment: http://stackoverflow.com/comment/32713315
has body: Basically I have two classes, one extends an activity, and the other SQLiteOpenHelper; public class DatabaseHandler extends SQLiteOpenHelper { // All Static variables // Database Version private static final int DATABASE_VERSION = 1; DashboardActivity da; // Database Name private static final String DATABASE_NAME = "android_api"; // Login table name private static final String TABLE_LOGIN = "login"; // Login Table Columns names private static final String KEY_ID = "id"; private static final String KEY_NAME = "name"; private static final String KEY_EMAIL = "email"; private static final String KEY_UID = "uid"; private static final String KEY_CREATED_AT = "created_at"; public String emaili; public DatabaseHandler(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } // Creating Tables @Override public void onCreate(SQLiteDatabase db) { String CREATE_LOGIN_TABLE = "CREATE TABLE " + TABLE_LOGIN + "(" + KEY_ID + " INTEGER PRIMARY KEY," + KEY_NAME + " TEXT," + KEY_EMAIL + " TEXT UNIQUE," + KEY_UID + " TEXT," + KEY_CREATED_AT + " TEXT" + ")"; db.execSQL(CREATE_LOGIN_TABLE); } // Upgrading database @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // Drop older table if existed db.execSQL("DROP TABLE IF EXISTS " + TABLE_LOGIN); // Create tables again onCreate(db); } /** * Storing user details in database * */ public void addUser(String name, String email, String uid, String created_at) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(KEY_NAME, name); // Name values.put(KEY_EMAIL, email); // Email values.put(KEY_UID, uid); // Email values.put(KEY_CREATED_AT, created_at); // Created At // Inserting Row db.insert(TABLE_LOGIN, null, values); db.close(); // Closing database connection } /** * Getting user data from database * */ public HashMap&lt;String, String&gt; getUserDetails(){ HashMap&lt;String,String&gt; user = new HashMap&lt;String,String&gt;(); String selectQu…
has answer: http://stackoverflow.com/a/21647006
has comment: http://stackoverflow.com/comment/32713639
favorite count: 0
has comment: http://stackoverflow.com/comment/32713480
has comment: http://stackoverflow.com/comment/32713442
tagged with: android
tagged with: sqlite
has comment: http://stackoverflow.com/comment/32713374
has title: Implementing a class that extends SQLiteOpenHelper
score: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32713468
upvote count: 1
downvote count: 1
tagged with: java

http://stackoverflow.com/a/21554899
score: 1
upvote count: 1
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/21554530
answers question: http://stackoverflow.com/q/21554530
has body: Say you have this data First Name Last Name Lebron James Michael Jordan Kobe Bryant What you want to do is loop through the model and depending on which column you want to check against, that will be the column you pass to getValueAt(row, column). So you could do something like this private void jButton1ActionPerformed(ActionEvent evt) { String name = jTextField1.getText(); DefaultTableModel model = (DefaultTableModel)jTable1.getModel(); for (int i = 0; i &lt; model.getRowCount(); i++) { if (((String)model.getValueAt(i, 0)).equals(name)) { model.removeRow(i); break; } } } I use 0 for the getValueAt(), checking for the First Name column. If a name equals, the row is deleted. If I type in Lebron, the row of Lebron James will be deleted.

http://stackoverflow.com/comment/32654316
type: QuestionComment
has text: An object is created when you use the object creator keyword `new`, so in this case you have 3 objects. As for `Long` and `Integer` they are just wrapper classes for `int` and `long` respectively. Unless you create an integer like this `Integer i = new Integer(10);`, `i` just holds a primitive variable.
comment on: http://stackoverflow.com/q/21611950
score: 0
type: Comment

http://stackoverflow.com/a/21669658
answers question: http://stackoverflow.com/q/21669582
downvote count: 1
score: -1
upvote count: 0
has body: If your problem is just about the duplicates, then you can store each random number generated in an array, and for every successive call to nextint(), check if it already exists in the array of stored values, and till it does, call nextint() again for that iteration itself, else store it in the array and go to next iteration.
type: Answer

http://stackoverflow.com/comment/32486068
type: QuestionComment
score: 0
has text: @user1066946 I shouldn't have brought up Eclipse... That really wasn't the reason behind this at all... What I meant to say was: "Trying to limit access to any resources in my code to only the relevant scope helps me..." And this local interface really just looks like `interface A extends B, C {}`. So there's nothing to test. I'll just use `abstract class A implements B, C {}` instead and done... :)
comment on: http://stackoverflow.com/q/21516375
type: Comment

http://stackoverflow.com/comment/32672569
score: 0
comment on: http://stackoverflow.com/a/21622580
type: AnswerComment
type: Comment
has text: So, u suggest me to save different sizes of any image in the database? I didnt do it, because i wanted to be free to change the size of the images shown on my pages. That's why i saved just one big photos, that i resize in every page (i need at least 3 different sizes of every image). But maybe your solution is the right one, probably i have to change some of my code and of my logic.

http://stackoverflow.com/a/41011957
has body: String input = "[200,350,500]"; String[] split = input.replaceAll("^.(.*).$","$1").split(",");
answers question: http://stackoverflow.com/q/21605904
has comment: http://stackoverflow.com/comment/69237730
has comment: http://stackoverflow.com/comment/69239692
score: 0
has comment: http://stackoverflow.com/comment/69239400
has comment: http://stackoverflow.com/comment/69239465
type: Answer

http://stackoverflow.com/comment/32545283
has text: Acording to this [link](http://www.goldennumber.net/phi-million-places/) my snippet is more precise :P
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21549669
type: Comment

http://stackoverflow.com/a/21672243
has body: You can use instaceof operator. For example: if (i instanceof Brownie) { eat(i); } else { dispose(i); } instaceof opertaor check if the type of an object is an instance of a class or a class that extends or implements the specified type. You can read more in Java tutorial, operators. Also see question What is the instaceof operator used for.
answers question: http://stackoverflow.com/q/21672199
downvote count: 0
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/comment/32509370
score: 0
type: AnswerComment
has text: DJClayworth , thanks for your answer. In such a case what is the need to have SomeClass member variable in SomeOtherClass.java? My intention is, i need to use same instance of SomeClass which is created in SomeOtherClass and call doSomeFunctionality(); on the same. Thanks!
type: Comment
comment on: http://stackoverflow.com/a/21530121

http://stackoverflow.com/q/21540642
has comment: http://stackoverflow.com/comment/32529216
type: Question
has answer: http://stackoverflow.com/a/21540738
has comment: http://stackoverflow.com/comment/32528876
tagged with: sorting
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/21541022
has comment: http://stackoverflow.com/comment/32529340
tagged with: arrays
has body: I'm looking for a way to associate each row from this file(csv) and to take the monthly maximum(each column represents the month) associated with the store name. I can get the row maximums and column maximums but I do not know how to link each column maximum to their city name. Help please! Here is the file: Omaha,104,1218,418,216,438,618,274,234,510,538,740,540 Saint Louis,72,1006,392,686,626,670,204,286,236,344,394,930 Des Moines,116,1226,476,330,444,464,366,230,602,260,518,692 Chicago,408,948,80,472,626,290,372,282,488,456,376,580 Kansas City,308,1210,450,234,616,414,500,330,486,214,638,586 Austin,500,812,226,470,388,488,512,254,210,388,738,686 Houston,454,1086,430,616,356,534,218,420,494,382,476,846 New Orleans,304,1278,352,598,288,228,532,418,314,496,616,882 Here is my code so far: File selectedFile = Utilities.selectFile("Type the file name: Ex:annualUnitsSold.csv \n"); int numberRecords = Utilities.countLinesInFile(selectedFile); String[][] records = Utilities.loadStringsFromFile(selectedFile, numberRecords); System.out.println(columnCompare(records,1); public static int columnCompare (String[][] array, int col) { String report = ""; int monthMax = 0; for(int row = 0; row &lt; array.length; row++) { if(monthMax &lt; Integer.parseInt(array[row][col])) { monthMax = Integer.parseInt(array[row][col]); } } return monthMax; } //NOTE: when i run this it works as long as i put the column number greater than zero.
has comment: http://stackoverflow.com/comment/32529024
has title: Parse 2D string array to 2D int array
type: UnansweredQuestion
tagged with: java

http://stackoverflow.com/a/21623527
answers question: http://stackoverflow.com/q/21623499
type: Answer
score: 2
downvote count: 0
upvote count: 2
has body: Nope because there are other thing which are not Objects in Java like primitive types. Smalltalk is a pure OOP language.

http://stackoverflow.com/comment/32812412
type: QuestionComment
score: 0
has text: @dimadima As your ciphertext is not protected for integrity nor authenticity, your ciphertext will happily decrypt to random bytes. Normally this is caught by the unpadding (which can have disastrous results itself because of padding oracle attacks) but otherwise the output is simply random. You can even decrypt with DES and get a result. Add a MAC or HMAC to protect against such things (and do use CBC and padding, your current solution is probably insecure on many levels).
comment on: http://stackoverflow.com/q/21655286
type: Comment

http://stackoverflow.com/q/21581311
has comment: http://stackoverflow.com/comment/32600677
possible better answer: http://stackoverflow.com/a/21581886
answer count: 3
upvote count: 1
downvote count: 0
favorite count: 0
linked to: http://stackoverflow.com/q/6250114
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21581886
score: 1
tagged with: java
has body: I'm currently working a small project where I end up messing with byte, short value etc, and after some reading, I still don't understand some stuff, like what is "bit shifting", why do we use it, when do we need, and how does it work. Also, I found this function to convert short into byte: private byte[] short2byte(short[] sData) { int shortArrsize = sData.length; byte[] bytes = new byte[shortArrsize * 2]; for (int i = 0; i &lt; shortArrsize; i++) { bytes[i * 2] = (byte) (sData[i] &amp; 0x00FF); bytes[(i * 2) + 1] = (byte) (sData[i] &gt;&gt; 8); sData[i] = 0; } return bytes; } I think I understand this function but my problem is that I'm not sure what these two lines are doing: bytes[i * 2] = (byte) (sData[i] &amp; 0x00FF); bytes[(i * 2) + 1] = (byte) (sData[i] &gt;&gt; 8); I think it has something to do with bit shifting, so can someone please explain what that means? If you have a link or good documentation regarding bytes, short, bit shifting etc, please include that if possible. Kind regards
type: Question
duplicate of: http://stackoverflow.com/q/6250114
has answer: http://stackoverflow.com/a/21582123
accepted answer: http://stackoverflow.com/a/21582123
has title: Java Bit Shifting, short conversion to byte
has answer: http://stackoverflow.com/a/21581982

http://stackoverflow.com/q/21673774
tagged with: android-activity
has answer: http://stackoverflow.com/a/21673878
favorite count: 0
has answer: http://stackoverflow.com/a/21673897
type: UnansweredQuestion
tagged with: android
has title: Android Activity Not Ending on Back Button Press
has comment: http://stackoverflow.com/comment/32762008
answer count: 4
has body: I have added the following code to a class I have: @Override public void onBackPressed() { // TODO Auto-generated method stub super.onBackPressed(); /* AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.setTitle("test"); dialog.setMessage("test 123"); dialog.setNeutralButton("OK", null); dialog.create().show(); */ finish(); } I know the method is being called because the alert dialog does display when I press the back button. However the MediaPlayer continues to play when I press back, which takes me to the previous screen. Why is this? Shouldn't finish() stop the MediaPlayer?
has comment: http://stackoverflow.com/comment/32761953
upvote count: 0
has comment: http://stackoverflow.com/comment/32761983
tagged with: java
has answer: http://stackoverflow.com/a/21673854
type: Question
score: -2
has answer: http://stackoverflow.com/a/21673887
downvote count: 2

http://stackoverflow.com/comment/32579324
type: AnswerComment
score: 0
type: Comment
has text: There is nothing complicated in this code.I just use one while loop and one Boolean variable.very basic java
comment on: http://stackoverflow.com/a/21568419

http://stackoverflow.com/comment/32600194
score: 0
has text: I like `str.substring(108)`. It does exactly what the poster asked for.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21578266

hibernate
tags question: http://stackoverflow.com/q/21579326
tags question: http://stackoverflow.com/q/21631985
tags question: http://stackoverflow.com/q/21657626
tags question: http://stackoverflow.com/q/21625059
tags question: http://stackoverflow.com/q/21654358
tags question: http://stackoverflow.com/q/21677614
tags question: http://stackoverflow.com/q/21594831
tags question: http://stackoverflow.com/q/21635031
tags question: http://stackoverflow.com/q/21622841
tags question: http://stackoverflow.com/q/21648644
tags question: http://stackoverflow.com/q/21557436
tags question: http://stackoverflow.com/q/21574236
tags question: http://stackoverflow.com/q/21552093
tags question: http://stackoverflow.com/q/21596500
tags question: http://stackoverflow.com/q/21516727
tags question: http://stackoverflow.com/q/21633548
tags question: http://stackoverflow.com/q/21556425
tags question: http://stackoverflow.com/q/21601049
tags question: http://stackoverflow.com/q/21625744
tags question: http://stackoverflow.com/q/21609497
tags question: http://stackoverflow.com/q/21537080
tags question: http://stackoverflow.com/q/21544928
tags question: http://stackoverflow.com/q/21659388
tags question: http://stackoverflow.com/q/21627953
tags question: http://stackoverflow.com/q/21598773
tags question: http://stackoverflow.com/q/21614093
tags question: http://stackoverflow.com/q/21605070
tags question: http://stackoverflow.com/q/21612574
tags question: http://stackoverflow.com/q/21562442
tags question: http://stackoverflow.com/q/21611545
tags question: http://stackoverflow.com/q/21569970
tags question: http://stackoverflow.com/q/21577265
tags question: http://stackoverflow.com/q/21577090
tags question: http://stackoverflow.com/q/21534112
tags question: http://stackoverflow.com/q/21550826
tags question: http://stackoverflow.com/q/21588038
tag name: hibernate
tags question: http://stackoverflow.com/q/21544311
tags question: http://stackoverflow.com/q/21648999
tags question: http://stackoverflow.com/q/21623697
tags question: http://stackoverflow.com/q/21625320
tags question: http://stackoverflow.com/q/21528846
tags question: http://stackoverflow.com/q/21527973
tags question: http://stackoverflow.com/q/21568693
tags question: http://stackoverflow.com/q/21657172
tags question: http://stackoverflow.com/q/21669094
tags question: http://stackoverflow.com/q/21668702
tags question: http://stackoverflow.com/q/21579452
tags question: http://stackoverflow.com/q/21672428
tags question: http://stackoverflow.com/q/21526867
tags question: http://stackoverflow.com/q/21580598
tags question: http://stackoverflow.com/q/21622076
tags question: http://stackoverflow.com/q/21647947
tags question: http://stackoverflow.com/q/21531019
tags question: http://stackoverflow.com/q/21631979
tags question: http://stackoverflow.com/q/21561696
tags question: http://stackoverflow.com/q/21608835
tags question: http://stackoverflow.com/q/21520899
tags question: http://stackoverflow.com/q/21570365
tags question: http://stackoverflow.com/q/21530411
tags question: http://stackoverflow.com/q/21524451
tags question: http://stackoverflow.com/q/21652509
tags question: http://stackoverflow.com/q/21514765
tags question: http://stackoverflow.com/q/21587027
tags question: http://stackoverflow.com/q/21677703
tags question: http://stackoverflow.com/q/21671731
tags question: http://stackoverflow.com/q/21622149
tags question: http://stackoverflow.com/q/21562518
tags question: http://stackoverflow.com/q/21576525
tags question: http://stackoverflow.com/q/21630851
tags question: http://stackoverflow.com/q/21663558
tags question: http://stackoverflow.com/q/21636649
tags question: http://stackoverflow.com/q/21593641
tags question: http://stackoverflow.com/q/21605632
tags question: http://stackoverflow.com/q/21575011
tags question: http://stackoverflow.com/q/21608881
tags question: http://stackoverflow.com/q/21667715
tags question: http://stackoverflow.com/q/21541818
tags question: http://stackoverflow.com/q/21588384
tags question: http://stackoverflow.com/q/21559386

http://stackoverflow.com/comment/32577575
type: QuestionComment
comment on: http://stackoverflow.com/q/21568102
has text: Please format your code. Also, learn to use a debugger. You wouldn't need to post this question if you were using a debugger.
score: 0
type: Comment

http://stackoverflow.com/comment/32695166
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21635386
type: Comment
has text: There is not "last known location", you should wait until the location manager calculate it. It doesn't always happen, but it happens.

http://stackoverflow.com/comment/32766693
has text: check your logcat give another above of it.
score: 0
type: Comment
comment on: http://stackoverflow.com/q/21676460
type: QuestionComment

http://stackoverflow.com/a/21628571
type: Answer
accepted answer of: http://stackoverflow.com/q/21602980
answers question: http://stackoverflow.com/q/21602980
score: 0
has comment: http://stackoverflow.com/comment/32771964
type: AcceptedAnswer
has body: i think after you have exposed the method written at VO as Client interface, you need to create a method binding in pageDef file of you page. after creating the method binding, you need to access the method in bean through binding layer something like this : OperationBinding op=((DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry()).getOperationBinding("Method Binding"); op.execute(); i think the method used by you to call VO method from bean is not right. i think one more thing you need to do in your bean after calling the VO method is that you need to do refresh the table / perform PPR programatically : AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance(); adfFacesContext.addPartialTarget(component binding for your table component); you can try setting autosubmit to true for command button which invokes action event, and set partial trigger for table to component id of the command button. can you post VO method code as well ? does the method get called and data gets committed / updated when you execute it through bean ? is it only a table refresh issue ? do you see changes to data if you manually refresh the page ?

http://stackoverflow.com/q/21649291
answer count: 1
favorite count: 0
has title: Trident Storm-Cassandra, writing to a table with multiple primary keys
tagged with: cassandra
has body: I'm learning how to use Storm's Trident with Cassandra 2.0.5, Storm version 0.9.0.1. I'm also using com.hmsonline storm-cassandra 0.4.0-rc4 contrib. My goal is simply to insert some text rows to a table with id (int), name (text) and a sentence (text) columns. id and name are primary keys. The partitionPersist requires a StateUpdater, and for that I'm using com.hmsonline.storm.cassandra.trident.CassandraUpdater&lt;K, C, V&gt;. But from what it seems it gets only one key as input and not two (I need id and name). The tuple mapper (TridentTupleMapper) also uses one key: TridentTupleMapper&lt;K, C, V&gt; tupleMapper Maybe I'm missing something but how do I define multiple columns as keys?
tagged with: nosql
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21948604
accepted answer: http://stackoverflow.com/a/21948604
downvote count: 0
score: 1
tagged with: java
tagged with: apache-storm
type: Question
tagged with: trident
upvote count: 1

http://stackoverflow.com/comment/32708272
type: Comment
type: QuestionComment
has text: @Mike M. no, DO NOT request that permission, as the files involved are not on the External Storage.
comment on: http://stackoverflow.com/q/21641455
score: 0

http://stackoverflow.com/comment/32770500
comment on: http://stackoverflow.com/a/21673975
score: 0
has text: @Dims Nope, still looks fine without `SWT.BORDER`.
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/32587385
type: Comment
comment on: http://stackoverflow.com/q/21529667
type: QuestionComment
has text: OK, I'll try JDesktopPane too.
score: 0

http://stackoverflow.com/q/21666291
has comment: http://stackoverflow.com/comment/32749612
has comment: http://stackoverflow.com/comment/32749602
tagged with: exception
has comment: http://stackoverflow.com/comment/32749863
accepted answer: http://stackoverflow.com/a/21666397
has comment: http://stackoverflow.com/comment/32749603
type: AnsweredQuestion
has body: When a specified file has been read successfully, but the data within the file is improper, such as malformed XML, or an ini file that specifies the wrong variables or is missing a section, or something like that, what should of exception should be used in that case? Does it make sense to use an IOException with a detailed exception message, or should another kind of exception be used? There doesn't appear to be a good exception type for this sort of event within the standard library.
score: 1
tagged with: java
has title: What exception should be used in Java when a file can be read but the file's data is improperly formatted?
upvote count: 1
possible better answer: http://stackoverflow.com/a/21666353
type: Question
has answer: http://stackoverflow.com/a/21666353
has comment: http://stackoverflow.com/comment/32749616
has answer: http://stackoverflow.com/a/21666397
answer count: 2
downvote count: 0
favorite count: 0

http://stackoverflow.com/a/21669242
has comment: http://stackoverflow.com/comment/32754857
has comment: http://stackoverflow.com/comment/32754830
has comment: http://stackoverflow.com/comment/32755949
score: -1
has comment: http://stackoverflow.com/comment/32755636
has comment: http://stackoverflow.com/comment/32798317
has comment: http://stackoverflow.com/comment/32834138
has comment: http://stackoverflow.com/comment/32798333
has comment: http://stackoverflow.com/comment/32797200
has comment: http://stackoverflow.com/comment/32797913
has comment: http://stackoverflow.com/comment/32797231
has comment: http://stackoverflow.com/comment/32797101
has body: If you want to just check if they are equal or not , you can use: int val = org.compareTo(check); It will return 0 if they are equal, negative value if org is before check , else positive value if org is after check. If you really want to return the first position where they are unequal, use this function: int firstMismatch(String org, String check) { int limit = (org.length()&gt;check.length())?org.length():check.length(); for(int i=0;i&lt;limit;i++) { try{ if(org.charAt(i)!=check.charAt(i)) { return i; //If one of the strings end, that's the position they are different, otherwise there is a mismatch. Either way, just return the index of mismatch } } catch(Exception e) { if(org.length()!=check.length()) { return(i); //Execution comes here only when length of strings is unequal //Exception occurs because first string is smaller than // the second or vice versa. Say if you use "fred" and"fredd" as org and check //respectively, "fred" is smaller than "fredd" so accessing org[4] is not allowed. //Hence the exception. } System.out.println("Problem encountered"); //Some other exception has occured. return(-2); } } return(-1); //if they are equal, just return -1 } EDIT : And in your code, call as follows: public class CheckPasswords extends ConsoleProgram { public void run() { while(true) { String org = readLine("Enter Password: "); String check = readLine("Confirm Password: "); int mismatchPosition = firstMisMatch(org,check); if(mismatchPosition==-1) { println("Password Confirmed"); } else { println("Passwords do not match from position "+mismatchPosition); } } } }
has comment: http://stackoverflow.com/comment/32796687
upvote count: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32796434
has comment: http://stackoverflow.com/comment/32798071
has comment: http://stackoverflow.com/comment/32797380
has comment: http://stackoverflow.com/comment/32796944
has comment: http://stackoverflow.com/comment/32755233
has comment: http://stackoverflow.com/comment/32797374
has comment: http://stackoverflow.com/comment/32796704
has comment: http://stackoverflow.com/comment/32796924
type: Answer
has comment: http://stackoverflow.com/comment/32840039
has comment: http://stackoverflow.com/comment/32796360
has comment: http://stackoverflow.com/comment/32797215
has comment: http://stackoverflow.com/comment/32796386
has comment: http://stackoverflow.com/comment/32772781
has comment: http://stackoverflow.com/comment/32797027
accepted answer of: http://stackoverflow.com/q/21669092
has comment: http://stackoverflow.com/comment/32779906
has comment: http://stackoverflow.com/comment/32796279
has comment: http://stackoverflow.com/comment/32755584
answers question: http://stackoverflow.com/q/21669092
downvote count: 1
has comment: http://stackoverflow.com/comment/32796768

http://stackoverflow.com/comment/32845636
has text: Why do you insist on editing out the sample code? The question is more useful with it left in. For anyone else coming to this question, it's available in the edit history.
comment on: http://stackoverflow.com/q/21578385
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/a/21568465
accepted answer of: http://stackoverflow.com/q/21568329
has body: You're calling bday.getInstance().get(Calendar.YEAR) // 1960 getInstance() is a static method that returns a new Calendar object. You can invoke static methods on instances, but it is highly discouraged for exactly this reason. You're calling get(int) on that new instance which is initialized to today, ie. year 2014, not on the instance referenced by bday.
type: Answer
answers question: http://stackoverflow.com/q/21568329
upvote count: 2
score: 2
has comment: http://stackoverflow.com/comment/32578262
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/32502458
type: AnswerComment
comment on: http://stackoverflow.com/a/21524133
has text: Ok, flag ticked! I noticed that now even if I comment the System.setProperty settings it still works, isn'it a little bit strange, how can the client do the cipher stuff to the https connection without using the public key? Maybe I am missing something, anyway now it works!
type: Comment
score: 0

http://stackoverflow.com/a/21639109
type: Answer
has comment: http://stackoverflow.com/comment/32709225
downvote count: 0
has body: that's because tomcat works on port 8080 unlike apache - when you run php sites they are just behind the apache which is visible on port 80 (which the default one in browsers), you can go through "http://mydomain.com:8080/sample" and it would work the same as through localhost you can also change tomcat's settings and change it's connector's port from 8080 to 80, and then it would work as you expected
has comment: http://stackoverflow.com/comment/32710592
has comment: http://stackoverflow.com/comment/32702931
score: 1
has comment: http://stackoverflow.com/comment/32702895
has comment: http://stackoverflow.com/comment/32703200
upvote count: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21638751
answers question: http://stackoverflow.com/q/21638751
has comment: http://stackoverflow.com/comment/32702998
has comment: http://stackoverflow.com/comment/32702876
has comment: http://stackoverflow.com/comment/32703424

list
type: Tag
tags question: http://stackoverflow.com/q/21633384
tags question: http://stackoverflow.com/q/21602753
tags question: http://stackoverflow.com/q/21592835
tags question: http://stackoverflow.com/q/21522138
tags question: http://stackoverflow.com/q/21676189
tags question: http://stackoverflow.com/q/21677212
tags question: http://stackoverflow.com/q/21604298
tags question: http://stackoverflow.com/q/21642660
tags question: http://stackoverflow.com/q/21602484
tag name: list
tags question: http://stackoverflow.com/q/21585253
tags question: http://stackoverflow.com/q/21658537
tags question: http://stackoverflow.com/q/21565212
tags question: http://stackoverflow.com/q/21653372
tags question: http://stackoverflow.com/q/21523993
tags question: http://stackoverflow.com/q/21529489
tags question: http://stackoverflow.com/q/21652326
tags question: http://stackoverflow.com/q/21586835
tags question: http://stackoverflow.com/q/21598937
tags question: http://stackoverflow.com/q/21531012
tags question: http://stackoverflow.com/q/21539586
tags question: http://stackoverflow.com/q/21622660
tags question: http://stackoverflow.com/q/21624841
tags question: http://stackoverflow.com/q/21568007
tags question: http://stackoverflow.com/q/21608990
tags question: http://stackoverflow.com/q/21637808
tags question: http://stackoverflow.com/q/21666870
tags question: http://stackoverflow.com/q/21605431
tags question: http://stackoverflow.com/q/21648038
tags question: http://stackoverflow.com/q/21612168
tags question: http://stackoverflow.com/q/21571503
tags question: http://stackoverflow.com/q/21576148
tags question: http://stackoverflow.com/q/21618071
tags question: http://stackoverflow.com/q/21551661

http://stackoverflow.com/comment/32720176
type: QuestionComment
has text: First question - why to use `ArrayList`???
comment on: http://stackoverflow.com/q/21649727
score: 0
type: Comment

http://stackoverflow.com/comment/32673214
type: QuestionComment
comment on: http://stackoverflow.com/q/21623064
has text: it might help http://stackoverflow.com/questions/5936003/write-html-file-using-java
score: 0
type: Comment

http://stackoverflow.com/comment/32764791
type: Comment
score: 0
has text: I followed exactly what is being written in http://josiahgore.blogspot.in/2011/02/using-spring-aop-to-retry-failed.html and then i annotated a service method with @RetryConcurrentOperation(exception = HibernateOptimisticLockingFailureException.class, retries = 12) Now, because the method is annotated with @Transactional it doesnt work, it gives a regular optimistic lock exception, on a non transactional method if i annotate it - it works.
type: AnswerComment
comment on: http://stackoverflow.com/a/21673679

http://stackoverflow.com/q/21648636
has comment: http://stackoverflow.com/comment/32718272
has comment: http://stackoverflow.com/comment/32718334
tagged with: excel
type: Question
has title: Export to Excel which will receive to client side
score: 0
linked to: http://stackoverflow.com/q/16193970
tagged with: jar
has comment: http://stackoverflow.com/comment/32718440
linked to: http://stackoverflow.com/q/17491527
has comment: http://stackoverflow.com/comment/32718527
has comment: http://stackoverflow.com/comment/32718255
linked to: http://stackoverflow.com/q/9293311
has comment: http://stackoverflow.com/comment/32718221
has body: I want to create a jar file which will dynamically create Excel sheet and stream the file contents through the response output stream to the client browser. In server side, generated file should not get saved. We can achieve this using servlet but i need JAR so we cant make use of it. So how can i achieve this? war/servlet file need to be deployed on webserver. Jar need not be. So for this exporting functionality i cant make use of sepereate webserver.
answer count: 0
has comment: http://stackoverflow.com/comment/32718738
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32718215
tagged with: java
has comment: http://stackoverflow.com/comment/32718392

http://stackoverflow.com/q/21605298
has answer: http://stackoverflow.com/a/21615228
answer count: 1
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/21615228
has title: Upgrade vRaptor to 3.5.3 Java.lang.NoClassDefFoundError: br/com/caelum/vraptor/validator/Validator
upvote count: 2
tagged with: maven
has comment: http://stackoverflow.com/comment/32644656
score: 2
type: AnsweredQuestion
tagged with: osx-mavericks
tagged with: java
has body: I have trouble when update my pom.xml for upgrade some jars, like vraptor and hibernate... My environment is, Web project, maven, tomcat 7, vraptor, jpa, osx mavericks, before update jars, all work's fine, after the update I got this error on start tomcat: SEVERE: Exception starting filter vraptor java.lang.NoClassDefFoundError: br/com/caelum/vraptor/validator/Validator at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2483) at java.lang.Class.getDeclaredConstructors(Class.java:1891) at br.com.caelum.vraptor.ioc.guice.GuiceComponentRegistry.getConstructor(GuiceComponentRegistry.java:154) at br.com.caelum.vraptor.ioc.guice.GuiceComponentRegistry.bindToConstructor(GuiceComponentRegistry.java:140) at br.com.caelum.vraptor.ioc.guice.GuiceComponentRegistry.register(GuiceComponentRegistry.java:84) at br.com.caelum.vraptor.ioc.guice.GuiceComponentRegistry.deepRegister(GuiceComponentRegistry.java:101) at br.com.caelum.vraptor.scan.DynamicWebAppBootstrap.configure(DynamicWebAppBootstrap.java:46) at br.com.caelum.vraptor.ioc.guice.GuiceProvider$2.configure(GuiceProvider.java:123) at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223) at com.google.inject.spi.Elements.getElements(Elements.java:101) at com.google.inject.spi.Elements.getElements(Elements.java:92) at com.google.inject.util.Modules$RealOverriddenModuleBuilder$1.configure(Modules.java:172) at com.google.inject.AbstractModule.configure(AbstractModule.java:59) at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223) at com.google.inject.spi.Elements.getElements(Elements.java:101) at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:133) at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103) at com.google.inject.Guice.createInjector(Guice.java:95) at com.google.inject.Guice.createInjector(Guice.java:83) at br.com.caelum.vraptor.ioc.guice.GuicePro…
type: Question
tagged with: vraptor
tagged with: tomcat

http://stackoverflow.com/comment/32764932
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21636518
has text: As I have already said. This is happening only for 1 of our customers. We are not experiencing this problem for any other and we have not experienced something like this for 13 years of operation. It is new for us as well. In the original question, you can find a direct copy-paste of our socket closing code.
score: 0

http://stackoverflow.com/q/21606748
type: AnsweredQuestion
has body: I have recently started playing with Java 8, having done bits and pieces in Haskell/Scala before. I am trying to play with higher-order functions in Java such as map or forEach, and I am struggling to understand what motivation it was to push everything towards Stream ideology. I understand it gives nice, general abstraction, it is supposed to be lazy, but let's consider a very simple, common example: list.map(x -&gt; do_sth(x)); very common idiom, expecting this to return a List&lt;T&gt;. Now, in Java 8, I need to do sth of this sort: list.stream().map(x -&gt; doSth(x)).collect(Collectors.toList()) Now, as far I see this, the stream will not apply the map until collect is called, so there will be one pass through the collection under the hood. What I can't see is why those common use cases for maps, lists such as map.toList(), list.groupBy() would not be added to corresponding interfaces? Is there an underlying design decision I am missing here?
tagged with: java
type: Question
has title: Java 8 - stream ideology
downvote count: 0
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/21608875
upvote count: 14
tagged with: collections
tagged with: lambda
tagged with: java-8
accepted answer: http://stackoverflow.com/a/21608875
score: 14

http://stackoverflow.com/a/21544148
has comment: http://stackoverflow.com/comment/32536769
has comment: http://stackoverflow.com/comment/32534875
has comment: http://stackoverflow.com/comment/32536490
has comment: http://stackoverflow.com/comment/32544312
has comment: http://stackoverflow.com/comment/32537569
score: 0
has body: You have android:minSdkVersion="12" So you need to change public class Settings extends FragmentActivity{ to public class Settings extends Activity{ Also it is better you check the availability of google play services before initializing google map object. From the docs public final GoogleMap getMap () Gets the underlying GoogleMap that is tied to the view wrapped by this fragment. Returns the GoogleMap. Null if the view of the fragment is not yet ready. This can happen if the fragment lifecyle have not gone through onCreateView(LayoutInflater, ViewGroup, Bundle) yet. This can also happen if Google Play services is not available. If Google Play services becomes available afterwards and the fragment have gone through onCreateView(LayoutInflater, ViewGroup, Bundle), calling this method again will initialize and return the GoogleMap. Edit: Missing a meta tag in the applciation tag of manifest fie. Pls make sure you followed all the steps @ https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2 &lt;meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /&gt;
has comment: http://stackoverflow.com/comment/32534256
answers question: http://stackoverflow.com/q/21544126
has comment: http://stackoverflow.com/comment/32537318
has comment: http://stackoverflow.com/comment/32534773
has comment: http://stackoverflow.com/comment/32537637
has comment: http://stackoverflow.com/comment/32534215
has comment: http://stackoverflow.com/comment/32536022
has comment: http://stackoverflow.com/comment/32537659
has comment: http://stackoverflow.com/comment/32534287
type: Answer
has comment: http://stackoverflow.com/comment/32537233
has comment: http://stackoverflow.com/comment/32537207
has comment: http://stackoverflow.com/comment/32537578
has comment: http://stackoverflow.com/comment/32537349

http://stackoverflow.com/a/21558907
answers question: http://stackoverflow.com/q/21558677
has body: ^([0-9]{5})\-$ As example (regex example), matches for 09090- will be: 0: [0,6] 09090- 1: [0,5] 09090 you can just replace it with matches /^([0-9]{5})[\-][0-9]{4}$/ //skip replacement.
score: 0
type: Answer

http://stackoverflow.com/q/21542825
tagged with: java
score: 10
upvote count: 10
type: Question
accepted answer: http://stackoverflow.com/a/21542836
has answer: http://stackoverflow.com/a/24278156
possible better answer: http://stackoverflow.com/a/21542897
downvote count: 0
tagged with: database
answer count: 6
has answer: http://stackoverflow.com/a/21542897
has comment: http://stackoverflow.com/comment/32532635
has body: Hello I am trying to delete a row from my database. I am getting no errors but it is doing nothing, any help or advice would be great! public static void DeleteRow(String name) { try { Class.forName("com.mysql.jdbc.Driver"); Connection connection = DriverManager.getConnection(url, username, password); PreparedStatement st = connection.prepareStatement("DELETE FROM Table WHERE name = " + name + ";"); st.executeUpdate(); } catch(Exception e) { System.out.println(e); } }
has title: Java sql delete row
tagged with: sql
has answer: http://stackoverflow.com/a/21542862
favorite count: 0
has answer: http://stackoverflow.com/a/21542836
has answer: http://stackoverflow.com/a/40674335
has answer: http://stackoverflow.com/a/33926439
type: AnsweredQuestion
tagged with: sql-delete

http://stackoverflow.com/q/21599776
answer count: 0
downvote count: 0
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32633576
has comment: http://stackoverflow.com/comment/32632814
type: Question
has title: how to make multi module Ear project in eclipse and maven
tagged with: eclipse
has comment: http://stackoverflow.com/comment/32635492
has body: i am new to Ear kind project i can make a war project now i want to add my all war project in a Ear project by using maven but not able to get success my pom.xml file of Ear project gives me the error and i am not able to get that, if any one has the solution please help. thanks in adv.
upvote count: 1
favorite count: 0
type: UnansweredQuestion
tagged with: maven
has comment: http://stackoverflow.com/comment/32670517
has comment: http://stackoverflow.com/comment/33165575

http://stackoverflow.com/comment/32671724
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21621984
type: Comment
has text: @Omoro the literal `"stack overflow"` is first created and goes to the pool then a new String is creating using the copy constructor which will not be in the pool.

http://stackoverflow.com/comment/32780224
type: AnswerComment
has text: You need to get the Apache Commons Lang jar from http://commons.apache.org/proper/commons-lang/ and put it in your classpath.
type: Comment
comment on: http://stackoverflow.com/a/21541517
score: 0

http://stackoverflow.com/a/21594554
has comment: http://stackoverflow.com/comment/32626684
type: Answer
has comment: http://stackoverflow.com/comment/32626653
accepted answer of: http://stackoverflow.com/q/21593825
upvote count: 2
answers question: http://stackoverflow.com/q/21593825
has comment: http://stackoverflow.com/comment/32626489
score: 2
has comment: http://stackoverflow.com/comment/32624481
has body: Recursion should be thought of as two parts. 1) A base case. This is trivial case that can easly be determined. What you have so far is a good start to a base case. 1) Is the string less then 3? Then return false. 2) Does the string start with "bab" then return true. 2) A recursive case. This splits the problem up into a tinier problems, and if you split them up enough hopefully you have a base case. @Logiraptro has a good example of a simple recursion. public static boolean hasBAB(String str) { if (str.length() &lt; 3) return false; if (str.substring(0,3).equals("bab")) return true; else return hasBAB(str.substring(1)); } This uses your base cases, and as a recursive case checks the string from index one on. This reduces our string only by one charter, but is enough to solve the problem. This means we end up with a stack level of the length of the string. Can we do better? A little, by breaking the problem in half we only need a stack level of ln(n) where n is the length of string. This is not a big deal for most lengths, but if you were searching a string with a length of one million it maybe significant. With the first version our stack would be about a 1,000,000 deep! But with this binary version we only need to go about 14 levels deep. This comes at a cost though, our solution because more involved. Our base cases 1) If the string is less then the length of the search string, return false. 2) If the string is length of the search string, if they are equal return true, else return false. 3) If the string appears over the mid point of the string return true. If none of these are true,we break the string into two parts and recursively check over that string. Here is an example of that algorithm, you can replace "bab" with any string you like, although it hasn't been fully tested for that I'm pretty sure it will be okay. public static boolean hasBAB(String str) { String searchString = "bab"; // Base cases if (str.length() &lt; searchString.length()) return false; i…
has comment: http://stackoverflow.com/comment/32625511
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32624427
has comment: http://stackoverflow.com/comment/32626411

http://stackoverflow.com/comment/32671998
comment on: http://stackoverflow.com/q/21622261
type: QuestionComment
has text: http://docs.oracle.com/javase/tutorial/collections/interfaces/map.html ?
type: Comment
score: 1

http://stackoverflow.com/comment/32711915
comment on: http://stackoverflow.com/a/21644762
score: 1
type: AnswerComment
has text: @JanickBernet pre Java 7 you could use a `switch` on `char` which would work fine because the OP only needs one letter.
type: Comment

http://stackoverflow.com/a/21673975
has comment: http://stackoverflow.com/comment/32770569
score: 4
has comment: http://stackoverflow.com/comment/32770500
upvote count: 4
downvote count: 0
answers question: http://stackoverflow.com/q/21671934
has comment: http://stackoverflow.com/comment/32770282
type: Answer
has body: Here is a code example that should give you an idea how to solve your problem: public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout(3, false)); Label firstLabel = new Label(shell, SWT.NONE); firstLabel.setText("PROMPT:"); firstLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); Text firstText = new Text(shell, SWT.BORDER); firstText.setText("hello"); firstText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); Button firstButton = new Button(shell, SWT.PUSH); firstButton.setText("Say"); firstButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); Label secondLabel = new Label(shell, SWT.NONE); secondLabel.setText("PROMPT:"); secondLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, true)); Text secondText = new Text(shell, SWT.BORDER | SWT.MULTI | SWT.WRAP); secondText.setText("hello"); secondText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Button secondButton = new Button(shell, SWT.PUSH); secondButton.setText("Say"); secondButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, true)); shell.pack(); shell.open(); shell.setSize(400, 300); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } Looks like this: Without SWT.BORDER:

http://stackoverflow.com/q/21587027
type: Question
answer count: 2
tagged with: sql-server
score: 0
upvote count: 1
downvote count: 1
linked to: http://stackoverflow.com/q/3572626
favorite count: 0
has body: i am working with store procedure i.e CREATE PROCEDURE test ( @INPUTPARAM INT, @OUTPUTPARAM VARCHAR(20) ) AS SELECT @OUTPUTPARAM=S.NAME+','+D.NAME FROM STUDENT S,DEPARTMENT D WHERE S.DEPTID=D.DEPARTID AND D.DEPARTID=@INPUTPARAM BEGIN END how to get out parameter from java class using hibernate please share code example
has answer: http://stackoverflow.com/a/21587077
type: UnansweredQuestion
tagged with: stored-procedures
has title: How to call ms sql store procedure using hibernate 4.0
tagged with: java
tagged with: hibernate
has answer: http://stackoverflow.com/a/21587113
linked to: http://stackoverflow.com/q/3493495

http://stackoverflow.com/a/21560793
downvote count: 0
answers question: http://stackoverflow.com/q/21560566
type: Answer
has comment: http://stackoverflow.com/comment/32563971
score: 3
has comment: http://stackoverflow.com/comment/32563993
has body: If you're using java 8 please skip to the end! I'd probably create a map to do this, but it seems like you're new to Java so I'll describe the more basic way. You should first create a list(arraylist) like so: // create an arraylist (list based on an array) List&lt;Emp&gt; emps = new ArrayList&lt;Emp&gt;(); Then you can add objects to the list: emps.add(new Emp(10,"Anitha",1000,"AE")); emps.add(new Emp(20,"Chaitanya",2000,"SE")); . . Now you can start filtering! So, suppose you have a getName() method in class Emp, you can write a function such as this: // this function takes a list and a name, and filters the list by the name public static List&lt;Emp&gt; filterEmpsByName(List&lt;Emp&gt; emps, String name){ // a place to store the result List&lt;Emp&gt; result = new ArrayList&lt;Emp&gt;(); // iterate over the list we got for (Emp emp: emps){ // save only the elements we want if (emp.getName().equals(name)){ result.add(emp); } } return result; } Now, filtering would be a simple matter of calling that function: // print to standard output the result of our function on the "main" list `emp` with name "Anitha" for (Emp emp : filterEmpsByName(emps, "Anitha")){ System.out.println(emp.toString()); // make sure toString() is overridden in Emp class } Now for the second part which is a bit more tricky: // this function takes a list and a name, and filters the list by the name public static List&lt;Emp&gt; getDistinctlyNamedEmps(List&lt;Emp&gt; emps, String name) { // this time we use a map which is A LOT faster for this kind of operation Map&lt;String, Emp&gt; result = new HashMap&lt;String, Emp&gt;(); // iterate over the list we got for (Emp emp : emps) { // save only the elements we want if (result.get(emp.getName()) == null ) { result.put(emp.getName(), emp); } } // convert map to list - not mandatory if you can use the map as is... return new ArrayList&lt;Emp&gt;(result.values()); } Notice that you can also write a comparator that compares objects using the name/any oth…
upvote count: 3

http://stackoverflow.com/comment/32662105
has text: Are you sure? The protocol being used in your example code is WHOIS, not HTTP. Completely different.
comment on: http://stackoverflow.com/q/21616059
type: Comment
type: QuestionComment
score: 1

http://stackoverflow.com/comment/32631594
type: QuestionComment
comment on: http://stackoverflow.com/q/21598261
score: 0
type: Comment
has text: But if you are writing an aspect around the method, that is not going to escape from the method not executing. you might just end up executing the `method1()` and `method2()` twice. Because, your program is actually going to enter `sourceMethod()` even with the aspect weaved into your program.

http://stackoverflow.com/comment/32745751
comment on: http://stackoverflow.com/a/21664103
score: 1
has text: @user3255780: I didn't *have* to - it's just cleaner that way. Typically I have one "primary constructor" which everything else chains to. That way if you have something that you need to validate, you only need to do it in one place.
type: AnswerComment
type: Comment

http://stackoverflow.com/a/21524546
has comment: http://stackoverflow.com/comment/32499530
has body: Replace ccc with EEE in the pattern to specify the day of the week: SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy"); Example: https://gist.github.com/kmb385/8781482
upvote count: 2
has comment: http://stackoverflow.com/comment/32499593
type: Answer
answers question: http://stackoverflow.com/q/21524476
score: 2
has comment: http://stackoverflow.com/comment/32499481
downvote count: 0

http://stackoverflow.com/comment/32667211
has text: I don't know why , but it always return 0. When it supposed to return 22.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21618909
type: Comment

http://stackoverflow.com/comment/32766080
comment on: http://stackoverflow.com/q/21676143
type: Comment
type: QuestionComment
score: 2
has text: The "where are strings created" and "where are parameters stored" aspects of this question have mostly separate answers. The parameter passing mechanism operates the same on Strings and other objects, but depending on the JVM, String literals may or may not be allocated in a special manner.

http://stackoverflow.com/comment/32485120
comment on: http://stackoverflow.com/q/21516125
score: 0
type: Comment
type: QuestionComment
has text: Also confused. Is the question whether any of the numbers is the sum of two other numbers in the set, or whether any of them is the sum of two immediately preceding numbers, or whether any of them is the sum of two numbers obtained from somewhere else? Is the `numbers` array presorted into ascending order or not? Are they guaranteed to all be positive or not? Whichever you're looking for, recursion is almost certainly the wrong solution to the problem, and you're making this fifteen times harder than it needs to be. Think about how you would solve it manually, and implement that.

http://stackoverflow.com/comment/32616954
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21589983
score: 0
has text: This is why you should use XML APIs to write XML out as well as to parse it in. They will take care of escaping for you, automagically. If you insist on hand-coding your XML serializations, it will be your responsibility to re-implement that logic.

http://stackoverflow.com/a/21515523
type: Answer
answers question: http://stackoverflow.com/q/21515401
has body: mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.myMapView)).getMap(); //LOGCAT shows Null at above statement only Did you confirm that ((MapFragment) getFragmentManager().findFragmentById(R.id.myMapView)) is not null? On this line is that possible that it can be null? Some discussion over here might help about google services: getMap() returning null
score: 0

http://stackoverflow.com/comment/32709397
score: 0
type: AnswerComment
has text: thanks so whats your suggestion? first user make the request, I send the requests to all web services then show the result to user and clear up the memory, while serving second user in real time? Imagine 1000 users are using the system synonymously , then the memory should be really big to support them all right?
comment on: http://stackoverflow.com/a/21642286
type: Comment

http://stackoverflow.com/q/21522518
linked to: http://stackoverflow.com/q/9603759
type: Question
tagged with: java
has title: Errors on tomcat's logs
has comment: http://stackoverflow.com/comment/32495931
linked to: http://stackoverflow.com/q/11028610
tagged with: jsp
linked to: http://stackoverflow.com/q/4438374
has body: i have a jsp site hosted on tomcat 7. Even if the site seems to work, i can see a lot of errors on tomcat's logs. Actually from time to time the site stops working and i have to restart tomcat. But i cant understand what i should do to solve this problems. I dont run the server, so i dont know if i made mistakes in my code or the problems depend on the company that runs the server. Feb 3, 2014 2:17:11 AM org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/local/jdk1.6.0_37/jre/lib/amd64/server:/usr/local/jdk1.6.0_37/jre/lib/amd64:/usr/local/jdk1.6.0_37/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib Feb 3, 2014 2:17:11 AM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host} Setting property 'xmlValidation' to 'false' did not find a matching property. Feb 3, 2014 2:17:11 AM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host} Setting property 'xmlNamespaceAware' to 'false' did not find a matching property. Feb 3, 2014 2:17:11 AM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'debug' to '5' did not find a matching property. Feb 3, 2014 2:17:12 AM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-bio-12418"] Feb 3, 2014 2:17:12 AM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 2164 ms Feb 3, 2014 2:17:12 AM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina Feb 3, 2014 2:17:12 AM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.47 Feb 3, 2014 2:17:12 AM org.apache.catalina.core.StandardContext resourcesStart SEVERE: Error starting sta…
tagged with: tomcat
score: 0
has comment: http://stackoverflow.com/comment/32497181
has comment: http://stackoverflow.com/comment/32495917
has comment: http://stackoverflow.com/comment/32495923
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32495806

http://stackoverflow.com/q/21592201
has body: I'm trying to pass an ArrayList from handle.jsp to main.jsp, but it doesn't let me do it. It keeps saying "Type mismatch: cannot convert from Object to ArrayList". main.jsp: <%@ page import="java.util.ArrayList" %> Hobby Manager <% ArrayList<String> hobbies = session.getAttribute("hobbies"); out.println(hobbies.size()); out.println(session.getAttribute("hobbies")); %> Add new hobby! What new hobby are you wishing to add? handle.jsp: <%@ page import="java.util.ArrayList" %> <% ArrayList<String> hobbies = new ArrayList<String>(); String hobbyName = request.getParameter("hobbyName"); if(hobbyName == null){ out.println("Please enter a hobby before clicking add! Dummy. "); } else{ hobbies.add(hobbyName); for(int index = 0; index < hobbies.size(); index ++){ out.println(hobbies.get(index) + " "); } session.setAttribute("hobbies", hobbies); } %> I have tried passing it as a string object, and passing it as an object alone but nothing seems to work.
upvote count: 1
answer count: 1
tagged with: jsp
accepted answer: http://stackoverflow.com/a/21592289
favorite count: 0
tagged with: arraylist
has answer: http://stackoverflow.com/a/21592289
downvote count: 0
score: 1
has title: How to pass an ArrayList from one jsp to another using session
type: AnsweredQuestion
tagged with: session
tagged with: java
has comment: http://stackoverflow.com/comment/47143467
type: Question

http://stackoverflow.com/a/21642588
has body: "I want to know ,how to add elements in the comboBox at the run-time?" See DefaultComboBoxModel#addElement public void addElement(E anObject) Description copied from interface: MutableComboBoxModel Adds an item at the end of the model. The implementation of this method should notify all registered ListDataListeners that the item has been added. In your case, since you have no reference to the model, you need to do this DefaultComboBoxModel model = (DefaultComboBoxModel)jComboBox2.getModel(); model.addElement(...) And see How to Use ComboBoxes Also learn to read the Documentation. Just go Here and you could've searched DefaultComboBoxModel or any other class you are unfamiliar with.
score: 5
upvote count: 5
has comment: http://stackoverflow.com/comment/41649540
has comment: http://stackoverflow.com/comment/32722901
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21642530
has comment: http://stackoverflow.com/comment/32708036

http://stackoverflow.com/comment/32532336
score: 1
comment on: http://stackoverflow.com/q/21542564
type: Comment
type: QuestionComment
has text: yep, unless there are 100 numbers in the file or you have negative numbers you'll always get 0

http://stackoverflow.com/comment/135621015
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/44426447
has text: JFrame is not a JComponent. So it does not answser
score: 0

http://stackoverflow.com/q/21652527
has title: Get actual painted pixel from Graphics2D geometry object
type: UnansweredQuestion
tagged with: shapes
has comment: http://stackoverflow.com/comment/32726908
tagged with: java
has answer: http://stackoverflow.com/a/21681109
type: Question
tagged with: graphics
has body: I paint geometry objects (in this example a simple line) in an Graphics2D object like this: Graphics2D g2d = (Graphics2D) g; g2d.setStroke(new BasicStroke(width)); Line2D.Double line = new Line2D.Double(oldPosition.x, oldPosition.y, newPosition.x, newPosition.y); g2d.draw(connectionLine); Is there any possibility to get the actual painted pixel from the line shape? I went through a lot of documentation but I was not able to find anything. The closest object I found was the PathIterator, but that is not solving my problem neither... PathIterator pi = connectionLine.getPathIterator(new AffineTransform()); while (!pi.isDone()) { double[] coords = new double[6]; pi.currentSegment(coords); System.out.println(Arrays.toString(coords)); pi.next(); } // OUTPUT (line was painted from (20,200) to (140,210): // [20.0, 200.0, 0.0, 0.0, 0.0, 0.0] // [140.0, 210.0, 0.0, 0.0, 0.0, 0.0] Is there any method which returns me an array of pixel coordinates which were really painted? If not, is there anything you can suggest? Would it be easy to implement the algorithm myself (keep in mind, that the line has a width > 1 pixel)? Or should I draw the line on a new blank (white) image, so that I can iterate over every pixel separately and check whether he is white or not (sounds weird...)? I would really appreciate an useful answer - best regards, Felix
has comment: http://stackoverflow.com/comment/32725303
score: 0
tagged with: graphics2d
has comment: http://stackoverflow.com/comment/32725158
answer count: 1
tagged with: applet

http://stackoverflow.com/comment/32487719
type: AnswerComment
has text: Ahhh! NOW it makes sense! Interfaces are implicitly static! That's the reason! It also complains if I try to define the local class as static (`... static abstract class Bar ...` in my first example raises an error). And, of course, it makes no sense to define anything as "static" inside a method...
comment on: http://stackoverflow.com/a/21516677
type: Comment
score: 0

http://stackoverflow.com/comment/32570253
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21564331
has text: Why are you using that if-statement with < 0.000000000001 in inList to check if the number is in the list?
score: 1

http://stackoverflow.com/q/21627851
type: Question
has comment: http://stackoverflow.com/comment/32682705
tagged with: java
tagged with: jboss
has title: Jboss comunity deployment tab not showing on eclipse
tagged with: eclipse
score: 0
has comment: http://stackoverflow.com/comment/32682497
has body: For some reason after I installed Jboss Tools on Kepler, the jboss is not showing the deployment tab. Anyone knows if thats is a Jboss tools bug?
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32681482
has comment: http://stackoverflow.com/comment/32682523
answer count: 0
has comment: http://stackoverflow.com/comment/32681883

http://stackoverflow.com/q/21666273
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21666344
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/36191887
has title: How to calculate student's average grade using HashMap?
has body: In the Student class, I need to add a method to put a new course into the student's course collection and a method that calculates and returns the student's average grade. I keep getting "NaN" as a result when I try to calculate the student's average grade. Would appreciate any help. Thanks. Below is my source code for the Student class. import java.util.HashMap; import java.util.Set; public class Student extends Member { // instance variables of class Student private HashMap&lt;String, Double&gt; courses; public Student() { super(); courses = new HashMap&lt;String, Double&gt;(); } /** * Constructor * @param firstName * @param lastName * @param emailAddress * @param bcitId */ public Student(String firstName, String lastName, String emailAddress, String bcitId) { super(firstName, lastName, emailAddress, bcitId); courses = new HashMap&lt;String, Double&gt;(); } public void addCourse(String course, Double grade) { if(!courses.isEmpty()) { courses.put(course, grade); } } public Double getAverageGrade() { Double averageGrade = 0.0; int counter = 0; if(!courses.isEmpty()){ Set&lt;String&gt; course = courses.keySet(); for(String grade : course){ averageGrade += courses.get(grade); counter++; } } return (averageGrade /= counter); } }
score: 0
has answer: http://stackoverflow.com/a/21666351
has answer: http://stackoverflow.com/a/21666292
answer count: 4

http://stackoverflow.com/comment/32539817
type: Comment
score: 0
comment on: http://stackoverflow.com/q/21546645
type: QuestionComment
has text: Is this an assignment that requires you to use those wacky arrays? Arrays are an awful way to do this. If they are not specifically required, follow JB Nizet's advice and become aware to objects.

http://stackoverflow.com/q/21613321
score: 0
has answer: http://stackoverflow.com/a/21613663
tagged with: user-interface
has answer: http://stackoverflow.com/a/21613411
has body: So I'm creating a calculator that calculates BMR &amp; TDEE. I'm having issues when I run the code because everything shows up, except my radio button groups. Can anyone tell me what I need to add/what I'm doing wrong to get them to show up on the screen? private JRadioButton female, male, sedentary, lightlyActive, modActive, veryActive, extrActive; private JButton calculate; public BMRGUI() { heightLabel = new JLabel ("Height (in.) "); weightLabel = new JLabel ("Weight (lbs) "); ageLabel = new JLabel ("Age (yrs)"); female = new JRadioButton ("Female"); female.setMnemonic(KeyEvent.VK_C); female.setActionCommand("Female"); female.setSelected(true); male = new JRadioButton ("Male"); male.setMnemonic(KeyEvent.VK_C); male.setActionCommand("Male"); ButtonGroup group = new ButtonGroup(); group.add(female); group.add(male); female.addActionListener(this); male.addActionListener(this); sedentary = new JRadioButton ("Sedentary"); sedentary.setMnemonic(KeyEvent.VK_C); sedentary.setActionCommand("Sedentary"); sedentary.setSelected(true); lightlyActive = new JRadioButton ("Lightly active"); lightlyActive.setMnemonic(KeyEvent.VK_C); lightlyActive.setActionCommand("Lightly active"); modActive = new JRadioButton ("Moderately active"); modActive.setMnemonic(KeyEvent.VK_C); modActive.setActionCommand("Moderately active"); veryActive = new JRadioButton ("Very active"); veryActive.setMnemonic(KeyEvent.VK_C); veryActive.setActionCommand("Very active"); extrActive = new JRadioButton ("Extremely active"); extrActive.setMnemonic(KeyEvent.VK_C); extrActive.setActionCommand("Extremely active"); ButtonGroup group2 = new ButtonGroup(); group2.add(sedentary); group2.add(lightlyActive); group2.add(modActive); group2.add(veryActive); group2.add(extrActive); sedentary.addActionListener((ActionListener) this); lightlyActive.addActionListener((ActionListener) this); modActive.addActionListener((ActionListener) this); veryActive.addActionListener((ActionListener) this); extrActive.addActionListener(…
has title: Adding a radio button group to the screen
tagged with: jradiobutton
tagged with: swing
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/21613411
tagged with: buttongroup
type: Question
answer count: 2
accepted answer: http://stackoverflow.com/a/21613663

http://stackoverflow.com/comment/32497760
type: AnswerComment
has text: They certainly do. `inheritance` has it's uses, but when you're dealing with classes that are as big as `Component` types in Java, you really need to consider another approach.
type: Comment
comment on: http://stackoverflow.com/a/21523569
score: 0

http://stackoverflow.com/a/21645344
upvote count: 1
downvote count: 0
has body: Your Logcat say it all, Read this Invalid int: "Enter first number" Your are casting a string value to int, which results java.lang.NumberFormatException.
type: Answer
score: 1
answers question: http://stackoverflow.com/q/21645206

http://stackoverflow.com/comment/32760173
score: 0
has text: *SOH-STX-ETX-EOT* - these are control code identifiers; the font in question seems to use byte values in the ASCII control char range but does not map them to a proper value in its **ToUnicode** map. Thus, your output still contains these values.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21659463

http://stackoverflow.com/comment/32872735
has text: Did this work ? What version of Cassandra did this work against?
type: Comment
comment on: http://stackoverflow.com/a/21714396
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32529305
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21540900
has text: I am getting the current session from HibernateUtils.currentSession
score: 0

http://stackoverflow.com/comment/32539333
comment on: http://stackoverflow.com/a/21530716
has text: Check your Query String properly..
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/21625445
has comment: http://stackoverflow.com/comment/32677431
has comment: http://stackoverflow.com/comment/32679141
has body: Summary: Program asks user to enter their number of shoes (0-200). Once they type in a non-number, calculations are made. Variables made are: int numberOfShoes =0;int highNumber = 0; int lowNumber = 0; int sumofShoesInputted = 0; int sumOfSquares = 0; double mean = 0; double variance = 0; double standardDeviation = 0; The formula for variance for a part of my program is: variance = (sumofTheSquares - (sumOfShoesInputted*sumOfShoesInputted / numberOfShoes)) / numberOfShoes -1) for standard deviation it's Math.sqrt(variance); I'm just confused what exactly is the "sum of the squares" part. *Would also like to add that the formula was given to me. **Even though it's homework I'm completely confused by this ONE thing. I'm not asking you to write my program. Just asking for a simple explanation.
type: UnansweredQuestion
upvote count: 1
downvote count: 6
score: -5
has comment: http://stackoverflow.com/comment/32679244
tagged with: java
has title: What is sum of squares when it comes to variance (calculation in Java)?
type: Question
has answer: http://stackoverflow.com/a/21625505
answer count: 1
has comment: http://stackoverflow.com/comment/32677213
favorite count: 0
has comment: http://stackoverflow.com/comment/32678906

http://stackoverflow.com/comment/32639772
type: QuestionComment
has text: I presume you mean like this: http://developer.android.com/training/custom-views/index.html
comment on: http://stackoverflow.com/q/21589476
score: 0
type: Comment

http://stackoverflow.com/comment/32793308
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21660328
has text: Thanks, I think I got it now.

http://stackoverflow.com/comment/32557489
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21556774
has text: Thanks a lot @Prince But I still cant find out, how this could be used at my last function... As a return type, or a the type of the movements variable?

http://stackoverflow.com/q/21520419
tagged with: http://stackoverflow.com/tag/html
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/32493340
upvote count: 1
has answer: http://stackoverflow.com/a/21520942
type: AnsweredQuestion
score: 1
tagged with: java
possible better answer: http://stackoverflow.com/a/21520942
type: Question
has answer: http://stackoverflow.com/a/21520458
linked to: http://stackoverflow.com/q/4112686
has body: Following are my get() and post() method of my servlet. I am very new to servlet. When I call from my client, this servlet create a new page and overwrite all my html elements in my client. What I want to do is I just stay remain in my html page and let servlet do his job alone. public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { // Check that we have a file upload request isMultipart = ServletFileUpload.isMultipartContent(request); DiskFileItemFactory factory = new DiskFileItemFactory(); // maximum size that will be stored in memory factory.setSizeThreshold(maxMemSize); // Location to save data that is larger than maxMemSize. factory.setRepository(new File("c:\\temp")); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); // maximum file size to be uploaded. upload.setSizeMax( maxFileSize ); try{ // Parse the request to get file items. List fileItems = upload.parseRequest(request); // Process the uploaded file items Iterator i = fileItems.iterator(); while ( i.hasNext () ) { FileItem fi = (FileItem)i.next(); if ( !fi.isFormField () ) { // Get the uploaded file parameters String fieldName = fi.getFieldName(); String fileName = fi.getName(); String contentType = fi.getContentType(); boolean isInMemory = fi.isInMemory(); long sizeInBytes = fi.getSize(); // Write the file if( fileName.lastIndexOf("\\") &gt;= 0 ){ file = new File( filePath + fileName.substring( fileName.lastIndexOf("\\"))) ; }else{ file = new File( filePath + fileName.substring(fileName.lastIndexOf("\\")+1)) ; } fi.write( file ) ; } } }catch(Exception ex) { System.out.println(ex); } } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { throw new ServletException("GET method used with " + getClass( ).getName( )+": POST method required."); }
tagged with: jsp
has title: How to avoid servlet responding with new html page?
accepted answer: http://stackoverflow.com/a/21520458
tagged with: servlets
answer count: 2
has comment: http://stackoverflow.com/comment/32493361

boolean-expression
tags question: http://stackoverflow.com/q/21524329
tag name: boolean-expression
type: Tag

http://stackoverflow.com/a/21612263
answers question: http://stackoverflow.com/q/21609334
downvote count: 0
has comment: http://stackoverflow.com/comment/32759221
type: Answer
has body: Please ask at the mailing list dev@platform.netbeans.org and provide a non-working sample, so that the issue can be reproduced.
upvote count: 1
score: 1

http://stackoverflow.com/q/21599323
favorite count: 0
has body: I want a java function where if we pass the lat,long of a object, whether that object lies inside a area. Again this Area is defined by lat,long for example I define a area with 3 lat/long positions.( a rectangle ) and if I pass a lat/long position it should return me whether its within the rectangle.
has title: Find an object within an geographical area
has answer: http://stackoverflow.com/a/21629907
upvote count: 2
type: UnansweredQuestion
tagged with: geolocation
tagged with: maps
linked to: http://stackoverflow.com/q/4287780
score: 2
tagged with: java
has comment: http://stackoverflow.com/comment/32632156
has comment: http://stackoverflow.com/comment/32632112
type: Question
downvote count: 0
answer count: 1

http://stackoverflow.com/a/21556665
type: Answer
score: 2
has body: Try something like this: PreparedStatement ps = null; ps = con.prepareStatement("select concat(first_name,' ',last_name) as full_name from employee where salary between ? and ?"); int i=1; ps.setInt(i++, 30000); ps.setInt(i++, 40000); rs = ps.executeQuery(); Replace parameters with "?" and add then afterward one by one. Then execute.
answers question: http://stackoverflow.com/q/21556594
downvote count: 0
upvote count: 2

http://stackoverflow.com/q/21644150
has comment: http://stackoverflow.com/comment/32710651
upvote count: 2
has answer: http://stackoverflow.com/a/21645181
type: UnansweredQuestion
tagged with: android-ndk
type: Question
tagged with: java
has title: Android NDK. Decrease size of APK
has body: I compiled an application for Android, using Android NDK. And I have two projects. First - is a library with ndk libs and jni folder. Second - is my working application which includes first project as a library. The size of my app is too big as for me (30Mb). And i want decrease it. I read tutorials, but they tell to do basic options, such as deleting logs and unused code, etc. But this doesn't help me. Can I delete jni folder with all my .c files (if i am correct in final build they are unnecessary, because they are compiled into .so libs), or this doesn't decreases the size of apk? Or may be i should do something else? Thank you for interest to my question!
has comment: http://stackoverflow.com/comment/32711505
has answer: http://stackoverflow.com/a/44506378
score: 2
downvote count: 0
favorite count: 0
linked to: http://stackoverflow.com/q/19954156
tagged with: android
has answer: http://stackoverflow.com/a/21645770
answer count: 4
tagged with: c++
has answer: http://stackoverflow.com/a/41120706

http://stackoverflow.com/comment/32573166
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21565750
has text: Would Import work with a file, or just a project?
score: 0

http://stackoverflow.com/comment/32747804
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21664968
has text: This sounds like marketing speak, and [a Google search would seem to reinforce that preconception](https://www.google.co.uk/search?q=data-intensive+business-logic&oq=data&aqs=chrome.1.69i57j69i59j0l4.1689j0j7&sourceid=chrome&espv=210&es_sm=93&ie=UTF-8#q=%22data-intensive+business+logic%22). Everything that mentions this phrase on the first few pages is a product-sheet of some description. Data-intensive business logic would just be business logic that deals with a lot of data.

http://stackoverflow.com/comment/32539833
type: QuestionComment
comment on: http://stackoverflow.com/q/21547537
score: 0
has text: give us example please ?
type: Comment

http://stackoverflow.com/q/21618830
has comment: http://stackoverflow.com/comment/32705315
has answer: http://stackoverflow.com/a/21619240
score: 0
answer count: 3
tagged with: applet
has answer: http://stackoverflow.com/a/21619465
tagged with: time
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21618920
tagged with: java
tagged with: date
has body: I have a small problem but I don't know to fix it. I create simple Applet in which should be simple digital clock. I created all methods correctly but repaint methods doesn't repaint my applet. Can you check my code and say where is mistake. Thanks. public class DigitalClock extends JApplet implements Runnable { private Thread timeThread; Date date = new Date(); public void start() { timeThread = new Thread(this, "Clock"); timeThread.start(); } @Override public void stop() { if (timeThread == null) { return; } timeThread = null; } @Override public void run() { while (timeThread != null) { repaint(); try { timeThread.sleep(1000); } catch (InterruptedException e) { } } } @Override public void paint(Graphics g) { date.setTime(System.currentTimeMillis()); g.drawString(date.toString(), 50, 95); } }
type: Question
has title: Time doesn't repaint in Applet

http://stackoverflow.com/comment/32733360
type: Comment
has text: Thank you very much! The correct SOAP Action was: "http://tempuri.org/abmeldung" now it worked.
comment on: http://stackoverflow.com/a/21656435
type: AnswerComment
score: 0

http://stackoverflow.com/comment/32658642
type: Comment
has text: the problem is in my DoublyLinkedList class I haven't defined the last node, but only the first node.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21614232

http://stackoverflow.com/comment/32575368
has text: That looks more like a ternary operator
score: 3
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21566956

cxf
tags question: http://stackoverflow.com/q/21670376
type: Tag
tags question: http://stackoverflow.com/q/21576186
tags question: http://stackoverflow.com/q/21590757
tags question: http://stackoverflow.com/q/21616339
tags question: http://stackoverflow.com/q/21629636
tags question: http://stackoverflow.com/q/21517275
tag name: cxf
tags question: http://stackoverflow.com/q/21534965
tags question: http://stackoverflow.com/q/21585909
tags question: http://stackoverflow.com/q/21515313
tags question: http://stackoverflow.com/q/21639755

http://stackoverflow.com/a/21847151
type: Answer
has body: use Java startElement and endElement for DOM Parsers
answers question: http://stackoverflow.com/q/21534340
score: 0

http://stackoverflow.com/comment/32596141
type: AnswerComment
score: 0
type: Comment
has text: You could create a constructor that takes in an object of L1, and assigns the appropriate fields from L1 to the new L2. You would have to do this by hand though.
comment on: http://stackoverflow.com/a/21567214

http://stackoverflow.com/comment/32507310
type: Comment
type: QuestionComment
score: 0
has text: How do you send the message? Can you post your code?
comment on: http://stackoverflow.com/q/21520011

http://stackoverflow.com/q/21608835
has comment: http://stackoverflow.com/comment/32657384
score: 3
has comment: http://stackoverflow.com/comment/32657905
linked to: http://stackoverflow.com/q/40641181
tagged with: transactions
upvote count: 3
tagged with: java
tagged with: hibernate
type: Question
has answer: http://stackoverflow.com/a/76254122
has body: we are currently using Hibernate 3.6 on our application. Application is full of uses of Hibernate Session, Spring HibernateTemplate - recently we started migrating the code to more standard Entity Manager, but it is a gradual process. So I got into the problem where we use both hibernate session and entity manager in one method (service method which is @Transactional) and one operation depends on the other, like this: hqlQuery = session.createQuery("DELETE FROM address WHERE user_id = 1"); hqlQuery.executeUpdate(); jpaQuery = em.createQuery("DELETE FROM user WHERE id = 1"); jpaQuery.executeUpdate(); // this throws org.hibernate.exception.ConstraintViolationException - cannot delete user because there are still references to this user in address I suspect that this could be because Hibernate uses different transaction (in different connection) for Session and EntityManager - delete of addreses are done in one transaction and delete of user is done in a second transaction - then it's clear why delete of user fails because of foreign key constraint. Session and EntityManager share the same transaction manager but I have no idea if this is important. I wanted to test this by getting some transaction ID from session.getTransaction() and em.getTransaction() but there's no identifier. So the question is - is it possible to share one transaction between Session and EntityManager? If it is, how? Thanks!
tagged with: session
has title: Do Hibernate session and Entity manager share the same transaction?
has answer: http://stackoverflow.com/a/76233869
answer count: 2
downvote count: 0
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32654030

http://stackoverflow.com/comment/32632079
score: 2
type: AnswerComment
has text: Link only answers are highly discouraged. Might be good as a comment.
type: Comment
comment on: http://stackoverflow.com/a/21599302

http://stackoverflow.com/comment/32616481
comment on: http://stackoverflow.com/a/21589896
score: 0
type: AnswerComment
type: Comment
has text: Sorry to hassle you, but what would the classpath:com//XX/XX/ look like...could someone give me an example?

http://stackoverflow.com/q/21674304
favorite count: 0
type: UnansweredQuestion
has title: Running a servlet using URL
has body: hi there , i have a url of a servlet . i want to invoke this servlet using this url in java application(Google app engine to rackespace server). is it possible or not. String url = "https://......."; HttpURLConnection conn = (HttpURLConnection)new URL(url).openConnection(); conn.setDoOutput(true);
tagged with: java
has answer: http://stackoverflow.com/a/21674364
downvote count: 1
type: Question
score: -1
tagged with: servlets
upvote count: 0
answer count: 1

http://stackoverflow.com/a/21538370
type: Answer
answers question: http://stackoverflow.com/q/21538160
has body: I havent work with Jackson but maybe instanceof will help, in pseudocode if (value instanceof Class){Class c=value;} else{String s=value;}
score: 0

http://stackoverflow.com/comment/32547370
has text: Make sure that a JAR containing `org.json.JSONException` can be found in the usual classpath places (`WEB-INF/lib` most probably).
type: Comment
comment on: http://stackoverflow.com/q/21552038
type: QuestionComment
score: 0

http://stackoverflow.com/a/21515483
has comment: http://stackoverflow.com/comment/32509061
score: 0
answers question: http://stackoverflow.com/q/21515331
type: Answer
has comment: http://stackoverflow.com/comment/32509096
has comment: http://stackoverflow.com/comment/32509509
has body: It will be difficult to maintain such data(insert and fetch), using text file.The efficient way is to go with excel sheet in which each column will handle the different record for single iteration.You can move with Apache POI library which is simple to read and write.I have google one example at http://viralpatel.net/blogs/java-read-write-excel-file-apache-poi/

http://stackoverflow.com/a/21672146
type: Answer
downvote count: 0
has body: While bigger memory might mean bigger problems, I'd say there's nothing (except the GC which you've excluded) what could extend 9 seconds to 48 minutes (factor 320). A big heap makes seemingly worse spatial locality possible, but I don't think it matters. I disagree with Tim's answer w.r.t. "having to leave the cache for everything". There's also the TLB which a cache for the virtual address translation, which could cause some problems with very large memory. But again, not factor 320. I don't think there's anything in the JVM which could cause such problems. The only reason I can imagine is that you have some swap space which gets used - despite the fact that you have enough physical memory. Even slight swapping can be the cause for a huge slowdown. Make sure it's off (and possibly check swappiness).
score: 3
has comment: http://stackoverflow.com/comment/117512576
has comment: http://stackoverflow.com/comment/32761017
accepted answer of: http://stackoverflow.com/q/21671725
answers question: http://stackoverflow.com/q/21671725
type: AcceptedAnswer
upvote count: 3

http://stackoverflow.com/comment/32712953
type: Comment
type: QuestionComment
has text: @tintinmj: Agree with you. I've edited my question.
score: 0
comment on: http://stackoverflow.com/q/21645559

http://stackoverflow.com/a/21519575
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21519541
has comment: http://stackoverflow.com/comment/32492166
has body: The way you are using is not the proper way of using PreparedStatement Do like this String charitysql = "SELECT wardName, charityRoomID FROM tbl_charityward,tbl_charityroom2 WHERE tbl_charityward.charityWardID = ?"; pst = conn.prepareStatement(charitysql); pst.setInt(1,tbl_charityroom2.charityWardID); rs = pst.executeQuery();

http://stackoverflow.com/a/21613780
downvote count: 0
score: 1
has body: If there's no documentation to help, try: &lt;#list .data_model?keys as varName&gt; ${varName} &lt;/#list&gt; It's quite data-model-specific if it works and if returns all variables through. So if that fails, you can put a breakpoint at freemarker.template.Template.process to see what's passed to the template as the data-model.
upvote count: 1
answers question: http://stackoverflow.com/q/21555174
type: Answer

http://stackoverflow.com/comment/32810336
score: 0
comment on: http://stackoverflow.com/a/21676422
type: AnswerComment
type: Comment
has text: @Ingo, you missed my point. Even with your preprocessor the literal strings are still in the constant pool. The constant pool is an abstract concept, not a concrete implementation; the JLS specifies, effectively, that literal strings are in the constant pool. It doesn't matter how the compiler goes about putting them there.

http://stackoverflow.com/q/21660136
downvote count: 0
score: 1
tagged with: java
tagged with: eclipse
type: Question
linked to: http://stackoverflow.com/q/10579716
tagged with: eclipse-plugin
has title: Executing eclipse plugin automatically
upvote count: 1
answer count: 1
has body: I try to create an eclipse plugin which deletes some files when eclipse workbench is closed. I started with the Hello, World command plugin project and added a IWorkbenchListener like mentioned in this toppic Eclipse shut down hook able to stop the termination. The listener is added when I press a special button in the eclipse menu bar (which is added by this plugin). How can I automatically add this IWorkbenchListener, without the need of clicking on any menu entry?
favorite count: 0
has answer: http://stackoverflow.com/a/21660164
accepted answer: http://stackoverflow.com/a/21660164
type: AnsweredQuestion

http://stackoverflow.com/a/21542040
has comment: http://stackoverflow.com/comment/32550911
has body: You are trying to call a function newAL which you do not have. Use: new AL() The new keyword specifies that you want to create a new instance of the AL class.
downvote count: 0
score: 3
type: Answer
answers question: http://stackoverflow.com/q/21542019
upvote count: 3

http://stackoverflow.com/comment/32724421
comment on: http://stackoverflow.com/q/21652101
has text: Which is line 59? What exception do you get?
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/33418967
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/21527774
has text: My problem is, that the call hierarchy does this only for a single selected method, but I need a complete overview of all call hierarchies.

http://stackoverflow.com/q/21612555
has answer: http://stackoverflow.com/a/23390122
has comment: http://stackoverflow.com/comment/32656775
answer count: 2
tagged with: functional-programming
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/30108266
tagged with: java-8
has title: Why does IntToDoubleFunction not come with IntToDoubleFunction andThen(DoubleUnaryOperator after)
upvote count: 3
type: UnansweredQuestion
tagged with: java
has body: Why does DoubleUnaryOperator come with default implementations for composition like DoubleUnaryOperator andThen(DoubleUnaryOperator after); but IntToDoubleFunction does not (as of b124, assumed to be feature complete). Is there a special reason that IntToDoubleFunction does not have a IntToDoubleFunction andThen(DoubleUnaryOperator after); ?
type: Question
score: 3

http://stackoverflow.com/a/21548495
answers question: http://stackoverflow.com/q/21548440
has body: if (this.myString != null &amp;&amp; this.myString.equals(comparisonObj.myString)) { changedVars.add("myString"); }
type: Answer
score: 0
upvote count: 1
downvote count: 1

http://stackoverflow.com/comment/32510699
comment on: http://stackoverflow.com/q/21530750
type: Comment
has text: My suspect is that you check the device String by using **if (device == "")** instead of **if (device.equals(""))**
type: QuestionComment
score: 1

http://stackoverflow.com/comment/100274525
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21580201
has text: I was testing it by making a ws package in the same MVC application, just for making it easy for myself, but it has to be a separate project. The MVC application is configured with spring3 and hibernate 4 with mvc:annotation-driven tag. I configured a WSServletContextListener and a WSServlet in my web.xml file.

http://stackoverflow.com/comment/32692888
comment on: http://stackoverflow.com/q/21633532
has text: Why don't you just use maven? http://stackoverflow.com/questions/6829961/create-complete-ear-project-with-maven-and-eclipse-helios
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21638783
downvote count: 0
favorite count: 0
has body: I want to set up breakpoints and remote debugging for a Jboss application in Intellij. From this blog post, I believe the first step is to run jboss in debug mode. I have Jboss 5.1.0.GA. so I don't have the same files (standalone.sh) as mentioned in How to start JBOSS 7 in debug mode?">this Stack Overflow which covers it for Jboss 7. How do I do this for Jboss-5.1.0.GA? In run.conf, I see these two lines: # Sample JPDA settings for remote socket debugging #JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n" # Sample JPDA settings for shared memory debugging #JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_shmem,address=jboss,server=y,suspend=n" Is all I need to do uncomment one of those? Then in Intellij what would be the corresponding settings? Here:
has title: How to Start Jboss 5.1.0.GA in Debug Mode for Remote Debug in Intellij
upvote count: 2
has answer: http://stackoverflow.com/a/35217193
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/24325107
score: 2
tagged with: java
type: Question
tagged with: intellij-idea
tagged with: jboss
answer count: 2

http://stackoverflow.com/a/21535857
has comment: http://stackoverflow.com/comment/32565411
score: 0
accepted answer of: http://stackoverflow.com/q/21534545
has comment: http://stackoverflow.com/comment/32867097
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32618354
answers question: http://stackoverflow.com/q/21534545
has comment: http://stackoverflow.com/comment/32613983
type: Answer
has comment: http://stackoverflow.com/comment/32839501
has comment: http://stackoverflow.com/comment/32561086
has body: By the answer in HTML 5 linked, I assume you need something like this: PGraphics mask, filler; int x; void setup(){ size(400,400); // initial bg color, the white circle... background(255); //init both PGraphics mask = createGraphics(width, height); filler = createGraphics(width, height); // draw a circle as a mask mask.beginDraw(); mask.background(255); mask.noStroke(); mask.fill(0); mask.ellipse(width/2, height/2, 200, 200); mask.endDraw(); } void draw(){ // a changing bg x = (x+1)%255; background(x); //dinamiaclly draw random rects filler.beginDraw(); filler.noStroke(); filler.fill(random(255), random(255), random(255)); filler.rect(random(width), random(height), random(5,40), random(5,40)); filler.endDraw(); // get an imge out ofthis... PImage temp = filler.get(); //mask image temp.mask(mask); //dispay it image(temp, 0, 0); } void mousePressed(){ mask.beginDraw(); mask.background(0); mask.noStroke(); mask.fill(255); mask.ellipse(width/2, height/2, 200, 200); mask.endDraw(); } void mouseReleased(){ mask.beginDraw(); mask.background(255); mask.noStroke(); mask.fill(0); mask.ellipse(width/2, height/2, 200, 200); mask.endDraw(); } second example PGraphics mask, front, back; int x; void setup(){ size(400,400); background(0); //init both PGraphics mask = createGraphics(width, height); front = createGraphics(width, height); back = createGraphics(width, height); } void draw(){ float x = random(width); float y = random(height); float sx = random(5, 40); // draw a circle as a mask mask.beginDraw(); mask.background(255); mask.noStroke(); mask.fill(100); mask.ellipse(mouseX, mouseY, 200, 200); mask.endDraw(); //dinamiaclly draw random colored rects to PG front.beginDraw(); front.noStroke(); front.fill(random(255), random(255), random(255)); front.rect(x, y, sx, sx); front.endDraw(); //dinamiaclly draw random gray rects to display back.beginDraw(); back.stroke(200); back.fill(0, 100); back.rect(x, y, sx, sx); back.endDraw(); // get an imge out ofthis... PImage temp = front.ge…
has comment: http://stackoverflow.com/comment/32614065
has comment: http://stackoverflow.com/comment/32558976
has comment: http://stackoverflow.com/comment/32551729

http://stackoverflow.com/comment/32582646
has text: @JonSkeet : I simply sysout the byte[]. Is it okay??
score: 0
comment on: http://stackoverflow.com/q/21570972
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32603250
score: 4
type: Comment
type: QuestionComment
has text: `i <= theCode.length()` should be `i < theCode.length()`, check your `for` loop.
comment on: http://stackoverflow.com/q/21582936

http://stackoverflow.com/a/23404711
upvote count: 2
answers question: http://stackoverflow.com/q/21646129
type: Answer
score: 2
downvote count: 0
has body: In my case the problem was solved simply by setting the background of the adview: ... layout.addView(adView, adParams); adView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); ... you can use any other color.

widget
tags question: http://stackoverflow.com/q/21667717
type: Tag
tags question: http://stackoverflow.com/q/21604836
tag name: widget

http://stackoverflow.com/comment/32525670
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21538318
type: Comment
has text: the problem is when I start overwriting a file , all data in the file is lost , only the new overwriten information remains. Unless there is a way to keep the old data , I mean overwrite file as if a simple byte[] buffer. Is there such a way ?

http://stackoverflow.com/q/21637838
tagged with: http-redirect
has comment: http://stackoverflow.com/comment/32723890
tagged with: spring-mvc
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/32703648
has answer: http://stackoverflow.com/a/21641076
type: Question
answer count: 2
score: 0
has comment: http://stackoverflow.com/comment/32719130
linked to: http://stackoverflow.com/q/11763779
accepted answer: http://stackoverflow.com/a/21641076
has body: I need to input URL like this http://localhost:8080/first and after that my controller must go to http://localhost:8080/second and so on until I came to http://localhost:8080/end. Its something like recursion. At the end point I need to pring a list. @Controller @RequestMapping(value = "/", method = RequestMethod.GET) public class CascadeController { @RequestMapping("/first") String first(ModelMap model) { model.put("list", new ArrayList&lt;String&gt;()); return "/second"; } @RequestMapping("/second") String second(ModelMap model) { ((List) model.get("list")).add("A"); return "/third"; } @RequestMapping("/third") String third(ModelMap model) { ((List) model.get("list")).add("B"); return "end"; } } end.jsp &lt;%@ page import="java.util.List" %&gt; &lt;html&gt; &lt;body&gt; &lt;%for(String s : (List&lt;String&gt;) request.getAttribute("list")){%&gt; &lt;%=s%&gt; &lt;%}%&gt; &lt;/body&gt; &lt;/html&gt; Is anybody can explain what is wrong with my code?
possible better answer: http://stackoverflow.com/a/21649991
has answer: http://stackoverflow.com/a/21649991
has title: How to build cascade controller?

http://stackoverflow.com/a/21645668
type: Answer
answers question: http://stackoverflow.com/q/21643817
has body: try to passe your second jframe as parameter in the first jframe than use it to change your textfield
score: 0

http://stackoverflow.com/a/21646108
answers question: http://stackoverflow.com/q/21645960
type: Answer
downvote count: 0
score: 1
has body: you can custom SQLException like this import java.sql.SQLException; public class SqlException extends SQLException{ public SqlException(String message){ super(message); } public static void main(String[] args) throws SqlException { throw new SqlException("name not found .!?"); } }
upvote count: 1

http://stackoverflow.com/a/21515891
answers question: http://stackoverflow.com/q/21515796
has body: from the doc of hashmap of java (http://docs.oracle.com/javase/7/docs/api/java/util/HashMap.html) HashMap.put() Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced. So the new value will replace the old value.
type: Answer
score: 2
downvote count: 0
upvote count: 2

http://stackoverflow.com/a/21642020
downvote count: 1
has comment: http://stackoverflow.com/comment/32707132
has comment: http://stackoverflow.com/comment/32707106
has body: Change for(checkint != (int)checkint) as for(;checkint != (int)checkint;) From Doc The general form of the for statement can be expressed as follows: for (initialization; termination; increment) { statement(s) } The initialization expression initializes the loop; it's executed once, as the loop begins. When the termination expression evaluates to false, the loop terminates. The increment expression is invoked after each iteration through the loop; it is perfectly acceptable for this expression to increment or decrement a value. BUT this will leads to an infinite loop in your code. So change it as if (checkint != (int)checkint)
has comment: http://stackoverflow.com/comment/32707114
answers question: http://stackoverflow.com/q/21642013
type: Answer
has comment: http://stackoverflow.com/comment/32707131
upvote count: 2
score: 1

http://stackoverflow.com/comment/32676904
comment on: http://stackoverflow.com/q/21625054
score: 0
type: QuestionComment
has text: Thanks for editing the post but please help me to solve this problem
type: Comment

http://stackoverflow.com/a/21563880
has body: The most faster pattern is probably: "\"([^\"]++)\"" with find method, the result is in capturing group 1.
type: Answer
accepted answer of: http://stackoverflow.com/q/21563827
answers question: http://stackoverflow.com/q/21563827
score: 1
upvote count: 1
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/32711869
has text: @kleopatra Both didn't work for me (Ubuntu) and unfortunately this has to be cross-platform (and has to work with jdk6). I get it to work using `JOptionPane.showInputDialog()`, but that's just… uncomfortable. I'd really like having a quick&easy text field popping up.
score: 0
comment on: http://stackoverflow.com/q/21644142
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32612800
type: QuestionComment
has text: Just use `g.drawString`. Forget the label. fyi, the reason your setBounds doesn't work is because it only works with null layouts. JPanel has a default FlowLayout
comment on: http://stackoverflow.com/q/21587309
type: Comment
score: 0

http://stackoverflow.com/comment/32599735
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21580841
has text: If you mean if (expire.after(start) && !expire.after(end)) it doesn't work
score: 0

http://stackoverflow.com/q/21620183
has comment: http://stackoverflow.com/comment/32669414
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/32668988
favorite count: 0
type: Question
tagged with: regex
accepted answer: http://stackoverflow.com/a/21621330
has title: Splitting recursive groups
upvote count: 1
answer count: 1
has comment: http://stackoverflow.com/comment/32668984
has body: I have a string in this format: a,b,c[a,b,c[a]],d And what (in the end) I want to end up with, is a b c.a c.b c.c.a d Any suggestion on how to approach this task?
tagged with: java
has comment: http://stackoverflow.com/comment/32669957
has answer: http://stackoverflow.com/a/21621330
type: AnsweredQuestion

http://stackoverflow.com/comment/32627182
type: AnswerComment
type: Comment
has text: Thanks for the verification. Having my assumptions verified has great value to me even though I was secretly hoping I was wrong. :-) I'll accept this answer.
comment on: http://stackoverflow.com/a/21589020
score: 0

http://stackoverflow.com/q/21564650
has comment: http://stackoverflow.com/comment/32571535
has answer: http://stackoverflow.com/a/21564914
upvote count: 0
linked to: http://stackoverflow.com/q/3748
type: UnansweredQuestion
tagged with: local-storage
type: Question
tagged with: jakarta-ee
score: -2
has title: Manage storage of images in a Java web applicaition
tagged with: java
has body: I'm working on a Java Enteprise web application that manages many image files. I do not want to store the image files in a database. Do I have to store the images on the filesystem? Is there an established framework for this purpose? To access to images to save on filesystem for to optimize the performance that you give me advice?
has comment: http://stackoverflow.com/comment/32570967
tagged with: image
has comment: http://stackoverflow.com/comment/32571362
has comment: http://stackoverflow.com/comment/32571828
has comment: http://stackoverflow.com/comment/32570958
downvote count: 2
has comment: http://stackoverflow.com/comment/32571057
has comment: http://stackoverflow.com/comment/32571436
answer count: 1
favorite count: 0

http://stackoverflow.com/q/21553270
accepted answer: http://stackoverflow.com/a/21572045
type: Question
tagged with: javafx-8
tagged with: borderpane
has title: Superimposed node in javafx
answer count: 1
downvote count: 0
favorite count: 0
has body: Maybe the title of my question is not good but actually I don't know how to name it. So I will try to explain my problem really clearly. So I want to know if its possible to make like a "ErrorBar" inside my scene. I understand by this to show this element over other node inside the scene for a short time. I have a BorderPane and I want when I have an error in my application (like webservice error) to show the error to the user. And for that I want to move a gridpane from the right to the left of the screen without change my scene (like put this object in the top of the borderpane). I don't have any example with a software who do it but I think some stuff in Javascript can do something like this. Just show a green or red bar in the top of the website event it's somthing already show. If someone know how to do that it will be great. Actually I use Java 8 latest version. Feel free to ask more if you want to know more about my question. Thanks in advance. Fische
has answer: http://stackoverflow.com/a/21572045
tagged with: java-8
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1

http://stackoverflow.com/comment/57249023
type: AnswerComment
comment on: http://stackoverflow.com/a/21793358
type: Comment
has text: This link is old, and I'd sure like to know the answer.
score: 0

http://stackoverflow.com/a/21534417
upvote count: 1
has body: You need to call addTopping. Eg, newPizza.addTopping(topping). Also, correct the addTopping method. Replace toppings.add("topping") with toppings.add(topping); And I am sure you need to put more effort to learn Java :)
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/21534091
type: Answer

http://stackoverflow.com/comment/32762595
has text: ORA-00604: error occurred at recursive SQL level 1 ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06512: at line 8 ORA-00907: missing right parenthesis
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21671013

http://stackoverflow.com/a/21627399
type: Answer
accepted answer of: http://stackoverflow.com/q/21627214
has comment: http://stackoverflow.com/comment/32681209
has body: If that's all the assignment, this is the solution: public class MyClass{ Instructor tutor; }
has comment: http://stackoverflow.com/comment/32680675
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21627214
score: 0

http://stackoverflow.com/comment/32518572
type: Comment
comment on: http://stackoverflow.com/a/21534651
score: 0
type: AnswerComment
has text: There are two problems with this answer: iterating over the output of `ls`, and relying on the word-split expansion of a parameter to be equivalent to the original command line. Both will break when they involve file names that contain whitespace.

http://stackoverflow.com/a/21665612
has comment: http://stackoverflow.com/comment/32787960
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21633274
upvote count: 11
answers question: http://stackoverflow.com/q/21633274
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33002966
type: Answer
score: 11
has body: No. A truststore contains nothing but public data: the public certificates of CAs that you trust. A KeyStore contains a private key and its certificate: your digital identity. They may even be controlled by different people. Don't conflate their functions.

http://stackoverflow.com/q/21606428
upvote count: 12
has answer: http://stackoverflow.com/a/21606717
downvote count: 0
has answer: http://stackoverflow.com/a/21606797
has title: Serialize and Deserialize an RSA public key
score: 12
answer count: 3
has comment: http://stackoverflow.com/comment/61748170
has comment: http://stackoverflow.com/comment/61750838
has body: KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); kpg.initialize(1024); KeyPair kp = kpg.genKeyPair(); Key publicKey = kp.getPublic(); Key privateKey = kp.getPrivate(); I want to create just the public key from a byte[]. I have tried this as an experiment: publicKey = new SecretKeySpec(publicKey.getEncoded(), publicKey.getAlgorithm()); But decryption using that key then fails. I have also tried serializing the key with ObjectOutputStream, but serialization fails. java.io.NotSerializableException: org.apache.harmony.xnet.provider.jsse.OpenSSLKey I read here that I can't use SecretKeySpec with RSA. so as long as you are talking of a SecretKey and not an RSA or DSA key then you don't have to go through any contortions involving KeyGenerator or the like. Anyone know how to perform these contortions or a way of doing this.
favorite count: 0
possible better answer: http://stackoverflow.com/a/21606909
has answer: http://stackoverflow.com/a/21606909
accepted answer: http://stackoverflow.com/a/21606797
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/61763836
tagged with: java
has comment: http://stackoverflow.com/comment/61763935
type: Question

http://stackoverflow.com/q/21663606
has answer: http://stackoverflow.com/a/21663838
answer count: 2
downvote count: 0
has title: Use of static method with enum in Java
has body: I have this assignment that I need use a static method to get student IDs then within that static method evaluate them if the students have passed or failed their classes. It is a bit challenging for me because the static method should only take one argument. Can this be accomplished by not changing private variables to private static variables? Any direction is much appreciated. import java.util.ArrayList; public class Grade { public static void main(String[] args) { ArrayList&lt;GradeDetail&gt; gradeList = new ArrayList&lt;GradeDetail&gt;() ; System.out.println("Student ID: "); for(String s : args) { boolean match = false; for(GradeDetail grade : GradeDetail.values()) { if(s.equals(grade.getCode())) { gradeList.add(grade); match = true; } } if(!match) { System.out.printf("unknown student ID entered!"); } } System.out.println("Students who passed: "); //Some function here System.out.println("Students who failed: ") //Some function here return; } } enum GradeDetail { JOHN (101, 90) , ROB (102, 50) , JAMES (103, 55) ; private final int studentID; private final int studentGrade; GradeDetail(int id, int sGrade) { studentID = id; studentGrade = sGrade; } public int getID() {return studentID;} public int getGrade() {return studentGrade;} } I honestly don't know how to go about this..
favorite count: 0
has answer: http://stackoverflow.com/a/21663825
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32744606
has comment: http://stackoverflow.com/comment/32744822
upvote count: 1
type: Question
tagged with: enums
score: 1
tagged with: java

http://stackoverflow.com/q/21574730
has comment: http://stackoverflow.com/comment/32589273
tagged with: java
has answer: http://stackoverflow.com/a/21574811
type: Question
has answer: http://stackoverflow.com/a/21575085
has answer: http://stackoverflow.com/a/21574892
answer count: 6
has body: Can any one suggest me to write a logic for this without using collections. I have a string s="This is the place called island and it is a nice place "; Input String to find repetition word is: "is"; output should be : 4
score: 0
has title: Repetition of a word in String with out using collections
tagged with: string
has answer: http://stackoverflow.com/a/21583186
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21574968
has answer: http://stackoverflow.com/a/21574866

http://stackoverflow.com/a/21606377
answers question: http://stackoverflow.com/q/21603626
type: Answer
has body: Here is the doc on the manifest file and what you need to put into it. All jars that get downloaded need to be signed with the same certificate AND you need to update the applet tag to include permission - see here for applet tag doc. This all assumes you are using Java7 update 51 or greater. Earlier versions were showning warnings but not blocking the applet or webstart apps.
score: 0

http://stackoverflow.com/q/21657886
has body: I'm trying to overlay a background picture with a .png sample, and I don't know how it works. I tried to create 2 JPanels, but didn't find out how to overlay them, then I tried to create 2 JLabels and once again, they just stay separated. Have you any idea ? Thanks !
tagged with: overlay
tagged with: swing
has comment: http://stackoverflow.com/comment/32735093
has answer: http://stackoverflow.com/a/21659000
tagged with: java
tagged with: image
type: Question
tagged with: awt
linked to: http://stackoverflow.com/q/2658554
score: 0
has title: Overlay images Java
answer count: 1
type: UnansweredQuestion

http://stackoverflow.com/comment/32709415
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21643449
score: 0
has text: `// TODO add your handling code here:` Remove these comments once you've added some handling code or a comment as to why it is not implemented! They are noise.

http://stackoverflow.com/comment/32717803
score: 0
type: Comment
has text: I think it is not clear whether you want to evaluate the data over a period of time (say, the last 10 minutes) or just ask for the data periodically and do something with it instantly. If you want to evaluate data over a period of time then you absolutely need to save the data (at least temporarily) in some kind of storage, be it an object or a database.
comment on: http://stackoverflow.com/a/21648087
type: AnswerComment

http://stackoverflow.com/q/21660080
has comment: http://stackoverflow.com/comment/32757082
has body: How does one draw a Rectangle around an Actor with a given Texture? The Rectangle should scale, move and rotate along with the Actor. Current implementation: shapeRenderer.begin(ShapeType.Line); shapeRenderer.setColor(Color.RED); Vector2 _BL = localToStageCoordinates(new Vector2(getX(), getY())); Vector2 _BR = localToStageCoordinates(new Vector2(getX() + getWidth(), getY())); Vector2 _TL = localToStageCoordinates(new Vector2(getX(), getY() + getHeight())); Vector2 _TR = localToStageCoordinates(new Vector2(getX() + getWidth(), getY() + getHeight())); float xmin = MyMathUtils.min(_BL.x, _BR.x, _TL.x, _TR.x); float ymin = MyMathUtils.min(_BL.y, _BR.y, _TL.y, _TR.y); float xmax = MyMathUtils.max(_BL.x, _BR.x, _TL.x, _TR.x); float ymax = MyMathUtils.max(_BL.y, _BR.y, _TL.y, _TR.y); shapeRenderer.rect(xmin, ymin, xmax-xmin, ymax-ymin); shapeRenderer.setColor(Color.BLUE); shapeRenderer.circle(_BL.x, _BL.y, 2); shapeRenderer.circle(_BR.x, _BR.y, 2); shapeRenderer.circle(_TL.x, _TL.y, 2); shapeRenderer.circle(_TR.x, _TR.y, 2); shapeRenderer.end(); The problem is that Rectangle doesn't fit well after moving the Actor. I think it has to do with a bad Coordinate Transformation. I would like to do something like this: Matix4 m = actor.computeTransform(); shapeRenderer.setTransformMatrix(m); but the computeTransform() is available in Group (which is an Actor), but not in Actor itself.
answer count: 0
type: UnansweredQuestion
tagged with: bounding-box
upvote count: 1
tagged with: rect
has comment: http://stackoverflow.com/comment/32758679
score: 1
tagged with: java
has title: libgdx rectangle around actor
type: Question
tagged with: libgdx
has comment: http://stackoverflow.com/comment/33613531
downvote count: 0
favorite count: 0

http://stackoverflow.com/a/21564135
score: 1
answers question: http://stackoverflow.com/q/21563996
has comment: http://stackoverflow.com/comment/32569861
has body: It is much clearer where your mistake is if you assign variables to each of the method call results: Map&lt;Integer, Integer&gt; map = Yoghurts.getHashMap(); Set&lt;Map.Entry&lt;Integer, Integer&gt;&gt; entrySet = map.entrySet(); Iterator&lt;Map.Entry&lt;Integer, Integer&gt;&gt; iterator = entrySet.iterator(); Map.Entry&lt;Integer, Integer&gt; entry = iterator.next(); What is left to do is to extract the key from the Map.Entry: int location = entry.getKey(); Note that you are also unboxing the Integer key to an int here, which could throw an exception if the key is null (I believe LinkedHashMap supports null keys).
upvote count: 1
type: Answer
downvote count: 0

http://stackoverflow.com/q/21524759
has comment: http://stackoverflow.com/comment/32499772
has answer: http://stackoverflow.com/a/21524785
has title: Java Date format weird
type: AnsweredQuestion
upvote count: 1
downvote count: 1
type: Question
has body: I have an issue where I would like to get the start of the day, however it seems to be setting it to 12:00 via automatic. SimpleDateFormat dfFull = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); String todayDate = dfFull.parse("2014-06-06 00:00:00"); today = dfFull.format(todayDate); System.out.println(today); Why is this spitting out: 2014-06-06 12:00:00 The 12:00:00 is the issue
tagged with: java
accepted answer: http://stackoverflow.com/a/21524785
tagged with: date
has answer: http://stackoverflow.com/a/21524804
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/32499766
possible better answer: http://stackoverflow.com/a/21524804
favorite count: 0

http://stackoverflow.com/q/21557813
downvote count: 1
has comment: http://stackoverflow.com/comment/32559144
type: Question
has answer: http://stackoverflow.com/a/21558011
has answer: http://stackoverflow.com/a/21558493
has comment: http://stackoverflow.com/comment/32558262
linked to: http://stackoverflow.com/q/1180397
score: -1
answer count: 2
upvote count: 0
has title: Selective direct download protecting
favorite count: 0
has comment: http://stackoverflow.com/comment/32558589
type: UnansweredQuestion
tagged with: java
has body: I want to restrict the direct download of a file on my site (let's say www.me.com/asd.txt) but permit to my java applet in www.me.com/javaapplet.jar to be able to download it. Is there a simple way for this? I'm not sure if it's relevant, but the server is running Apache 2.2.24 Anticipated thanks for your help, sboda
has comment: http://stackoverflow.com/comment/32558952
has comment: http://stackoverflow.com/comment/32559778

http://stackoverflow.com/comment/32690021
type: Comment
comment on: http://stackoverflow.com/a/21631769
score: 0
type: AnswerComment
has text: +1 from me - this is a terrific answer. Thoughtful, well written.

http://stackoverflow.com/q/21655137
accepted answer: http://stackoverflow.com/a/21664469
downvote count: 0
has comment: http://stackoverflow.com/comment/32746235
favorite count: 0
tagged with: maven
linked to: http://stackoverflow.com/q/14427351
has body: I'm trying to deploy a simple JSF app onto a Tomcat 8 server on my local machine. When I run mvn tomcat:deploy, I get the following feedback: C:\_workspace\portfolio>mvn tomcat:deploy [INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building the effective model for com.italic:portfolio:war:0.0.1-SNAPSHOT [WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:tomcat-maven-plugin is missing. @ line 38, column 12 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects. [WARNING] [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Portfolio 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] >>> tomcat-maven-plugin:1.1:deploy (default-cli) @ portfolio >>> [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ portfolio --- [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ portfolio --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ portfolio --- [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ portfolio --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ portfolio --- [INFO] [INFO] --- maven-war-plugin:2.2:war (default-war) @ portfolio --- [INFO] Packaging webapp [INFO] Assembling webapp [portfolio] in [C:\_workspace\portfolio\t…
type: AnsweredQuestion
score: 3
upvote count: 3
has comment: http://stackoverflow.com/comment/32734435
tagged with: java
has answer: http://stackoverflow.com/a/21664469
type: Question
has title: Maven won't deploy to tomcat; gives '405' error
answer count: 1
tagged with: tomcat

image
tags question: http://stackoverflow.com/q/21537296
tags question: http://stackoverflow.com/q/21517659
tags question: http://stackoverflow.com/q/21564650
tags question: http://stackoverflow.com/q/21517025
tags question: http://stackoverflow.com/q/21568535
tags question: http://stackoverflow.com/q/21651176
tags question: http://stackoverflow.com/q/21532553
tags question: http://stackoverflow.com/q/21668014
tags question: http://stackoverflow.com/q/21515552
tags question: http://stackoverflow.com/q/21666053
tags question: http://stackoverflow.com/q/21516299
tags question: http://stackoverflow.com/q/21548411
tags question: http://stackoverflow.com/q/21631276
tags question: http://stackoverflow.com/q/21625051
tags question: http://stackoverflow.com/q/21532761
tags question: http://stackoverflow.com/q/21625170
tags question: http://stackoverflow.com/q/21671582
tags question: http://stackoverflow.com/q/21657886
tags question: http://stackoverflow.com/q/21528504
tags question: http://stackoverflow.com/q/21555526
tags question: http://stackoverflow.com/q/21573863
tag name: image
tags question: http://stackoverflow.com/q/21655354
tags question: http://stackoverflow.com/q/21572090
tags question: http://stackoverflow.com/q/21546770
tags question: http://stackoverflow.com/q/21573758
type: Tag
tags question: http://stackoverflow.com/q/21638199
tags question: http://stackoverflow.com/q/21642101
tags question: http://stackoverflow.com/q/21552634
tags question: http://stackoverflow.com/q/21600141
tags question: http://stackoverflow.com/q/21533356

windows
tags question: http://stackoverflow.com/q/21582724
tags question: http://stackoverflow.com/q/21553414
tags question: http://stackoverflow.com/q/21583339
tags question: http://stackoverflow.com/q/21596866
tags question: http://stackoverflow.com/q/21623718
tags question: http://stackoverflow.com/q/21580907
tags question: http://stackoverflow.com/q/21534002
tags question: http://stackoverflow.com/q/21593099
tags question: http://stackoverflow.com/q/21578418
tags question: http://stackoverflow.com/q/21528903
tags question: http://stackoverflow.com/q/21671934
tags question: http://stackoverflow.com/q/21572423
tags question: http://stackoverflow.com/q/21601466
tags question: http://stackoverflow.com/q/21670264
tags question: http://stackoverflow.com/q/21550289
tags question: http://stackoverflow.com/q/21546388
tags question: http://stackoverflow.com/q/21664485
tags question: http://stackoverflow.com/q/21637917
type: Tag
tags question: http://stackoverflow.com/q/21624035
tags question: http://stackoverflow.com/q/21662439
tags question: http://stackoverflow.com/q/21658061
tags question: http://stackoverflow.com/q/21675836
tag name: windows
tags question: http://stackoverflow.com/q/21559366
tags question: http://stackoverflow.com/q/21622382

http://stackoverflow.com/a/21652588
answers question: http://stackoverflow.com/q/21652237
has body: This problem assumes there is only one number which occurs odd number of times in the array. If you have more such numbers - say K of them: a1, a2, ... aK, then at the end of the loop, in res you will get this value. res == a1 ^ a2 ^ ... ^ aK From that value you cannot infer/extract all K unknown numbers a1, a2, ... aK. Buf ... you see, if K=1 (i.e. if you have exactly one number occurring odd number of times), at the end you will get in res just that number. Use the first approach as long as you understand why it works. Also, in the second approach the space is not O(n) but O(s), where s is the count of distinct values in your array. And as you have only 1 number occurring odd number of times we can say for sure that 2*s + 1 &lt;= n i.e. s &lt;= (n-1)/2. So the space complexity is O((n-1)/2) in the second approach. You achieve it when your array looks like this: s numbers occurring twice, and 1 number occurring once.
score: 0
type: Answer

http://stackoverflow.com/comment/32659599
has text: Thank you so much! That fixed it and it counts them right now! I will try the HashMap out as well!
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/21612939
type: Comment

http://stackoverflow.com/q/21623962
upvote count: 1
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21624130
score: 1
has body: Do the virtual machines that run programs written in managed languages (eg. .Net, Mono or Java) make use of the same virtualization technologies as virtual machine applications (eg. VirtualBox or VMWare)? Particularly; do they make use of Intel hardware virtualization (VT-x)? If not, why? Is this because of some fundamental difference between the concepts (they just happen to share a name but are entirely different) or something else?
tagged with: java
tagged with: mono
has title: Do managed programming languages make use of hardware virtualization?
tagged with: managed
type: Question
downvote count: 0
tagged with: .net
tagged with: vm-implementation
has answer: http://stackoverflow.com/a/21624130
answer count: 1
favorite count: 0

http://stackoverflow.com/q/21621423
has body: I have a JSP page where i am getting a Date value from my action class. I am not able to understand how it is handled as: &lt;s:property value="#someDate"/&gt; gives me date 2/7/14 whereas &lt;s:property value="{#someDate}"/&gt; gives me Date as [Wed Feb 7 00:00:00 IST 2014] Can someone tell me how date value is actually handled here, as date is returned in different formats?
score: 5
answer count: 1
linked to: http://stackoverflow.com/q/21607045
tagged with: jsp
has comment: http://stackoverflow.com/comment/32672094
favorite count: 0
tagged with: struts2
has comment: http://stackoverflow.com/comment/32672109
upvote count: 5
has comment: http://stackoverflow.com/comment/32768206
downvote count: 0
has comment: http://stackoverflow.com/comment/32818457
type: Question
has comment: http://stackoverflow.com/comment/32755700
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/32680222
has title: How struts property tag works with date value?
tagged with: struts-tags
has answer: http://stackoverflow.com/a/23173939
accepted answer: http://stackoverflow.com/a/23173939
has comment: http://stackoverflow.com/comment/32671405

http://stackoverflow.com/comment/32649995
has text: @Petey I need the byet's array for writing into file, but while getting the bytes it fails 'response.getEntity().getBytes()'
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21608974

http://stackoverflow.com/comment/32680510
type: QuestionComment
comment on: http://stackoverflow.com/q/21621781
has text: It is quite impossible to debug this, as you are not sharing any information about your JMS consumer. Do you experience the same problem if you replace your JMS consumer with a Mule JMS Inbound Endpoint?
score: 0
type: Comment

http://stackoverflow.com/q/21526132
has answer: http://stackoverflow.com/a/21526426
has comment: http://stackoverflow.com/comment/32503498
favorite count: 0
has body: I'm new to Spring so I been mucking around with security side of things. Everytime I run my application I get: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.security.core.userdetails.UserDetailsService com.entirety.app.config.SecurityConfig.userDetailsServiceImplementation; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.security.core.userdetails.UserDetailsService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} I've gone through my code with a fine comb and can't pinpoint the issue. Spring Framework Version: 3.2.5.RELEASE Spring Security Version: 3.2.0.M2 SecurityConfig.java package com.entirety.app.config; import com.entirety.app.service.implement.UserDetailsServiceImplementation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import javax.sql.DataSource; @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(prePost…
upvote count: 9
has comment: http://stackoverflow.com/comment/32504330
tagged with: spring
tagged with: autowired
answer count: 4
has comment: http://stackoverflow.com/comment/32504821
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32502418
downvote count: 0
has comment: http://stackoverflow.com/comment/32502372
tagged with: java
possible better answer: http://stackoverflow.com/a/21526426
has comment: http://stackoverflow.com/comment/32503043
has answer: http://stackoverflow.com/a/21539620
accepted answer: http://stackoverflow.com/a/21539620
score: 9
type: Question
has answer: http://stackoverflow.com/a/21534879
has comment: http://stackoverflow.com/comment/32502369
has comment: http://stackoverflow.com/comment/32503424
has answer: http://stackoverflow.com/a/21527800
tagged with: spring-security
has comment: http://stackoverflow.com/comment/32504879
has comment: http://stackoverflow.com/comment/32504641
has comment: http://stackoverflow.com/comment/32504101
has comment: http://stackoverflow.com/comment/32503614
has title: Could not autowire field: private org.springframework.security.core.userdetails.UserDetailsService

http://stackoverflow.com/comment/32563286
score: 2
comment on: http://stackoverflow.com/a/21560644
has text: that is not an answer, that's a comment
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32668998
type: QuestionComment
comment on: http://stackoverflow.com/q/21620191
score: 0
has text: Use a Map implementation: http://docs.oracle.com/javase/7/docs/api/java/util/Map.html
type: Comment

http://stackoverflow.com/comment/32710010
score: 0
comment on: http://stackoverflow.com/q/21643817
type: Comment
type: QuestionComment
has text: are you using netbeans?

http://stackoverflow.com/comment/32725609
score: 2
has text: Per convention all class names start with an uppercase character. Try adhering to it as soon as possible, it will make your later Java life much easier.
comment on: http://stackoverflow.com/q/21652761
type: Comment
type: QuestionComment

libgdx
tags question: http://stackoverflow.com/q/21662252
tags question: http://stackoverflow.com/q/21547391
tags question: http://stackoverflow.com/q/21636437
tags question: http://stackoverflow.com/q/21602987
tags question: http://stackoverflow.com/q/21634257
tags question: http://stackoverflow.com/q/21517889
tags question: http://stackoverflow.com/q/21523764
tag name: libgdx
tags question: http://stackoverflow.com/q/21547509
tags question: http://stackoverflow.com/q/21653643
tags question: http://stackoverflow.com/q/21657730
tags question: http://stackoverflow.com/q/21648268
tags question: http://stackoverflow.com/q/21572692
tags question: http://stackoverflow.com/q/21660080
tags question: http://stackoverflow.com/q/21565624
tags question: http://stackoverflow.com/q/21651614
tags question: http://stackoverflow.com/q/21609600
tags question: http://stackoverflow.com/q/21670740
tags question: http://stackoverflow.com/q/21649962
tags question: http://stackoverflow.com/q/21553106
tags question: http://stackoverflow.com/q/21661139
tags question: http://stackoverflow.com/q/21654034
type: Tag
tags question: http://stackoverflow.com/q/21633630
tags question: http://stackoverflow.com/q/21674747
tags question: http://stackoverflow.com/q/21519955
tags question: http://stackoverflow.com/q/21524776
tags question: http://stackoverflow.com/q/21636321
tags question: http://stackoverflow.com/q/21538858
tags question: http://stackoverflow.com/q/21561004
tags question: http://stackoverflow.com/q/21585069
tags question: http://stackoverflow.com/q/21609753
tags question: http://stackoverflow.com/q/21534008
tags question: http://stackoverflow.com/q/21517038
tags question: http://stackoverflow.com/q/21646129
tags question: http://stackoverflow.com/q/21659980
tags question: http://stackoverflow.com/q/21653599
tags question: http://stackoverflow.com/q/21623394
tags question: http://stackoverflow.com/q/21553414
tags question: http://stackoverflow.com/q/21559131
tags question: http://stackoverflow.com/q/21593084
tags question: http://stackoverflow.com/q/21647419
tags question: http://stackoverflow.com/q/21519450

http://stackoverflow.com/comment/32633461
type: AnswerComment
score: 0
type: Comment
has text: According to your code, when you acquire your database connection, it's done via `conn = DataSourceUtils.getConnection( this.dataSource );`. This get's the connection via the datasource, not the SessionFactory
comment on: http://stackoverflow.com/a/21599567

http://stackoverflow.com/a/21701422
type: Answer
has body: I use "styleClass" instead , "class" alone does not work
answers question: http://stackoverflow.com/q/21674977
score: 0
accepted answer of: http://stackoverflow.com/q/21674977
type: AcceptedAnswer

http://stackoverflow.com/a/21591239
has comment: http://stackoverflow.com/comment/32618865
answers question: http://stackoverflow.com/q/21591014
type: Answer
has body: Use a HashMap to store the count and first index of each unique word. Map&lt;String, Map&lt;String, int&gt;&gt; uniqueWords = new HashMap&lt;&gt;(); Then Change your loop through stringArray to only use the first outer loop. You don't need the inner loop. In each iteration through stringArray, do if(!uniqueWords.get(stringArray[i])) { uniqueWords.put(stringArray[i], new HashMap&lt;String, int&gt;()); uniqueWords.get(stringArray[i]).put("Count", 0); uniqueWords.get(stringArray[i]).put("Index", str.indexOf(stringArray[i])); } uniqueWords.get(stringArray[i]).get("Count")++; You can then use the uniqueWords map to build your return array. I'll leave that for you to code.
has comment: http://stackoverflow.com/comment/32618882
score: 0

http://stackoverflow.com/q/21649800
has comment: http://stackoverflow.com/comment/32720444
has answer: http://stackoverflow.com/a/21650046
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21650089
has comment: http://stackoverflow.com/comment/32720348
has comment: http://stackoverflow.com/comment/32720350
has comment: http://stackoverflow.com/comment/32720361
has comment: http://stackoverflow.com/comment/32721722
tagged with: java
has comment: http://stackoverflow.com/comment/32720406
type: Question
duplicate of: http://stackoverflow.com/q/5176391
score: 0
downvote count: 4
tagged with: arrays
has body: I am a beginner to programming. I'm a few weeks into my first programming class, so please bear with me. I am not a person to ask for help, so I have searched for an answer extensively with no luck. This is also my first time posting anything in any type of forum, so if my question structure is off I'm sorry and I will correct for future posts. This is the question I am tackling: Write a program that declares an array "alpha" of 50 elements of type "double". Initialize the array so that the first 25 elements are equal to the square of the index variable and the last 25 elements are equal to three times the index variable. Output the array so that 10 elements per line are printed. This is what I got while running the program. Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:50 on line 23 And this is the code I'm working on import java.util.*; import java.lang.*; public class ProgrammingProblem5_4 { public static void main(String[] args) { int i=0; int count=0; double[] alpha = new double[50]; if (i &gt;= 25) alpha[i] = 3*i; System.out.print(alpha[i]+ " "); count++; if (count==10) { System.out.println("/n"); count=0; } } } } Thank you in advance for any help. I'm not looking to have this done for me, I'm just stuck and need help finding my way.
has comment: http://stackoverflow.com/comment/32720425
favorite count: 0
has answer: http://stackoverflow.com/a/21649888
upvote count: 4
has title: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
linked to: http://stackoverflow.com/q/5176391
answer count: 4
has answer: http://stackoverflow.com/a/21649939

http://stackoverflow.com/comment/32487804
type: Comment
has text: Try doing a clean. If that doesn't work, close Eclipse and re-start. Sometimes that will do it if it can't find an id reference.
comment on: http://stackoverflow.com/a/21517439
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32536152
type: AnswerComment
comment on: http://stackoverflow.com/a/21545263
score: 0
has text: @user3040563: What type of objects are `optionlist`? Are they Lists, JComboboxes?
type: Comment

http://stackoverflow.com/q/21519016
score: 6
upvote count: 6
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/71159150
has title: Java Sphinx "Answers Itself"
tagged with: java
has comment: http://stackoverflow.com/comment/32490269
tagged with: sphinx4
type: Question
has answer: http://stackoverflow.com/a/21524925
has comment: http://stackoverflow.com/comment/32490487
downvote count: 0
has body: I'm having a problem with the Sphinx voice recognition library for Java. I am using it to get input and handle it. The first time I get input, it works. The second time, it immediately answers itself before I have a chance to talk. After that, it just continues to answer itself. I tried allocating before every input and deallocating after every input but that doesn't seem to work. What can I do? Code: This is the method that handles getting input: public void getInput() { if (using) return; using = true; if (!allocated) { JTalk.speak("Please hold."); recognizer.allocate(); allocated = true; } JTalk.speak("Speak now."); Result result = recognizer.recognize(); if (result != null) { String resultText = result.getBestFinalResultNoFiller(); JDispatcher.getInstance().matchInput(resultText); } else { JTalk.speak("Try again."); } using = false; } What you need to know: This is being called from a MouseListener for a TrayIcon. speak(String) runs say &lt;text&gt; from the Runtime. matchInput(String) iterates over all registered listeners in an array and tests for matches. Update 2: As per Nikolay Shmyrev's answer, I tried allocating the microphone in the constructor and starting, then stopping, the microphone at the appropriate times in getInput(). Here's the SphinxBridge class: public class SphinxBridge { private ConfigurationManager cm; private Recognizer recognizer; private Microphone microphone; private boolean using = false; public SphinxBridge() { this.cm = new ConfigurationManager(SphinxBridge.class.getResource("input.config.xml")); this.recognizer = (Recognizer) cm.lookup("recognizer"); this.microphone = (Microphone) cm.lookup("microphone"); recognizer.allocate(); } public void getInput() { if (using) return; using = true; if (!microphone.startRecording()) { JTalk.speak("Cannot start microphone."); return; } JTalk.speak("Speak now."); Result result = recognizer.recognize(); if (result != null) { String resultText = result.getBestFinalResultNoFiller(); JDispatcher.getI…
has comment: http://stackoverflow.com/comment/71065254
answer count: 1
accepted answer: http://stackoverflow.com/a/21524925
favorite count: 0

http://stackoverflow.com/q/21674665
has comment: http://stackoverflow.com/comment/32764029
has comment: http://stackoverflow.com/comment/32765469
has comment: http://stackoverflow.com/comment/32763703
has comment: http://stackoverflow.com/comment/32763576
tagged with: android
has comment: http://stackoverflow.com/comment/32764373
has comment: http://stackoverflow.com/comment/32765432
has body: Here is the code mentioned i am trying to insert values in ArrayList and saving arrayList in Session Storage while key is different everytime.Now my target is to get selected value by passing "position" onclick of Spinner.Here are two mthods that are used to save values in SharePreferences i am getting error while trying to retrieve value from getSpinnerSelectedValue method. public static void setValuesInSession(Context c,String key,List&lt;String&gt; myArrayList) { SharedPreferences sPrefs=PreferenceManager.getDefaultSharedPreferences(c); SharedPreferences.Editor sEdit=sPrefs.edit(); Set&lt;String&gt; set = new HashSet&lt;String&gt;(); Log.i("myArrayList SharePrefereces",""+myArrayList +"::key::"+key); set.addAll(myArrayList); sEdit.putStringSet(key,set); sEdit.commit(); } public static List&lt;String&gt; getValuesOfSession(Context c,String key) { SharedPreferences sPrefs=PreferenceManager.getDefaultSharedPreferences(c); SharedPreferences.Editor sEdit=sPrefs.edit(); Set&lt;String&gt; set = new HashSet&lt;String&gt;(); set = sPrefs.getStringSet(key,null); List&lt;String&gt; setList=new ArrayList&lt;String&gt;(set); return setList; } public static void setSpinnerSelectedValue(Context c,String key,String value) {SharedPreferences pref=PreferenceManager.getDefaultSharedPreferences(c); SharedPreferences.Editor editor=pref.edit(); editor.putString(key,value); } public static String getSpinnerSelectedValue(Context c,String key) { SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(c); String val = sharedPrefs.getString(key,null); return val; } how i am using this code in Activity: SessionManager.setValuesInSession(getActivity().getApplicationContext(),menuFieldInstance.getFieldLabel().toString(),[0100,0200,0300,0400,0500]); siteSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) { Log.i("Spinner Selected Value", "" + position); List&lt…
answer count: 0
has comment: http://stackoverflow.com/comment/32763824
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32763461
has comment: http://stackoverflow.com/comment/32765022
tagged with: java
tagged with: sharedpreferences
tagged with: local-database
has comment: http://stackoverflow.com/comment/32764467
type: Question
score: 0
has title: Failed to pass value to Method retrieve from another method error : java.util.HashSet cannot be cast to java.lang.String
has comment: http://stackoverflow.com/comment/32763635

http://stackoverflow.com/q/21615358
has title: Calling AlertDialog.Builder in Java For Android Fragment When Back Button Is Pressed
score: 0
linked to: http://stackoverflow.com/q/5448653
tagged with: android
answer count: 1
accepted answer: http://stackoverflow.com/a/21615747
type: AnsweredQuestion
tagged with: android-fragments
has comment: http://stackoverflow.com/comment/32660818
tagged with: java
has answer: http://stackoverflow.com/a/21615747
type: Question
has body: I have a simple application (really!) that displays a list and then displays the details of an item on the list based on the user's choice. I do this using Fragments. The details portion is a Fragment which has an EditText in it. Currently, if the user types in the EditText and clicks on the Save button, an AlertDialog.Builder pops up asking her if she wants to save. If she chooses yes, the text is saved to a database. I want the same thing to happen if the user hits the back button. In my class that extends FragmentActivity, I have: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { super.onKeyDown(keyCode, event); DetailFrag frag = (DetailFrag) getSupportFragmentManager().findFragmentById(R.id.frag_stitchdetail); frag.onKeyDown(keyCode, event); return false; } In my class that extends Fragment (the details portion), I have: public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER &amp;&amp; event.getRepeatCount() == 0 &amp;&amp; Edited) { return true; } else return false; } I'm not sure where to put the code that will call the AlertDialog.Builder. I want to put it in the Fragment class because the code needs to get the rowID of the detail from the list (a class that extends ListFragment). That information isn't available to the FragmentActivity class. For clarification, here's the code I use to operate the Save button. It's called from the onCreateView method of the Fragment class and I want to re-use this code (put it in its own method, probably) when the back button is hit. @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.detailfragment, container, false); Typeface danielFont = Typeface.createFromAsset(getActivity().getAssets(), "danielbk.ttf"); final EditText notes = (EditText)view.findViewById(R.id.stitchnotes); notes.setTypeface(danielFont); notes.setTextSize(12); builder = new AlertDialog.Builder(getActivity()…

http://stackoverflow.com/q/21518938
tagged with: reentrancy
has title: Re-entrancy in Java saves us from a deadlock situation in this code sample.. How, why?
favorite count: 0
has body: I'm new to Java and OOP. I'm reading concurrency in java and in chapter 2, it talks about re-entrancy. I don't quite understand how a deadlock situation would occur. Can some one break this situation down for me to understand the details line by line? Thank you in advance. If intrinsic locks were not reentrant, the call to super.doSomething would never be able to acquire the lock because it would be considered already held, and the thread would permanently stall waiting for a lock it can never acquire. public class Widget { public synchronized void doSomething() { ... } } public class LoggingWidget extends Widget { public synchronized void doSomething() { System.out.println(toString() + ": calling doSomething"); super.doSomething(); } } and the thread would permanently stall waiting for a lock it can never acquire. How, why, which thread?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21519135
accepted answer: http://stackoverflow.com/a/21519135
downvote count: 0
has answer: http://stackoverflow.com/a/21519017
score: 1
tagged with: java
tagged with: multithreading
type: Question
possible better answer: http://stackoverflow.com/a/21518962
answer count: 3
has answer: http://stackoverflow.com/a/21518962
upvote count: 1

http://stackoverflow.com/comment/32719581
has text: Thanks, I will try it in a moment. ad 1) it is javax.transaction.Transactional from JPA 1.2. I tried to explicitely specify it, but it did not help.
comment on: http://stackoverflow.com/a/21648448
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32707213
score: 0
comment on: http://stackoverflow.com/q/21642032
type: Comment
type: QuestionComment
has text: Do what @SotiriosDelimanolis said...but just wanted to add that's 1.7+ only

http://stackoverflow.com/comment/32638793
comment on: http://stackoverflow.com/a/21603472
type: AnswerComment
score: 0
type: Comment
has text: Sorry for the typo just updated my code I am getting `Expression elements[element_index + 1] is undefined`

http://stackoverflow.com/comment/32620621
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21565237
has text: Thank you @Marco13, this is exactly what i was looking for. Do you know if it's also possible to find **scale** and **translate** information from given values.
score: 0

http://stackoverflow.com/q/21647501
type: Question
has comment: http://stackoverflow.com/comment/32716585
has comment: http://stackoverflow.com/comment/32717492
has comment: http://stackoverflow.com/comment/32717218
has comment: http://stackoverflow.com/comment/32717104
has comment: http://stackoverflow.com/comment/32716179
has comment: http://stackoverflow.com/comment/32717185
has title: Java Generics : How to test if a field type is a specification of a generic class
has body: I want to test if a field of type MyType&lt;int&gt; to be a field of a subtype of MyType&lt;?&gt;. If the field is of type MyType&lt;?&gt;, then I would instantiate it correctly using getActualTypeArguments of ParameterizedType. But I can't get to do the test : if( (field.getType instanceof MyType&lt;?&gt;) ) ... wont compile and get me : Incompatible conditional operand types Class&lt;capture#3-of ?&gt; and myType&lt;?&gt; The myType is a generic class that I created. The field is a field gotten from a class using reflection (instance of java.lang.reflect.Field, which expose a getType method). any one know how to ?
tagged with: types
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/32717072
has comment: http://stackoverflow.com/comment/32717019
tagged with: generics
favorite count: 0
has comment: http://stackoverflow.com/comment/32717366
has comment: http://stackoverflow.com/comment/32716751
has answer: http://stackoverflow.com/a/21648120
has comment: http://stackoverflow.com/comment/32717306
accepted answer: http://stackoverflow.com/a/21648120
type: AnsweredQuestion
tagged with: reflection
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32716382
upvote count: 1
has comment: http://stackoverflow.com/comment/32716929

http://stackoverflow.com/q/21666870
answer count: 2
tagged with: arrays
has body: I have a problem whilst trying to output a word from my array list into a text field on screen. Whenever I run the program and type a couple of words into the inbox field and click the analyse button, nothing gets outputted, any ideas? import javax.swing.*; import java.applet.*; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; import java.util.Iterator; public class SApplet extends Applet implements ActionListener { TextField input,output; Label label1; Button b1, b2; JLabel lbl; String Word1; String wordArrayList[]; public void init(){ label1 = new Label("Please enter your text: "); add(label1); label1.setBackground(Color.orange); label1.setForeground(Color.black); input = new TextField(20); add(input); output = new TextField(20); add(output); b1 = new Button("Analyze"); b2 = new Button("Reset"); add(b1); add(b2); b1.addActionListener(this); b2.addActionListener(this); setBackground(Color.orange); } public void actionPerformed(ActionEvent e){ try{ String a = null; ArrayList&lt;String&gt; wordArrayList = new ArrayList&lt;String&gt;(); if (e.getSource()== b1) { Word1 = input.getText(); for(String word : Word1.split(" ")) { wordArrayList.add(word); } Iterator&lt;String&gt; word = wordArrayList.iterator(); if (word.hasNext()) { // output.setText(word.next()); // System.out.println(word.next()); a += word.next(); } while (word.hasNext()) { a += ", " + word.next(); output.setText(a); // System.out.println(a); } } if(e.getSource() == b2) input.setText(""); output.setText(""); } catch(NumberFormatException a){ lbl.setForeground(Color.red); lbl.setText("Invalid Entry!"); } } }
tagged with: applet
has title: Array List wont output. Java Applet
score: 0
possible better answer: http://stackoverflow.com/a/21666929
tagged with: textfield
accepted answer: http://stackoverflow.com/a/21667003
type: AnsweredQuestion
tagged with: list
has answer: http://stackoverflow.com/a/21666929
tagged with: java
has answer: http://stackoverflow.com/a/21667003
type: Question

http://stackoverflow.com/comment/126682180
type: Comment
has text: I stand corrected then. I will delete my previous comment to avoid confusion.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21684876

http://stackoverflow.com/comment/32627355
score: 1
comment on: http://stackoverflow.com/q/21574566
type: Comment
type: QuestionComment
has text: If you want to forgoe server authentication (i.e., the customary X509 checks), then add a custom `X509TrustManager`, override `checkServerTrusted`, and always accept what you get during an invocation. See the Android example at OWASP's [Certificate and Public Key Pinning](https://www.owasp.org/index.php/Certificate_and_Public_Key_Pinning#Android), and **don't** do the stuff shown in `checkServerTrusted`.

http://stackoverflow.com/comment/32647076
has text: Is it possible to implement it with parametrization stuff otherwise? Thanks.
comment on: http://stackoverflow.com/q/21607469
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21665065
type: Question
has title: EL getType obj.property1.sub_property
tagged with: jsf-2
answer count: 2
score: 0
has body: I want to get the type of the sub property of the Object "obj", which is accessible as obj.property1.sub_property this code works only for direct property like obj.property FacesContext.getCurrentInstance().getApplication(). getELResolver().getType(FacesContext.getCurrentInstance().getELContext(), obj, "property1"); but how to make this work FacesContext.getCurrentInstance().getApplication(). getELResolver().getType(FacesContext.getCurrentInstance().getELContext(), obj, "property1.sub_property"); or How to get the TYPE of the complete expression #{obj.property1.sub_property}
has answer: http://stackoverflow.com/a/21680752
tagged with: el
has answer: http://stackoverflow.com/a/21667106
accepted answer: http://stackoverflow.com/a/21667106
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21680752
tagged with: java

http://stackoverflow.com/q/21668126
has answer: http://stackoverflow.com/a/21668158
accepted answer: http://stackoverflow.com/a/21668240
has title: Getting values from an array
has comment: http://stackoverflow.com/comment/32752885
type: Question
has comment: http://stackoverflow.com/comment/32752790
has answer: http://stackoverflow.com/a/21668240
tagged with: java
possible better answer: http://stackoverflow.com/a/21668158
answer count: 2
tagged with: arrays
score: 0
has comment: http://stackoverflow.com/comment/32752898
has body: So let's say I have an array called arr with the values &amp;&amp;&amp;&amp;.&amp;&amp;. I want to find the number of ampersands (&amp;) that are after the decimal point and store the value into numDecimalDigits. int numDecimalDigits = 0; char[] arr = new char[7] for (int i = 0; i &lt; str.length(); i ++) { for (int decimal = (arr[pos] = '.'); decimal &lt;= arr.length; decimal ++) { numDecimalDigits += 1; } } I'm not sure if this is the right approach. So the outside for loop runs through each index value of the array. The inner for loop starts at the decimal, and ends at the end of the array. Every time a new value is found, numDecimalDigits is added by one. However, in my code I think numDecimalDigits is returning an incorrect value.
has comment: http://stackoverflow.com/comment/32752881
type: AnsweredQuestion

http://stackoverflow.com/q/21664727
score: 0
has comment: http://stackoverflow.com/comment/32746809
answer count: 1
has title: Exception in thread "main" java.lang.Error: unresolved variable
favorite count: 0
has answer: http://stackoverflow.com/a/21664891
has comment: http://stackoverflow.com/comment/32746802
tagged with: linkageerror
type: AnsweredQuestion
tagged with: compiler-errors
tagged with: java
tagged with: error-handling
upvote count: 1
tagged with: methods
downvote count: 1
type: Question
accepted answer: http://stackoverflow.com/a/21664891
has comment: http://stackoverflow.com/comment/32746699
has body: Exception in thread "main" java.lang.Error: Why can't my parameter variable be resolved to a variable? I'm trying to create a simple program that creates two objects of the people class, give them names and make the first object ("lisa") be-friend the second object ("mark") and finally display/print out lisa's friend on screen. But Eclipse displays the following error: Exception in thread "main" java.lang.Error: Unresolved compilation problems: lisa cannot be resolved to a variable mark cannot be resolved to a variable lisa cannot be resolved to a variable Syntax error, insert ";" to complete Statement The method friend() is undefined for the type People at People.main(People.java:22) As you can tell, I'm very new to Java, so I cannot understand what the error means and how I can fix it. Your help is greatly appreciated! Here is my People class: public class People { //Constructor public void name(String name) { this.name = name; } // Instance variables public String name; public String friend; // Instance method public void addFriend(String name){ name = Object1.friend(); } Here is my main method: public static void main(String[] args) { People Object1 = new People(); Object1.name(lisa); People Object2 = new People(); Object2.name(mark); Object1.addFriend(lisa); System.out.println(Object1.friend()); } }

http://stackoverflow.com/comment/32973904
has text: Hey Rob thanks for that. After modifying the code based on your input i have located the root cause of the whole issue. Unless you specifically scan for that UserDetailsService implementation (in my case UserAccessDetails and the Autowired repositories within UserAccessDetails.java) you end up with that injection problem. Should you really be specific class scanning just for that Config? (hope that makes sense)
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21539620

http://stackoverflow.com/comment/32724353
score: 0
type: AnswerComment
type: Comment
has text: I know ..public will be in small and i=0;...those writting mistakes
comment on: http://stackoverflow.com/a/21652050

http://stackoverflow.com/a/28133620
has comment: http://stackoverflow.com/comment/52687608
downvote count: 0
has body: Go for ConcurrentHashMap. It allows Concurrent read access without compromising on performance.
answers question: http://stackoverflow.com/q/21616234
type: Answer
upvote count: 3
score: 3

http://stackoverflow.com/q/21615718
has answer: http://stackoverflow.com/a/21616540
has comment: http://stackoverflow.com/comment/32663012
score: 2
type: AnsweredQuestion
has body: I am testing SoftReference for a cache implementation and I found a strange behaviour : I have a setName(String name) method which sets the name of a Graph object through a SoftReference : public void setName(String newName) { getData().name = new SoftReference&lt;String&gt;(newName,garbagedData); } (garbagedData is a ReferenceQueue and doesn't seem important in this particular problem). When I call graph.setName("name"); from main thread, and when à force a OutOfMemory error, the value pointed by the reference is not garbaged but if I call graph.setName(new String("name")) then it is. I look the heap contents with Eclipse Memory Analyzer and in both case there is no other reference chain than the Soft one. If anyone has an explanation for this strange behavior I am interested.
upvote count: 2
tagged with: garbage-collection
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/21616486
answer count: 2
has title: SoftReference<String> not garbage collected when out of memory
downvote count: 0
has comment: http://stackoverflow.com/comment/32662720
tagged with: soft-references
has comment: http://stackoverflow.com/comment/32664256
favorite count: 0
possible better answer: http://stackoverflow.com/a/21616540
accepted answer: http://stackoverflow.com/a/21616486

http://stackoverflow.com/comment/32718471
comment on: http://stackoverflow.com/a/21639659
type: Comment
has text: All numbers returned by java.util.Random or Math.random are pseudo-random. The crucial point is that in the first case, you can define the random seed (and thus, obtain always the same sequence of numbers), and in the lattern, you can't.
score: 1
type: AnswerComment

http://stackoverflow.com/comment/32643648
score: 0
has text: Filter out the blank rows before putting them into the JComboBox.
comment on: http://stackoverflow.com/q/21605985
type: QuestionComment
type: Comment

http://stackoverflow.com/q/21533368
score: 0
downvote count: 2
tagged with: singleton
has comment: http://stackoverflow.com/comment/32515577
has body: Is there a singleton design which can completely prevent the creation of more than one object? Asking this question keeping in mind that, in Java, we can recreate 'singleton objects' using serialization-deserialization and reflection.
linked to: http://stackoverflow.com/q/70689
favorite count: 0
type: UnansweredQuestion
tagged with: design-patterns
has answer: http://stackoverflow.com/a/21533619
has answer: http://stackoverflow.com/a/21533503
linked to: http://stackoverflow.com/q/21033112
has answer: http://stackoverflow.com/a/21533512
tagged with: reflection
tagged with: java
has title: Can we design a truly singleton class in java?
has comment: http://stackoverflow.com/comment/32515829
duplicate of: http://stackoverflow.com/q/70689
type: Question
has answer: http://stackoverflow.com/a/21533519
answer count: 6
has answer: http://stackoverflow.com/a/21533469
linked to: http://stackoverflow.com/q/20940715
has answer: http://stackoverflow.com/a/21533464
upvote count: 2

http://stackoverflow.com/q/21674111
has comment: http://stackoverflow.com/comment/32762640
has comment: http://stackoverflow.com/comment/32763438
linked to: http://stackoverflow.com/q/10305176
has comment: http://stackoverflow.com/comment/32763754
tagged with: java
has comment: http://stackoverflow.com/comment/42489278
has comment: http://stackoverflow.com/comment/32763927
upvote count: 2
answer count: 2
has comment: http://stackoverflow.com/comment/32763418
has comment: http://stackoverflow.com/comment/32764447
favorite count: 0
has comment: http://stackoverflow.com/comment/32763406
type: UnansweredQuestion
tagged with: android
has answer: http://stackoverflow.com/a/21674811
linked to: http://stackoverflow.com/q/5101739
has comment: http://stackoverflow.com/comment/32762465
has comment: http://stackoverflow.com/comment/32764013
has body: I have a listview that i added an header, but i don't want the listview background to come around the header. Like they are two different views (I don't want to put the listview inside the scrollview) The listview : <com.example.tuto.customs.CustomHoverView android:id="@+id/chv_activity_list_with_header" android:layout_width="fill_parent" android:layout_height="fill_parent" > </com.example.tuto.customs.CustomHoverView> The header : <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Header" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:adjustViewBounds="true" android:src="@drawable/ic_launcher" /> BaseAdapter class:- private class MyAdapter extends BaseAdapter{ private LayoutInflater inflater; private List<String> strings; public MyAdapter(Context context, List<String> strings) { inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); this.strings = strings; } @Override public int getCount() { // TODO Auto-generated method stub return strings.size(); } @Override public Object getItem(int position) { // TODO Auto-generated method stub return strings.get(position); } @Override public long getItemId(int position) { // TODO Auto-generated method stub return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub View v = convertView; ViewHolder h; if(v == null){ v = inflater.inflate(R.layout.adapter_strings, null); h = new ViewHolder(); h.tv = (TextView) v.findViewById(R.id.tv_adapter_strings); v.setTag(h); }else{ h = (ViewHolder) v.getTag(); } if(position == 0){ // here it changes the first item, but not the header v.setBackgroundColor(Color.RED); } h.tv.setText(""+getItem(position)); return v; } private class ViewHolder{ TextView tv; } } The adapter : <TextView android:id="@+id/tv_adapter_strings" android:layout_width="wrap_content" android:layout_height="wrap_content" />
score: 2
linked to: http://stackoverflow.com/q/16812191
downvote count: 0
has title: Remove the header's background in listview
has answer: http://stackoverflow.com/a/21674161
type: Question
has comment: http://stackoverflow.com/comment/32762549

http://stackoverflow.com/comment/32740277
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21660888
type: AnswerComment
has text: yes. I have spring tools suite. It's has all I need

http://stackoverflow.com/comment/32675954
has text: Have a look [http://stackoverflow.com/questions/3337056/convenient-way-to-parse-incoming-multipart-form-data-parameters-in-a-servlet](http://stackoverflow.com/questions/3337056/convenient-way-to-parse-incoming-multipart-form-data-parameters-in-a-servlet)
score: 0
comment on: http://stackoverflow.com/q/21615714
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32652860
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21609224
has text: Ah sorry i meant the code for SAXXMLParser, the bug lies in these 2 lines `InputStream stream = new ByteArrayInputStream(xml.getBytes()); videos = SAXXMLParser.parse(stream);` and im guessing its the second one that causes it so something is going wrong in your parser

http://stackoverflow.com/a/21677305
score: 3
answers question: http://stackoverflow.com/q/21676920
downvote count: 0
has body: Currently your JTable is locally scoped in the Journal constructor, so it can't be accessed from anywhere else. What you want to do is declare it as a class-member and have a getter for it. public class Journal extends JPanel { private JTable table; public Journal() { table = new JTable(...); } public JTable getTable() { return table; } } Now the table can be accessed and retrieved from the Main class using the getTable(). Also you'll want to use a TableModel to update data dynamically. Yo can use a simple, already implemented DefaultTableModel. You want to set this model to the JTable. Something like this public Journal() { ... DefaultTableModel model = new DefaultTableModel(data, columns); table = new JTable(model); } So you have everything set in for your Main class. In your actionPerfomed you can do something like this private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { String data1 = textField1.getText(); String data2 = textField2.getText(); JTable table = journal.getTable(); DefaultTableMode model = (DefaultTableModel)table.getModel(); model.addRow( new Object[] { data1, data2 } ); } Side Notes You don't need two main methods, as I assume the Main class already has a main method. Also take a look at The Use of Multiple JFrames, Good/Bad Practice?. It looks like your Journal class use a JFrame in its main method, and I assume your Main class is a JFrame also. What you can do is just make Journal a JDialog and add the JTable to it.
type: Answer
upvote count: 3

http://stackoverflow.com/comment/32594761
score: 0
type: Comment
has text: See my **EDIT** if you want to change the icon of a different label, and not the button.
type: AnswerComment
comment on: http://stackoverflow.com/a/21577658

http://stackoverflow.com/a/21538664
has comment: http://stackoverflow.com/comment/57725082
has comment: http://stackoverflow.com/comment/57640634
answers question: http://stackoverflow.com/q/21537148
type: Answer
score: 10
upvote count: 10
has body: In Scala you can create a Enumeration structure which is close to "enum" from Java. Basically, what you need to do is just to extend a scala.Enumeration class and to extend a Val class if you need a more complicated class as a enum. Otherwise, you can use default Val class which takes Int or String or Both. Below, is a Scala version of your Java code. object Status extends Enumeration { case class StatusVal(code: Int, name: String, description: String) extends Val val OK = StatusVal(1, "Ok", "Okay") val NOT_OK = StatusVal(1, "Not Ok", "Not Okay") val BAD = StatusVal(1, "Bad", "Run for your life") } object Application extends App { Status.values foreach (s =&gt; println(s.asInstanceOf[StatusVal].description)) }
downvote count: 0

http://stackoverflow.com/comment/32765926
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/21675410
type: Comment
has text: Hard to tell. Might be a parser bug.

http://stackoverflow.com/a/21706249
answers question: http://stackoverflow.com/q/21658547
type: Answer
score: 0
has body: The issue is resolved automatically. It might be some bug of eclipse, b'cox when I started the eclipse another day, my project work fine. Even i didn't made any changes.

http://stackoverflow.com/comment/32650401
type: Comment
comment on: http://stackoverflow.com/a/21607691
score: 0
has text: You should be able to figure that out by reading the Javadoc. I don't actually have experience with Joda-Time myself, but a quick glance seems to indicate that something like this should work: `LocalTime start = LocalTime.parse("12:00"); LocalTime finish = LocalTime.parse("14:00"); long difference = finish.getMillisOfDay() - start.getMillisOfDay();` I would keep the value as a long as much as possible, especially to do calculations with. To format it as a string, look at the `Duration` and `PeriodFormatter/PeriodFormatterBuilder` classes.
type: AnswerComment

http://stackoverflow.com/q/21626335
favorite count: 0
accepted answer: http://stackoverflow.com/a/21629921
has comment: http://stackoverflow.com/comment/32678788
tagged with: rest
type: Question
has comment: http://stackoverflow.com/comment/32680706
tagged with: owasp
upvote count: 3
tagged with: java
answer count: 1
tagged with: csrf
has title: Is it safe to include a CSRF token for a REST service as a Http Response Header?
has answer: http://stackoverflow.com/a/21629921
type: AnsweredQuestion
score: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/32680428
tagged with: spring-security
has body: I have a set of REST services that are protected by CSRF using something similar to OWASP's Synchronizer Token Pattern (https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet). * REST is implemented using Java and JAX-RS * Security is implemented using Spring Security CSRF tokens * HTTP PUT, POST, and DELETE are protected At my Web-App startup, I write the correct CSRF token in the HTML page and then the application includes the token as "X-CSRF-HEADER" in the Request Headers for every single request. I also have clients that access the URLs directly (curl command-line and others for example). The alternate clients need to get the CSRF token somehow (after authenticating of course). Is it safe to include the token as an HTTP Response Header for GET requests? If so, then I could include it in the Response Header and a client could read it out and include it in future Request Headers. Is that safe?

mongodb
tags question: http://stackoverflow.com/q/21577413
tags question: http://stackoverflow.com/q/21579683
tags question: http://stackoverflow.com/q/21675723
tags question: http://stackoverflow.com/q/21533301
tags question: http://stackoverflow.com/q/21613009
tags question: http://stackoverflow.com/q/21608888
tags question: http://stackoverflow.com/q/21625431
tags question: http://stackoverflow.com/q/21529219
tag name: mongodb
tags question: http://stackoverflow.com/q/21554271
tags question: http://stackoverflow.com/q/21527016
type: Tag
tags question: http://stackoverflow.com/q/21522198
tags question: http://stackoverflow.com/q/21588871
tags question: http://stackoverflow.com/q/21590367
tags question: http://stackoverflow.com/q/21607975
tags question: http://stackoverflow.com/q/21672612
tags question: http://stackoverflow.com/q/21580147
tags question: http://stackoverflow.com/q/21629500
tags question: http://stackoverflow.com/q/21528455
tags question: http://stackoverflow.com/q/21568542
tags question: http://stackoverflow.com/q/21599514
tags question: http://stackoverflow.com/q/21649566
tags question: http://stackoverflow.com/q/21571367
tags question: http://stackoverflow.com/q/21553493

http://stackoverflow.com/a/21562819
type: Answer
score: 2
upvote count: 2
has body: What the term "interface" means (and what the therm "Object" means) depends on the programming paradigm you are refferring. Java embrace totally the classic OOP paradigm, based on inheritance of a base and some interfaces. C++, by converse, can support "mutiple inheritance" that is a more general concept. An "interface", in this context can be seen as a class with only pure virtual methods; class Ia { public: virtual int method1()=0; virtual int method2()=0; virtual ~Ia() {} }; class Ib { public: vritual int method3()=0; vritual int method4()=0; virtual ~Ib() {} }; class Object { public: virtual ~Object() {} }; class A: public Object, public Ia, { public: virtual int method1(); //implementation virtual int method2(); //implementation }; class B: public A, public Ib { public: virtual int method3(); //implementation virtual int method4(); //implementation }; It should be easy in this sense to recognize your case
downvote count: 0
answers question: http://stackoverflow.com/q/21562664
has comment: http://stackoverflow.com/comment/32567929

http://stackoverflow.com/q/21600099
type: Question
accepted answer: http://stackoverflow.com/a/21600204
score: 0
has comment: http://stackoverflow.com/comment/32633335
answer count: 1
tagged with: arrays
has comment: http://stackoverflow.com/comment/32633377
has comment: http://stackoverflow.com/comment/32633134
has answer: http://stackoverflow.com/a/21600204
has body: I have a problem: I cannot check whenever to elements in two array A and B are the same... why does this not work? It is this part of my program the problem lies, and in the if(A.get(j)==B.get(i)), is there something about arrays i don't know about. for(int i=0; i&lt;n; i++){ if(B.get(i) != A.get(i)){ for(int j=0; j&lt;n; j++){ if(A.get(j)==B.get(i)){ Collections.swap(B, j, i); System.out.println("Swapping "+i+" with "+j+" : "+B); count++; } } } } The hole program is... import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Opgave4Uge6 { private static Scanner s; public static void main(String arg[]){ int n = s.nextInt(); long time = System.currentTimeMillis(); ArrayList&lt;Integer&gt; A = new ArrayList&lt;&gt;(); for(int a=0; a&lt;n ;a++){ A.add(new Integer(a)); } System.out.println("The solution"); System.out.println(A); ArrayList&lt;Integer&gt; B = new ArrayList&lt;&gt;(); for(int b=0; b&lt;n ;b++){ B.add(new Integer(b)); } Collections.shuffle(B); System.out.println("The random list"); System.out.println(B); int count = 0; for(int i=0; i&lt;n; i++){ if(B.get(i) != A.get(i)){ for(int j=0; j&lt;n; j++){ if(A.get(j)==B.get(i)){ Collections.swap(B, j, i); System.out.println("Swapping "+i+" with "+j+" : "+B); count++; } } } } System.out.println(B+" Solved!"); System.out.println("Number of moves "+count); int k = n-count; System.out.println("Number of cycles "+k); long newtime = System.currentTimeMillis()-time; System.out.println("Time "+newtime+" ms"); } } BTW: I am using Netbeans.
type: AnsweredQuestion
tagged with: java
has title: Solving a puzzle, array programming, java

http://stackoverflow.com/a/21518238
upvote count: 5
answers question: http://stackoverflow.com/q/21518208
score: 5
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21518208
type: Answer
has body: A list has to be maintained somewhere, otherwise those inner class instances will be garbage-collected. Whether that's in an array that is a member of Bicycle or in some external data structure is a design decision, but there's no automatic list kept by Java of inner class instances.

http://stackoverflow.com/comment/32761606
comment on: http://stackoverflow.com/a/21672824
score: 0
has text: @aNish, yes it doesn't handle those cases. I added a suggestion to my answer. This will add an empty entry in the resulting array.
type: AnswerComment
type: Comment

http://stackoverflow.com/q/21522223
answer count: 2
has answer: http://stackoverflow.com/a/21522866
upvote count: 1
has comment: http://stackoverflow.com/comment/32495439
favorite count: 0
score: 0
downvote count: 1
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32495983
possible better answer: http://stackoverflow.com/a/21522866
has title: Make one json object a child of the other using java
has body: I'm working out a problem, and this part of it I could use some assistance on, I have the following JSON array: parentArray: [{"name":"folder1","children":[],"parent":"root","type":"folder"}, {"name":"folder2","children":[],"parent":"folder1","type":"folder"}] I need to create a method that will put the put the object with name 'folder2' in to the 'children' array of 'folder1'. Thanks for any help or pointers.
type: Question
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has answer: http://stackoverflow.com/a/21522654
accepted answer: http://stackoverflow.com/a/21522654

http://stackoverflow.com/comment/32534373
score: 0
comment on: http://stackoverflow.com/q/21543089
type: QuestionComment
type: Comment
has text: @SotiriosDelimanolis: Hi, it is a Big JSON file. It is a JSON Array.

http://stackoverflow.com/comment/32616244
type: Comment
has text: The com.mongodb.MongoException.DuplicateKey is unavoidable if the dbObj you are writing violates some unique key constraint. That is just now the Mongo driver works. We are always WriteConcern.SAFE here.
comment on: http://stackoverflow.com/q/21588871
score: 0
type: QuestionComment

http://stackoverflow.com/comment/32566897
comment on: http://stackoverflow.com/a/21558705
type: Comment
has text: @CodeDCode so what you want
score: 0
type: AnswerComment

http://stackoverflow.com/a/21585974
has body: In this section: a=b; b=a+b; you're assigning b to a+b, but a is already b. So really you're doubling b Easiest solution is a temp variable: public static int fib2(int n){ int a = 0; int b =1; while(n-- &gt;0){ int old_a; old_a = a; a=b; b=old_a+b; } return a; } In python, a, b = b, a + b stores an intermediate tuple automatically before assigning the new values to the variables, while in Java you need to be explicit about it Breaking down Python's instructions, a, b = b, a + b is executing this disassembly: 5 17 LOAD_FAST 1 (b) 20 LOAD_FAST 0 (a) 23 LOAD_FAST 1 (b) 26 BINARY_ADD 27 ROT_TWO 28 STORE_FAST 0 (a) 31 STORE_FAST 1 (b) In a simpler sense, staying python, here's the process: temp_tuple = (b, a + b) a, b = temp_tuple
type: Answer
has comment: http://stackoverflow.com/comment/32613302
has comment: http://stackoverflow.com/comment/32631231
has comment: http://stackoverflow.com/comment/32618171
has comment: http://stackoverflow.com/comment/32613215
has comment: http://stackoverflow.com/comment/32619932
has comment: http://stackoverflow.com/comment/32609220
has comment: http://stackoverflow.com/comment/32609376
has comment: http://stackoverflow.com/comment/32609031
score: 27
accepted answer of: http://stackoverflow.com/q/21585932
upvote count: 27
answers question: http://stackoverflow.com/q/21585932
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32613383
has comment: http://stackoverflow.com/comment/32611006

http://stackoverflow.com/comment/32812738
type: Comment
comment on: http://stackoverflow.com/a/21678850
score: 0
type: AnswerComment
has text: This returns another error it seems opencv is not in java.library.path, how I do get it there?

http://stackoverflow.com/a/21586781
answers question: http://stackoverflow.com/q/21583875
has comment: http://stackoverflow.com/comment/44136073
upvote count: 3
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/38200469
score: 3
type: Answer
accepted answer of: http://stackoverflow.com/q/21583875
has comment: http://stackoverflow.com/comment/44117113
has body: Your posted layout won't work because your inner linear layout has a height of wrap_content (thereby causing its children's layout_weights to be ignored) but the web view has a height of 0. You also gave your ad view a weight of 1, as if it should grab as much space as possible, when normally an ad should have a fixed height. I'm not sure why RelativeLayout didn't work for you, but maybe you were trying to use it with layout_weight? If so, note that layout_weight only applies to the children of a LinearLayout. Here is how I would do it: <com.google.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentTop="false" android:layout_centerHorizontal="true" ads:adSize="BANNER" ads:adUnitId="ca-app-pub-7041222655570180/1503313077" ads:loadAdOnCreate="true" ads:refreshInterval="30" > </com.google.ads.AdView> <ProgressBar android:id="@+id/ProgressBar" style="?android:attr/progressBarStyleHorizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:indeterminate="false" android:progress="50" android:progressDrawable="@drawable/greenprogress" /> <WebView android:id="@+id/webview" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" />

http://stackoverflow.com/comment/32498080
score: 0
type: Comment
type: QuestionComment
has text: The redirection to co.in is done by UI,thr is no any issue with code
comment on: http://stackoverflow.com/q/21523824

http://stackoverflow.com/q/21604032
type: AnsweredQuestion
score: 2
has answer: http://stackoverflow.com/a/21604784
upvote count: 2
tagged with: java
tagged with: rowsorter
type: Question
has body: I'm currently getting the value of my jTable as everybody does: String d = jTable1.getModel().getValueAt( jTable1.getSelectedRow() , row ).toString(); The thing is that now I'm sorting my jTable with a rowsorter: sorter = new TableRowSorter&lt;TableModel&gt;(modelo); jTable1.setRowSorter(sorter); private void filterTable(){ //If current expression doesn't parse, don't update. try { rf = RowFilter.regexFilter("(?iu)"+jFilter.getText(),0,1,2,3,4);//no filtrar la columna con imágenes porque hace cualquiera } catch (java.util.regex.PatternSyntaxException e) { return; } sorter.setRowFilter(rf); } THE PROBLEM: Once the table is filtered, the function getSelectedRow returns the correct row, but the getModel function returns the original model, not the one after filtering... THE QUESTION: How to get the correct value from the table when it is filtered?
accepted answer: http://stackoverflow.com/a/21604784
tagged with: jtable
answer count: 2
has title: Getting true selected value of JTable
downvote count: 0
possible better answer: http://stackoverflow.com/a/21604306
favorite count: 0
has answer: http://stackoverflow.com/a/21604306
tagged with: swing

http://stackoverflow.com/comment/32724611
comment on: http://stackoverflow.com/q/21651671
has text: OK, see also here: http://www.toadworld.com/products/toad-extension-for-eclipse/f/42/t/20417.aspx They just say directly 5.6 is not yet fully tested or supported. But this is from Oct 2013. I guess you should open a bug with MySQL and see what they say.
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/q/21654777
has comment: http://stackoverflow.com/comment/32729221
tagged with: java
upvote count: 1
tagged with: swing
answer count: 1
has comment: http://stackoverflow.com/comment/32730475
has title: Move JPanel in JFrame
tagged with: jpanel
type: UnansweredQuestion
tagged with: move
has body: I'm looking to move a jpanel inside of a JFrame, and it won't seem to budge. I can set it's location in the paint() method, but it won't update in repaint. Please help! Here is my code: public void paint(Graphics g) { g.drawImage(playerImg, x, 50, null); this.setLocation(x, 50); } public void update() { this.repaint(); } public void keyPressed(KeyEvent key) { if(key.getKeyCode() == KeyEvent.VK_UP) { x = x + 50; System.out.println("e"); update(); } }
downvote count: 0
score: 1
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/21654805

http://stackoverflow.com/a/21644785
has comment: http://stackoverflow.com/comment/32711638
accepted answer of: http://stackoverflow.com/q/21644593
has comment: http://stackoverflow.com/comment/32719842
answers question: http://stackoverflow.com/q/21644593
has comment: http://stackoverflow.com/comment/32711691
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32711785
type: Answer
has body: Answer depends on the scale of your app. If you have only one server with enough memory to hold sessions for all your concurrent users Storing info in the session is the easiest thing to do. Make sure that your graph is serializable and Servlet (or J2EE) container will take of the rest. You can help with httpsession persistence if you implement some custom algo for your data. If you grew big That is if you have more than one server with a load balancer in front or your graphs do not fit in memory. Store them in some shared storage - either DB or a filer and retrieve by some key lookup. Consider using sticky sessions to minimize DB/file lookups and cache recent graphs in memory Fancy trick If you find a way to compress your whole graph into 1-2KB put it entirely into http cookie, browser will send it back to you on every request, your server will be stateless, no DB, no session affinity issue.
downvote count: 0
score: 1

http://stackoverflow.com/a/21595066
accepted answer of: http://stackoverflow.com/q/21579971
answers question: http://stackoverflow.com/q/21579971
score: 0
has body: There should be some limit set on user / group / system level. Can you check if there is any limit set? \du USERNAME -- To check user settings \dg GROUPNAME - To check group setting show system default rowsetlimit -- To check system setting
type: AcceptedAnswer
type: Answer

http://stackoverflow.com/q/21568102
has title: Java.lang.NullPointerException error in Java program
tagged with: methods
type: Question
linked to: http://stackoverflow.com/q/218384
tagged with: null
duplicate of: http://stackoverflow.com/q/218384
possible better answer: http://stackoverflow.com/a/21568172
has answer: http://stackoverflow.com/a/21568172
answer count: 2
has body: Keep getting this error, sorry I am a beginner in Java. Exception in thread "main": java.lang.NullPointerException at assignment01.Student.addGrade(Student.java:28) at assignment01.GpaTest.main(GpaTest.java:11) package assignment01; public class Grades { private double qualPts; private int numCred; public double getGPA() { if(numCred!=0) { return(qualPts/numCred); } return numCred; } public void addGrade(int creds, double grade) { grade+=creds+numCred; qualPts+=creds*grade; } public int getNumCred() { return numCred; } } . package assignment01; public class Student { private String name; private String bNumber; private Grades grades; public Student(String name, String bNumber) { this.name=name; this.bNumber=bNumber; } public void addGrade(int creds, double grade) { grades.addGrade(creds, grade); } . package assignment01; public class GpaTest { public static void main(String[] args) { Student theStudent= new Student("Ethan","00000000"); int CREDITS_ENROLLED1=4; double GRADE1=90; theStudent.addGrade(1, 100); theStudent.addGrade(CREDITS_ENROLLED1,GRADE1); System.out.println("Determining the grades of student named Ethan."); System.out.println("Ethan has a grade of 90."); } }
upvote count: 0
has answer: http://stackoverflow.com/a/21568157
tagged with: pointers
favorite count: 0
score: -2
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32577575
accepted answer: http://stackoverflow.com/a/21568157
tagged with: java
downvote count: 2

http://stackoverflow.com/a/21591599
type: Answer
downvote count: 0
score: 1
has body: Constructors are not inherited, so subclasses of AnAbstractClass won't necessarily have a two-argument constructor. If a subclass does have a two-argument constructor, there is nothing stopping you from creating an instance of that subclass using the two-argument constructor and returning it: public abstract class AnAbstractClass { public AnAbstractClass(String foo, String bar) { System.out.format("created with (%s, %s)\n", foo, bar); } } public class BaseClass extends AnAbstractClass { public BaseClass(String foo, String bar) { super(foo, bar); } } public interface I { public AnAbstractClass k(); } public class Implementation implements I { @Override public AnAbstractClass k() { return new BaseClass("hello", "world"); } } public class Demo { public static void main(String[] args) { I i = new Implementation(); AnAbstractClass a = i.k(); } }
accepted answer of: http://stackoverflow.com/q/21591398
upvote count: 1
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21591398

http://stackoverflow.com/comment/32536618
comment on: http://stackoverflow.com/q/21545170
has text: alternate is the image @rajshree
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21671627
type: Question
has answer: http://stackoverflow.com/a/21671868
has title: Property 'dataSource' is required Error in java (Spring)
has comment: http://stackoverflow.com/comment/32758617
answer count: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/32758367
favorite count: 0
has body: I am developing an web application in Java (Spring) My java file is as, try { JdbcTemplate jt = new JdbcTemplate(dataSource); System.out.println("Connection ....."+jt.toString()); Connection conn; Statement st; conn =DriverManager.getConnection(jt.toString()); conn = (Connection) jt.getDataSource(); st=conn.createStatement(); System.out.println("Connection created....."+st); } catch (Exception e) { System.out.println("Error Found...."+ e.getMessage()); System.out.println("Strack Trace....."+e.getStackTrace()); } My spring-servlet.xml file is as, But it gets an error as, Error Found: Property 'dataSource' is required. Strack Trace: [Ljava.lang.StackTraceElement;@7948dd Here, I want to make a connection in Java file and pass it to the another variable as Jasper Report. Please help, How to fix this issue?
upvote count: 2
tagged with: spring
score: 2
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21671705
has answer: http://stackoverflow.com/a/21679282
has answer: http://stackoverflow.com/a/21671705
tagged with: java
tagged with: datasource
accepted answer: http://stackoverflow.com/a/21679282

http://stackoverflow.com/a/21585982
has body: Sounds like a job for an InputVerifier: http://docs.oracle.com/javase/7/docs/api/javax/swing/InputVerifier.html
answers question: http://stackoverflow.com/q/21585941
type: Answer
has comment: http://stackoverflow.com/comment/32609477
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/32609691
upvote count: 2

http://stackoverflow.com/comment/32546703
comment on: http://stackoverflow.com/a/21551644
type: Comment
has text: Wow, that was pretty simple! I feel like a proper knob. Thanks! I will accept your answer as soon as stack allows me to(7 mins). How would I add this to a JTable btw?
type: AnswerComment
score: 0

http://stackoverflow.com/q/21612415
answer count: 3
downvote count: 1
possible better answer: http://stackoverflow.com/a/21612521
tagged with: arraylist
type: AnsweredQuestion
score: 2
has answer: http://stackoverflow.com/a/21612497
has title: Retrieving value from key/value in ArrayList HashMap<String, String>
favorite count: 0
has body: I have stored some values to an ArrayList HashMap like so: ArrayList&lt;HashMap&lt;String, String&gt;&gt; bookDetails = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); map.put("book_author", bookAuthor); map.put("book_description", bookDescription); bookDetails.add(map); I simply want to be able to retreive the description value and have it displayed in a TextView, how would I go about doing so? Thanks in advance.
type: Question
tagged with: android
has answer: http://stackoverflow.com/a/21612548
has answer: http://stackoverflow.com/a/21612521
accepted answer: http://stackoverflow.com/a/21612497
upvote count: 3
tagged with: java

memory-management
tags question: http://stackoverflow.com/q/21595929
tags question: http://stackoverflow.com/q/21536413
tags question: http://stackoverflow.com/q/21667362
tags question: http://stackoverflow.com/q/21554848
tags question: http://stackoverflow.com/q/21521149
tags question: http://stackoverflow.com/q/21601306
tags question: http://stackoverflow.com/q/21589971
type: Tag
tags question: http://stackoverflow.com/q/21647394
tags question: http://stackoverflow.com/q/21596670
tags question: http://stackoverflow.com/q/21522882
tags question: http://stackoverflow.com/q/21648822
tags question: http://stackoverflow.com/q/21597840
tag name: memory-management

http://stackoverflow.com/a/21636756
has comment: http://stackoverflow.com/comment/32697854
has body: You have written an infinite loop: 600851475143L is greater than the maximum value that can be stored in an int, so i &lt;= x will always be true. Changing i and all the other relevant variables to long may solve this issue, but you'll still have to rethink your algorithm. Checking if 600851475143 numbers are prime is just going to take too long. Hint: once you have found a number that divides x, you can divide x by that number... (Hope this doesn't spoil the fun)
score: 3
accepted answer of: http://stackoverflow.com/q/21636647
has comment: http://stackoverflow.com/comment/32697892
answers question: http://stackoverflow.com/q/21636647
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32710585
type: Answer
upvote count: 3

http://stackoverflow.com/comment/32678077
has text: @APD - you are passing those values to the super class.. you have to keep them somewhere (in the child class ) to pass right?
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21625868
type: Comment

http://stackoverflow.com/q/21551456
type: Question
score: 0
answer count: 2
has body: My application was working with a SimpleDateFormat bug. There was specified only 3y rather than 4 but it was generating a correct output with 4 digits. I don't know why from yesterday it started generating 2 digits only. I mean '14' instead of '2014'. I solved the problem just correcting the wrong format but I'm still wondering why it changed behavior. Any ideas about it? Thanks
has answer: http://stackoverflow.com/a/21552129
has comment: http://stackoverflow.com/comment/32546345
accepted answer: http://stackoverflow.com/a/21557595
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21552129
has title: SimpleDateFormat("ddMMyyyHHmm") with only 3y
has answer: http://stackoverflow.com/a/21557595
tagged with: simpledateformat
tagged with: java
has comment: http://stackoverflow.com/comment/32546322

http://stackoverflow.com/q/21518851
tagged with: spring-ws
score: 1
tagged with: java
answer count: 2
upvote count: 1
has body: In spring-ws reference documentation, they say that it uses a contract-first approach (i.e. WSDL comes first), and that spring-ws even doesn't support a contract-last approach. But then, in the first example (page 15), a Java class is created, annotated with @Endpoint, and the WSDL is generated afterwards. So, isn't it contract-last approach?
favorite count: 0
has title: spring-ws and contract-first approach
downvote count: 0
has answer: http://stackoverflow.com/a/29929688
type: UnansweredQuestion
tagged with: web-services
type: Question
has answer: http://stackoverflow.com/a/21829798

http://stackoverflow.com/q/21669094
has answer: http://stackoverflow.com/a/21669203
has body: I am trying to make a Hibernate Criteria query to get the count of rows from a table that match a certain criteria. Something like SELECT COUNT(*) FROM MyTable WHERE field1 = &lt;numVal&gt; and field2 = 'strVal2' Here is my criteria code public static int getTransactionCount(Session session, int parentID) { Criteria criteria = session.createCriteria(MyTable.class); return (Integer) criteria.add(Restrictions.eq("parentID", parentID)) .add(Restrictions.eq("txnType", TransactionType.SOME_TYPE)) .setProjection(Projections.count("txnID")).uniqueResult(); } I get Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer at com.mydomain.MyClass.getTransactionCount(MyClass.java:123) Is there something wrong with my criteria code or should I always expect a long from getting a count?
has answer: http://stackoverflow.com/a/21669140
favorite count: 0
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
tagged with: hibernate
tagged with: hibernate-criteria
type: Question
has title: Does Projections.count("fieldName") always yield a Long?
accepted answer: http://stackoverflow.com/a/21669140
answer count: 2
possible better answer: http://stackoverflow.com/a/21669203
upvote count: 1

http://stackoverflow.com/comment/32601125
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21581198
has text: sounds like an out of memory error. Perhaps an increased buffer, or a [multipart](http://docstore.mik.ua/orelly/java-ent/servlet/ch04_04.htm#ch04-20158) request?

http://stackoverflow.com/comment/32566121
comment on: http://stackoverflow.com/a/21561248
score: 0
type: AnswerComment
has text: Now its not working no more. I am just going to give up with it it is depressing me.
type: Comment

http://stackoverflow.com/comment/32686928
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21628823
has text: Some dissatisfaction with my answer above made me look at this more carefully. The last bit of your regex, \\S*, is trying to match non-whitespace, but there's clearly whitespace in a stack trace. Also, since you're not compiling your regex pattern as I do, it won't match over line boundaries. Also, you're calling `sc.findInLine` which will only go line by line. And lastly, you'd need to remove the newlines from any stacktrace you find to have it print the way you want.
type: AnswerComment

http://stackoverflow.com/q/21637691
accepted answer: http://stackoverflow.com/a/30871451
has comment: http://stackoverflow.com/comment/53881438
tagged with: retrofit
answer count: 1
downvote count: 0
favorite count: 0
tagged with: android
has body: I'm working on a Flex Mobile app for Android with a native extension. I'm trying to use Retrofit in the Java code, but the Retrofit calls are failing. I have the following interface defined: public interface GitHubService { @GET("/repos/{owner}/{repo}/contributors") List&lt;Contributor&gt; contributors( @Path("owner") String owner, @Path("repo") String repo ); } Then I have an AsyncTask invoked from the appropriate point in my Java code. Its doInBackground method looks like this: @Override protected String doInBackground(String... arg0) { Gson gson = new GsonBuilder() .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .registerTypeAdapter(Date.class, new DateTypeAdapter()) .create(); RestAdapter restAdapter = new RestAdapter.Builder().setServer("https://api.github.com") .setConverter(new GsonConverter(gson)) .build(); GitHubService service = restAdapter.create(GitHubService.class); List&lt;Contributor&gt; contributors = service.contributors("square", "okhttp"); for (Contributor contributor : contributors) { Log.d("FooTask", contributor.login + " - " + contributor.contributions); } return null; } From all this, I'm expecting to see a list printed in LogCat; instead I get the following exception: FATAL EXCEPTION: AsyncTask #1 java.lang.RuntimeException: An error occured while executing doInBackground() ... Caused by: java.lang.IllegalStateException: No Retrofit annotation found on parameter 1 of contributors Is there a way to make Retrofit work inside a native extension with Flex Mobile?
has comment: http://stackoverflow.com/comment/37452089
has answer: http://stackoverflow.com/a/30871451
type: AnsweredQuestion
has title: Using Retrofit with a Flex Mobile app
score: 1
tagged with: java
tagged with: apache-flex
upvote count: 1
tagged with: air-native-extension
has comment: http://stackoverflow.com/comment/37443076
type: Question

http://stackoverflow.com/comment/32667799
has text: Do you want to get the `shift` given a radix?
score: 0
type: Comment
comment on: http://stackoverflow.com/q/21619438
type: QuestionComment

jtable
tags question: http://stackoverflow.com/q/21523753
tags question: http://stackoverflow.com/q/21585851
tags question: http://stackoverflow.com/q/21542479
tags question: http://stackoverflow.com/q/21608328
tags question: http://stackoverflow.com/q/21604032
type: Tag
tags question: http://stackoverflow.com/q/21551545
tags question: http://stackoverflow.com/q/21644142
tags question: http://stackoverflow.com/q/21654957
tags question: http://stackoverflow.com/q/21639873
tags question: http://stackoverflow.com/q/21669380
tags question: http://stackoverflow.com/q/21611142
tag name: jtable
tags question: http://stackoverflow.com/q/21672049
tags question: http://stackoverflow.com/q/21661055
tags question: http://stackoverflow.com/q/21659357
tags question: http://stackoverflow.com/q/21675908
tags question: http://stackoverflow.com/q/21521701
tags question: http://stackoverflow.com/q/21524447
tags question: http://stackoverflow.com/q/21518521
tags question: http://stackoverflow.com/q/21579782
tags question: http://stackoverflow.com/q/21623340
tags question: http://stackoverflow.com/q/21610712
tags question: http://stackoverflow.com/q/21644621
tags question: http://stackoverflow.com/q/21534958
tags question: http://stackoverflow.com/q/21524191
tags question: http://stackoverflow.com/q/21585604
tags question: http://stackoverflow.com/q/21554530
tags question: http://stackoverflow.com/q/21676920
tags question: http://stackoverflow.com/q/21589073

http://stackoverflow.com/q/21538789
tagged with: draw
type: Question
tagged with: jpanel
has title: How to change locations of drawn objects with user input
score: 0
has body: I'm attempting to draw multiple fish (very simple ones), as many as the user specifies. But the circles aren't drawn in the proper places when the user specifies they want more than one fish to be drawn. All ovals are drawn, they just aren't in the right spots, so they no longer look like fish. public class FishList extends JPanel { static int fn = Integer.parseInt(JOptionPane.showInputDialog(null, "How many fish would you like to draw? ")); static int w = 200; static int h = 100; static int x; static int y; static int a = x + 20; static int b = y + 30; static int d = 50; static int c = x + 195; public FishList() { setPreferredSize( new Dimension(400,400)); } public void paint(Graphics g) { g.setColor(Color.GREEN); g.fillOval(x, y, w, h); g.fillOval(c, y, d, h); g.setColor(Color.BLACK); g.fillOval(a, b, 25, 25); } public static void main(String[] args) { MyFrame frame1 = new MyFrame("Drawing Fish"); JPanel outer = new JPanel(); for(int i=0; i&lt;fn; i++){ x = 0 + (i*(w+d+1)); y = 0; FishList sPanel1 = new FishList(); outer.add(sPanel1); } frame1.add(outer); frame1.pack(); frame1.setVisible(true); } }
answer count: 1
type: UnansweredQuestion
tagged with: swing
has answer: http://stackoverflow.com/a/21539044
tagged with: paint
tagged with: java

http://stackoverflow.com/a/21622784
has comment: http://stackoverflow.com/comment/32675404
has comment: http://stackoverflow.com/comment/32676183
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32673043
downvote count: 0
type: Answer
has body: Because your loop is incorrect. You constructed a new String array in every inner loop, so every array has only on element. Try the following code: List&lt;String[]&gt; data = new ArrayList&lt;String[]&gt;(); for(List&lt;String&gt; strlist : resultList) { String[] array = new String[strlist.size()]; int offset = 0; for(String s : strlist) { array[offset ++] = s; } data.add(array); } ============== Edited bellow ================== I've re-ordered the loop to match your output requirement. Also, a sample input is provided to test the algorithm. List&lt;List&lt;String&gt;&gt; resultList = new ArrayList&lt;List&lt;String&gt;&gt;(); for (int i = 1; i &lt;= 9; i++) { List&lt;String&gt; innerList = new ArrayList&lt;String&gt;(); resultList.add(innerList); for (int j = 1; j &lt;= 9; j++) { innerList.add(j + ""); } } List&lt;String[]&gt; data = new ArrayList&lt;String[]&gt;(); for(int m = 0; m &lt; resultList.get(0).size(); m++) { String[] array = new String[resultList.size()]; for (int i = 0; i &lt; resultList.size(); i++) { array[i] = resultList.get(i).get(m).toString(); } data.add(array); } for(String[] array : data) { System.out.println(Arrays.toString(array)); }
has comment: http://stackoverflow.com/comment/32676253
answers question: http://stackoverflow.com/q/21622660
accepted answer of: http://stackoverflow.com/q/21622660
score: 1
upvote count: 1

http://stackoverflow.com/q/21644741
score: 0
downvote count: 4
answer count: 3
favorite count: 0
has body: I'm writing a simple method that takes grades as input from the user and calculates the Grade Point Average. Here is my code: public static double calculateGPA(){ Scanner in = new Scanner(System.in); double totalGradePoints = 0; // total grade points int numClasses = 0; // total classes completed boolean doneInput = false; // returns true when use is done inputting grades System.out.println("Enter all your grades (A,B,C,D,F) and enter 'done' if you are done entering your grades."); while (!doneInput) { String grade = in.next(); if (grade == "A") { totalGradePoints += 4; numClasses++; } else if (grade == "B") { totalGradePoints += 3; numClasses++; } else if(grade == "C") { totalGradePoints += 2; numClasses++; } else if(grade == "D") { totalGradePoints += 1; numClasses++; } else if(grade == "F") { numClasses++; } else { doneInput = true; } //end if - else-if - else statement }//end while loop double unwtGPA = (totalGradePoints/numClasses); return unwtGPA; } When I tested the method, I was only able to input one grade and none of the variables incremented, can somebody tell me what's wrong with the code?
linked to: http://stackoverflow.com/q/513832
has answer: http://stackoverflow.com/a/21644762
duplicate of: http://stackoverflow.com/q/513832
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21644771
tagged with: java
type: Question
tagged with: if-statement
has answer: http://stackoverflow.com/a/21644844
upvote count: 4
linked to: http://stackoverflow.com/q/7520432
has title: Why does this code not work as intended?

http://stackoverflow.com/comment/32768345
score: 0
comment on: http://stackoverflow.com/q/21677455
type: QuestionComment
has text: instead of `onDestroy()` use `onStop()`.
type: Comment

http://stackoverflow.com/comment/32582390
type: Comment
comment on: http://stackoverflow.com/a/21571021
score: 0
has text: +1 Yeps, you are correct.
type: AnswerComment

http://stackoverflow.com/comment/32758906
has text: So removing the tread.sleep statement will stop the frames from dropping?
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21671890

http://stackoverflow.com/comment/32756601
comment on: http://stackoverflow.com/a/21670377
type: AnswerComment
score: 0
has text: can u please help me i want to split the "~" in splitedValue[j] but i am failed to do so ..... i have written Log.i(j+" at ArrayIndex "+k+" at splitedIndex Value is >> ",splitedValue[k].split("~"));
type: Comment

http://stackoverflow.com/q/21558207
downvote count: 0
answer count: 1
favorite count: 0
has body: I'm hitting a strange memory limit with java. Below I execute "java -version" with different heap sizes. Once I set the heap to anything over 30M, java exits with error, complaining there is no free memory. # /usr/java/default/bin/java -Xmx30m -version java version "1.7.0_45" Java(TM) SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode) # /usr/java/default/bin/java -Xmx40m -version # # There is insufficient memory for the Java Runtime Environment to continue. # pthread_getattr_np # An error report file with more information is saved as: # /root/hs_err_pid6689.log # /usr/java/default/bin/java -Xmx50m -version Error occurred during initialization of VM java.lang.OutOfMemoryError: unable to create new native thread # /usr/java/default/bin/java -Xmx60m -version # # There is insufficient memory for the Java Runtime Environment to continue. # pthread_getattr_np # An error report file with more information is saved as: # /root/hs_err_pid6703.log According to "free" I have lots of free RAM: # free -m total used free shared buffers cached Mem: 2909 1051 1858 0 17 618 -/+ buffers/cache: 415 2494 Swap: 511 0 511 But from what I see this clearly is a memory limit issue. When I kill some background processes, I can assign more heap to "java -version" command. Does anyone know what's happening?
upvote count: 2
type: AnsweredQuestion
tagged with: memory-limit
tagged with: java
has answer: http://stackoverflow.com/a/21574434
has comment: http://stackoverflow.com/comment/32563419
type: Question
has title: Couldn't reserve enough space for object heap
has comment: http://stackoverflow.com/comment/32559458
accepted answer: http://stackoverflow.com/a/21574434
score: 2

http://stackoverflow.com/comment/32512050
type: QuestionComment
comment on: http://stackoverflow.com/q/21526538
has text: Yes, still trying to figure it out, as im just started programming java/android
score: 0
type: Comment

http://stackoverflow.com/comment/32583153
comment on: http://stackoverflow.com/a/21571465
type: AnswerComment
type: Comment
has text: I see. Which line do you say it comes from?
score: 0

http://stackoverflow.com/comment/32531549
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21538783
has text: I think I understand what you need now. Take a look and see if this code gives you the desired output. I should have read your post more clearly. You need the timezone offset in the solution, so the millis have the correct value. Let me know if this works (and don't forget to accept if you like it! :))

http://stackoverflow.com/comment/32761458
score: 0
comment on: http://stackoverflow.com/q/21672969
type: Comment
type: QuestionComment
has text: Why would you want to use raw sockets for http, you'd need to implement TCP yourself

http://stackoverflow.com/q/21672177
accepted answer: http://stackoverflow.com/a/21780428
possible better answer: http://stackoverflow.com/a/21779607
has body: I dont know where to ask about this, I cannot find strategic information, "whole picture" information regarding android app architecture, so please bear with me on this one. I tried programmers.stackexchange, but there is almost no activity there. Here is my question: I have an android app in which users have sets of items, and each item has about 10 properties. What I do at the moment: items are stored in the server database when the user logs in, I get all the items (say 37) via the API and put them in a LinkedHashSet&lt; UserItem > (UserItem is a POJO with setters and getters) then I get the 37 items from the set and put them in the local SQLite database when the user opens "My Items" screen in the app, i get the 37 items from the local SQLite DB I was thinking, is this a good practice? Could I circumvent Step 3(storing items in the local database), but instead maintain the life of that LinkedHashSet object and get the items directly from there. If Im right with this suggestion, how do I do that?
has answer: http://stackoverflow.com/a/21779607
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32759717
has comment: http://stackoverflow.com/comment/32759395
has comment: http://stackoverflow.com/comment/32759363
has comment: http://stackoverflow.com/comment/32760487
tagged with: java
has comment: http://stackoverflow.com/comment/32759516
type: Question
answer count: 2
has title: Android strategic decision on data persistence
has answer: http://stackoverflow.com/a/21780428
score: 0
has comment: http://stackoverflow.com/comment/32759251
tagged with: android

http://stackoverflow.com/a/21621984
has comment: http://stackoverflow.com/comment/32677233
upvote count: 5
answers question: http://stackoverflow.com/q/21621958
has comment: http://stackoverflow.com/comment/32671694
has comment: http://stackoverflow.com/comment/32671721
has comment: http://stackoverflow.com/comment/32671595
downvote count: 0
has comment: http://stackoverflow.com/comment/32671957
has body: In this case you are constructing an entirely new String object and that object won't be shared in the constant pool. Note though that in order to construct your new String() object you actually passed into it a String constant. That String constant is in the constants pool, however the string you created through new does not point to the same one, even though they have the same value. If you did String s = "Stackoverflow" then s would contain a reference to the instance in the pool, also there are methods to let you add Strings to the pool after they have been created.
has comment: http://stackoverflow.com/comment/32672398
has comment: http://stackoverflow.com/comment/32671724
type: Answer
has comment: http://stackoverflow.com/comment/32671700
score: 5
has comment: http://stackoverflow.com/comment/32671754

http://stackoverflow.com/comment/32762325
score: 0
comment on: http://stackoverflow.com/q/21673667
type: Comment
type: QuestionComment
has text: yes i do, i even explained the logic id use :) check first comment.

http://stackoverflow.com/a/26905596
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21588727
has body: Try adding this to your web.xml com.sun.jersey.api.json.POJOMappingFeature true More info Jersey JSON Support

http://stackoverflow.com/a/21634117
answers question: http://stackoverflow.com/q/21633630
upvote count: 1
has comment: http://stackoverflow.com/comment/32693701
has body: I suggest add gravity to your game. The gravity will always pull the sprite downwards (-5 on the y axis), but the collision with the floor will always stop the sprite. Unless there is a slope, and then the sprite won't collide with the floor and it will go down, and also in the direction of the keys pressed.
downvote count: 0
score: 1
type: Answer

http://stackoverflow.com/a/21620119
type: Answer
accepted answer of: http://stackoverflow.com/q/21566442
answers question: http://stackoverflow.com/q/21566442
score: 0
type: AcceptedAnswer
has body: This is a simple trick. I hope you would be able to fix this to your code easily. You can put a button (SMS) to its setOnClickListener you can use this. public void onClick(View v) { // TODO Auto-generated method stub try { Intent sendIntent = new Intent(Intent.ACTION_VIEW); sendIntent.putExtra("sms_body", "default content"); sendIntent.setType("vnd.android-dir/mms-sms"); startActivity(sendIntent); } catch (Exception e) { // TODO: handle exception Toast.makeText(getApplicationContext(), "PLS Enter Again ! ", Toast.LENGTH_LONG).show(); e.printStackTrace(); } } });

http://stackoverflow.com/q/21577131
has answer: http://stackoverflow.com/a/21577821
has comment: http://stackoverflow.com/comment/32593425
has comment: http://stackoverflow.com/comment/32593067
has comment: http://stackoverflow.com/comment/32593307
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32593799
has comment: http://stackoverflow.com/comment/32592741
has comment: http://stackoverflow.com/comment/32593737
has comment: http://stackoverflow.com/comment/32593672
score: 0
has comment: http://stackoverflow.com/comment/32593868
tagged with: java
has answer: http://stackoverflow.com/a/21578050
type: Question
has comment: http://stackoverflow.com/comment/32593437
has body: I have code fragment in my Jsp: catch (Exception e) { out.print("&lt;Grid&gt;&lt;IO Result='-1' Message='"); out.print(e.toString()); out.print("'/&gt;&lt;/Grid&gt;"); out.close(); throw new Exception(""); } I expect that result must be valid xml as "&lt;Grid&gt;&lt;IO Result='-1' Message='Failed to load HSQLDB JDBC driver.'/&gt;&lt;/Grid&gt;" But Result of this : "&lt;Grid&gt;&lt;IO Result='-1' Message='"); out.print(e.toString()); out.print("'/&gt;&lt;/Grid&gt;" Please help me to fix this problem!
has title: Jsp out.print() captured extra text
has comment: http://stackoverflow.com/comment/32592980
has comment: http://stackoverflow.com/comment/32593466
answer count: 2
tagged with: printing
tagged with: jsp
has comment: http://stackoverflow.com/comment/32593719

http://stackoverflow.com/comment/32673425
comment on: http://stackoverflow.com/q/21623066
score: 0
type: Comment
has text: The question has been answered in previous thread. Check [this](http://stackoverflow.com/a/6898278/1129468) out!
type: QuestionComment

http://stackoverflow.com/comment/32611539
type: Comment
has text: Now tell us what doesn't work. How is it behaving differently than your expectation?
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21587220

http://stackoverflow.com/q/21615990
type: Question
has title: How to add lines to a TabbedPane in Java
has body: This is my code thus far: Public TabbedPaneGraphic{ super(new GridLayout(1, 1)); JTabbedPane tabbedPane = new JTabbedPane(); ImageIcon icon = createImageIcon(""); for(int i=0; i&lt; 4; i++) { JPanel panel = new JPanel(); tabbedPane.addTab("Name " + i , icon, panel, "Panel " + (i+1)); tabbedPane.setMnemonicAt(0, KeyEvent.VK_1); } add(tabbedPane); tabbedPane.setSize(new Dimension(300, 300)); tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); } I wish to add a grid made of lines to each individual tabbed panel, conditional on what "i" is (e.g. drawLine(0,i,0,100*i)). However, I do not see any way to add such a grid in the "for" loop-- is this even possible? If not, how would I do it?
score: 0
has comment: http://stackoverflow.com/comment/32662497
has comment: http://stackoverflow.com/comment/32662066
tagged with: java
type: UnansweredQuestion
tagged with: user-interface
answer count: 0
tagged with: jtabbedpane

http://stackoverflow.com/q/21606473
possible better answer: http://stackoverflow.com/a/21608222
downvote count: 0
has body: I've made a basic client server FTP program using sockets, but for some reason files are getting corrupted during the transfer. In the case below, I'm pushing a file to the server from the client. It almost works, since some files (such as a .png) transfer and open fine, but others (a .docx) don't. Any file that I transfer has a different MD5 to the one I sent. Client code: File file = null; FTPDataBlock transferBlock; int numBytesRead = 0; int blockNumber = 1; int blockSize = 1024; byte[] block = new byte[blockSize]; fc = new JFileChooser(); // select file to upload int returnVal = fc.showOpenDialog(Client.this); if (returnVal == JFileChooser.APPROVE_OPTION) { file = fc.getSelectedFile(); try { // get total number of blocks and send to server int totalNumBlocks = (int)Math.ceil((file.length()*1.0) / blockSize); System.out.println("File length is: " + file.length()); FTPCommand c = new FTPCommand("PUSH", Integer.toString(totalNumBlocks)); oos = new ObjectOutputStream(sock.getOutputStream()); oos.writeObject(c); oos.flush(); // send to server block by block FileInputStream fin = new FileInputStream(file); while ((numBytesRead = fin.read(block)) != -1){ transferBlock = new FTPDataBlock(file.getName(), blockNumber, block); blockNumber++; System.out.println("Sending block " + transferBlock.getBlockNumber() + " of " + totalNumBlocks); oos = new ObjectOutputStream(sock.getOutputStream()); oos.writeObject(transferBlock); oos.flush(); } fin.close(); System.out.println("PUSH Complete"); // get response from server ois = new ObjectInputStream(sock.getInputStream()); FTPResponse response = (FTPResponse)ois.readObject(); statusArea.setText(response.getResponse()); } catch (IOException | ClassNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } Server Code: else if (cmd.getCommand().equals("PUSH")){ // get total number of file blocks int totalNumBlocks = Integer.parseInt(cmd.getParameters()); // get first block in = new ObjectInputStream(sock.getI…
favorite count: 0
tagged with: sockets
has comment: http://stackoverflow.com/comment/32648369
has answer: http://stackoverflow.com/a/21610699
has comment: http://stackoverflow.com/comment/32644907
tagged with: ftp
type: AnsweredQuestion
upvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/32644963
has title: Java - FTP program corrupting file during transfer
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/21610699
has comment: http://stackoverflow.com/comment/32646612
has answer: http://stackoverflow.com/a/21608222
has comment: http://stackoverflow.com/comment/32644658
has comment: http://stackoverflow.com/comment/32644798
has comment: http://stackoverflow.com/comment/32647565
has comment: http://stackoverflow.com/comment/32647179
answer count: 2

http://stackoverflow.com/comment/32493174
type: AnswerComment
comment on: http://stackoverflow.com/a/21520864
type: Comment
has text: So the `responseList` bean will include `response` bean object state automatically?
score: 0

http://stackoverflow.com/comment/63830218
type: AnswerComment
comment on: http://stackoverflow.com/a/21573253
score: 0
type: Comment
has text: Ah, sorry, I actually looked into the 2.1.0-SNAPSHOT development sources where `PDPageContentStream` has got a base class `PDAbstractContentStream` - the issue PDFBOX-3353 is cause of this change. Thus, I assume this base class will soon be part of the release.

http://stackoverflow.com/a/21520957
type: Answer
upvote count: 7
score: 7
accepted answer of: http://stackoverflow.com/q/21520380
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21520380
has body: In your declaration: public class ActivityInventoryMem&lt;Activity&gt; extends TreeSet&lt;Activity&gt; implements ActivityInventory&lt;Activity&gt; // ^ (1) ^ (2) ^ (3) the uses of Activity at (2) and (3) are as type arguments to TreeSet and ActivityInventory, whereas the use at (1) is declaring a new type parameter for your ActivityInventoryMem class. Thus, uses of the symbol Activity within that class don't refer to your actual Activity class, they refer to some type parameter whose actual type is unknown. You probably just want to leave off (1) from your class declaration: public class ActivityInventoryMem extends TreeSet&lt;Activity&gt; implements ActivityInventory&lt;Activity&gt;

http://stackoverflow.com/q/21561914
upvote count: 7
type: Question
has answer: http://stackoverflow.com/a/21563753
tagged with: algorithm
has answer: http://stackoverflow.com/a/21562584
answer count: 2
has title: Error calculating pi using the Chudnovsky algorithm - Java
possible better answer: http://stackoverflow.com/a/21562584
downvote count: 0
score: 7
favorite count: 0
has body: I have been trying to write a simple program to calculate pi using the Chudnovsky algorithm however I keep getting the wrong value output. The latest code i have written is below and outputs: 9.642715619298075837448823278218780086541162343253084414940204168864066834806498471622628399332216456e11 Can anyone tell me where I went wrong. As Peter de Rivaz pointed out I was discarding the value of b with that fixed the output is now: -1.76779979383639157654764981441635890608880847407921749358841620214761790018058‌​3600120191582474909093e-2 Apfloat sum = new Apfloat(0); for(int k = 0; k &lt; n; k++) { int thrk= 3*k; Apfloat a = ApintMath.factorial(6*k); //(6k)! * (-1)^k a = a.multiply(ApintMath.pow(new Apint(-1),k)); Apfloat b = new Apfloat(545140134); b = b.multiply(new Apfloat(k)); b = b.add(new Apfloat(13591409)); // 13591409 + 545140134k Apfloat c = ApintMath.factorial(thrk); // (3k!) Apfloat d = ApintMath.factorial(k); d = ApfloatMath.pow(d, 3); // (k!)^3 Apfloat e = new Apfloat(640320); e = ApfloatMath.pow(e,(thrk)); // (640320)^(3k) a = a.multiply(b); // a is know the numerator c = c.multiply(d).multiply(e); // c in know the denominator Apfloat div = a.divide(c.precision(digits)); sum = sum.add(div); } Apfloat f = new Apfloat(10005, digits);// Works out the constant sqrt part f = ApfloatMath.sqrt(f); f = f.divide(new Apfloat(42709344*100)); Apfloat pi = ApfloatMath.pow(sum.multiply(f), -1); System.out.println(pi);
accepted answer: http://stackoverflow.com/a/21563753
tagged with: apfloat
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/a/21558493
has body: A secure way to do this is to require client certificate authentication for applets that want to download your file. Here's an example that uses the Apache HTTP Client. You'll also need to create a self-signed client certificate that you provide to "valid" users through some other channel (like a web page with a required login), and you'll need to tell your HTTP server about the self-signed certificate. Here's a way to set up a self-signed client certificate if you are using Tomcat: Tomcat Server/Client Self-Signed SSL Certificate. Of course, other HTTP servers will have different procedures. There are some issues using the browser certificates with the java plugin that will require your users do to some work exporting the browser certificates for use with the Java plugin. See http://download.java.net/jdk7/archive/b126/docs/technotes/guides/deployment/deployment-guide/upgrade-guide/article-16.html
score: 0
has comment: http://stackoverflow.com/comment/32586424
type: Answer
answers question: http://stackoverflow.com/q/21557813

http://stackoverflow.com/comment/32557628
comment on: http://stackoverflow.com/q/21557529
type: Comment
type: QuestionComment
has text: Also, check your logs.
score: 0

http://stackoverflow.com/a/21523291
score: 0
has body: in Java, notion of class is somewhat misleading. On one hand, it is a minimal program and a component of complex programs. On the other hand, it is a reference data type. When it is claimed "all classes are inherited from Object", class is meant as data type. But only non-static members of a class define the data type. Static members like static void main() are parts of a program but not parts of data type. So main has no relation with Object and heap.
answers question: http://stackoverflow.com/q/21521149
type: Answer

classification
tags question: http://stackoverflow.com/q/21533837
tag name: classification
tags question: http://stackoverflow.com/q/21525337
type: Tag
tags question: http://stackoverflow.com/q/21645046
tags question: http://stackoverflow.com/q/21674522

http://stackoverflow.com/q/21655354
type: UnansweredQuestion
has body: so I'm trying to write a flappy bird like coin collector game, and when I try to set the coin images coordinates to a random number the screen freezes. Any help? Heres my player class: package gamepackage; import java.util.Random; import org.newdawn.slick.*; import org.newdawn.slick.geom.Rectangle; import org.newdawn.slick.state.*; public class Playing extends BasicGameState{ Image coin; Image guy; int coincounter = 0; float x = 30, y = 90; int coiny = 20, coinx= 1000; public Playing(int state){ } public void init(GameContainer gc, StateBasedGame sbg)throws SlickException{ guy = new Image("res/PlaneMovie1.gif"); coin = new Image("res/coin.gif"); } public void render(GameContainer gc, StateBasedGame sbg, Graphics g)throws SlickException{ g.drawString("Coins:" + coincounter, 70, 70); g.drawImage(coin, coinx, coiny); g.drawImage(guy, x, y); } public void update(GameContainer gc, StateBasedGame sbg, int delta)throws SlickException{ Input input = gc.getInput(); coinx --; if(input.isKeyDown(Input.KEY_SPACE)){ y -= 1 ; } if(input.isKeyDown(Input.KEY_SPACE) == false){ y += .5;} if(y == coiny){ coincounter += 1;coinx = 1000; coiny -= 20;} if(coinx == -175){coinx = 1000; coiny += 20;} } public int getID(){ return 1; } }
has title: Setting a picture to random coordinates?
answer count: 0
tagged with: java
tagged with: slick2d
type: Question
tagged with: image
has comment: http://stackoverflow.com/comment/32885892
score: 0
upvote count: 1
downvote count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/32730287

http://stackoverflow.com/q/21567326
tagged with: android
answer count: 0
has title: Two Extremely unusual Errors
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/21567086
tagged with: java
tagged with: eclipse
type: Question
has comment: http://stackoverflow.com/comment/32576218
has body: I've implemented a Drag n Drop (android version 11) After implementing it, sometimes it throws these Errors... Any of you know what are these errors? I can't seem to find any information about them. Error 1: Unable to transfer touch focus Error 2: Drag is in progress but there is no drag window handle. The code is in this page: StackOverflow Question (I want to avoid duplicates) Thanks!
has comment: http://stackoverflow.com/comment/32576073
has comment: http://stackoverflow.com/comment/32576086
tagged with: runtime-error
score: 0

http://stackoverflow.com/a/21630565
downvote count: 0
answers question: http://stackoverflow.com/q/21628983
has comment: http://stackoverflow.com/comment/32742086
has body: You could probably call an @Asynchronous EJB for the Database updates (http://docs.oracle.com/javaee/6/tutorial/doc/gkkqg.html), but then you'd have to handle the case where the DB updates failed. You could return a temporary location to the client and so that it can send subsequent requests to get the status of the DB operations (success/in progress/failed).
has comment: http://stackoverflow.com/comment/32704528
has comment: http://stackoverflow.com/comment/32742409
has comment: http://stackoverflow.com/comment/32741573
type: Answer
has comment: http://stackoverflow.com/comment/32758624
upvote count: 1
score: 1

http://stackoverflow.com/a/21631031
has comment: http://stackoverflow.com/comment/32687368
upvote count: 1
downvote count: 0
answers question: http://stackoverflow.com/q/21630855
score: 1
type: Answer
has body: This happens, because the amount cannot be represented exactly as a double. When you convert to an int it gets truncated. The change amount in cents is 372.99999999999955 if you print it with 14 decimals. Either use BigDecimal or a custom Currency type that only uses Integer or int to do calculations.
has comment: http://stackoverflow.com/comment/32687321

http://stackoverflow.com/q/21643449
downvote count: 0
score: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21649189
has comment: http://stackoverflow.com/comment/32709380
favorite count: 0
type: Question
upvote count: 2
tagged with: swing
answer count: 1
accepted answer: http://stackoverflow.com/a/21649189
tagged with: java
has body: drag a jframe window from it's content area is simple, but here is the problem. when i added a label onto the frame, it's still ok even drag on the label, but when i add mouseclicked event for the label, even no codes actually proccessed in the adapter, the dragging can't happen when i drag on the label, but drag on the rest area of the window is fine. another thing is I want to make the window's opacity varies with the mouse motion, with this.setOpacity(0.9f); after the label's mouseclicked event set, the label won't respond to this also.. anyone knows how the solve this? private void formMousePressed(java.awt.event.MouseEvent evt) { offsetX = evt.getX(); offsetY = evt.getY(); } private void formMouseDragged(java.awt.event.MouseEvent evt) { java.awt.Component c = (Component) evt.getSource(); c.setLocation(evt.getXOnScreen() - offsetX, evt.getYOnScreen()- offsetY); } private void jLabel1MouseClicked(java.awt.event.MouseEvent evt) { // nothing actually done in the Label's mouse handler } private void formMouseEntered(java.awt.event.MouseEvent evt) { this.setOpacity(0.9f); } private void formMouseExited(java.awt.event.MouseEvent evt) { this.setOpacity(0.4f); }
has comment: http://stackoverflow.com/comment/32709415
has title: drag/move JFrame/JDialog window from content area
has comment: http://stackoverflow.com/comment/32709712

http://stackoverflow.com/q/21651338
upvote count: 3
has answer: http://stackoverflow.com/a/21701125
type: Question
has title: Using myBatis with dynamic table name and object
score: 3
tagged with: java
has comment: http://stackoverflow.com/comment/32735899
has body: I'm about to create a dynamic SQL insert using myBatis, where the table name and the object holding the parameters are different. Something like this: INSERT INTO ${tablename} (column1, column2) VALUES (#{column1}, #{column2}) The interface method would be this: @Insert(CREATE) @Options(useGeneratedKeys = true, keyProperty = "id", flushCache = true) public int write(String tablename, Object object) throws Exception; Where the Object holds the field values: class Object { int id; String column1; String column2; getters, setters... } Unfortunately I can't find out how to do this, the best and working way I found is when the table name is a property of the Object, so the myBatis can read the value in this way. For some practical reason I'd like to avoid this approach, maybe someone has a better idea? Thanks.
answer count: 1
downvote count: 0
tagged with: mybatis
favorite count: 0
has comment: http://stackoverflow.com/comment/32723050
accepted answer: http://stackoverflow.com/a/21701125
type: AnsweredQuestion

http://stackoverflow.com/comment/32564280
type: AnswerComment
score: 0
type: Comment
has text: @SotiriosDelimanolis I dunno, it actually fixes all the problems and provides code.
comment on: http://stackoverflow.com/a/21561194

glassfish-4
tags question: http://stackoverflow.com/q/21602868
type: Tag
tags question: http://stackoverflow.com/q/21637912
tag name: glassfish-4
tags question: http://stackoverflow.com/q/21607087

http://stackoverflow.com/comment/32545153
comment on: http://stackoverflow.com/q/21550495
has text: Your init method will set row & col values later than a[][] & b[][] initialize, so a and b are 0-bidimensional.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32645177
comment on: http://stackoverflow.com/q/21607011
score: 0
type: QuestionComment
type: Comment
has text: You're right; "literal variable" is meaningless. The person who made the answers is getting confused about initializers.

tableview
tags question: http://stackoverflow.com/q/21678088
tags question: http://stackoverflow.com/q/21639108
type: Tag
tags question: http://stackoverflow.com/q/21641299
tags question: http://stackoverflow.com/q/21585943
tag name: tableview

http://stackoverflow.com/comment/32551030
comment on: http://stackoverflow.com/q/21553553
type: Comment
score: 0
has text: I use rectangle.intersects() and it worked. Problem in notify my objects when collision is ended.
type: QuestionComment

xpath
tags question: http://stackoverflow.com/q/21651033
tags question: http://stackoverflow.com/q/21628593
tag name: xpath
tags question: http://stackoverflow.com/q/21549179
tags question: http://stackoverflow.com/q/21672729
tags question: http://stackoverflow.com/q/21553798
tags question: http://stackoverflow.com/q/21661304
tags question: http://stackoverflow.com/q/21606789
type: Tag
tags question: http://stackoverflow.com/q/21595021

formatting
tags question: http://stackoverflow.com/q/21584419
tag name: formatting
type: Tag
tags question: http://stackoverflow.com/q/21534704

http://stackoverflow.com/comment/32702599
has text: Hopefully my edits help! I know there is a lot, but it is a lot easier to make a setter and getter than to have to get input ever time.
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21638962

http://stackoverflow.com/a/21546996
has comment: http://stackoverflow.com/comment/32538982
has body: String s=longStr.split("@")[9]; would give someText10 if you want the substring till the end do String sub=longStr.substring(indexOf(s)); or all in one: String sub=longStr.substring(indexOf(longStr.split("@")[9]));
has comment: http://stackoverflow.com/comment/32538785
downvote count: 0
has comment: http://stackoverflow.com/comment/32574500
type: Answer
answers question: http://stackoverflow.com/q/21546977
score: 5
upvote count: 5

http://stackoverflow.com/q/21566144
score: 0
has body: public class Starter extends Thread{ private int x = 2; public static void main(String[] args) throws Exception { new Starter().makeItSo(); } public Starter() { x = 5; start(); } public void makeItSo() throws Exception { join(); x = x - 1; System.out.println(x); } public void run() { x *= 2; } } I understand how the code works and the answer is "9". But i have a doubt in Exception concept. As i know join() method throws an Exception i.e Interrupted Exception , so we declared that exception but why we didn't handled that exception in main method? And suppose if i handled this exception in the same method , where i have declared join(). Then what i need to do in main() method??
answer count: 1
has comment: http://stackoverflow.com/comment/32574256
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21566200
has comment: http://stackoverflow.com/comment/32573938
tagged with: java
has title: Exception is declared but not handled SCJP
type: Question

http://stackoverflow.com/q/21637050
type: AnsweredQuestion
tagged with: java
tagged with: eclipse
possible better answer: http://stackoverflow.com/a/21637086
has comment: http://stackoverflow.com/comment/32698301
type: Question
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/32698520
has answer: http://stackoverflow.com/a/21637127
accepted answer: http://stackoverflow.com/a/21637127
has comment: http://stackoverflow.com/comment/32698618
has answer: http://stackoverflow.com/a/21637086
has body: I am trying to create a program that works as a "math help calculator" and it asks you questions. I have a button on the calculator to ask you a new question and I want to be able to ask a maximum of ten questions. So I figured why not make a for loop where the button to ask a new questions makes the increment which will then prompt the new question. PROBLEM: for some reason unless I make it i++ in the for loop it's self. My program freezes. No syntax or run time errors but the java program freezes. I guess in theory it would work but I am doing something wrong? for(int i = 0; i &lt; 10;){ if(e.getSource() == cmdNew){ i++; }
has title: Program freezing on run
has comment: http://stackoverflow.com/comment/32698827
has comment: http://stackoverflow.com/comment/32698494

http://stackoverflow.com/q/21553570
has body: A long standing issue (some call it - arguably - feature :) is the weakness of all listeners installed by all fx-bindings. As a consequence, we can't build "chains" of properties without keeping a strong reference to each link of the chain. A particular type of such a chain link is a JavaBeanProperty: its purpose is to adapt a javabean property to a fx-property. Typically, nobody is interested in the adapter as such, so its usage would do something like private Parent createContentBean() { ... // local ref only Property property = createJavaBeanProperty(); Bindings.bindBidirectional(label.textProperty(), property, NumberFormat.getInstance()); .. wondering why the label isn't updated. Changing property to a strong reference will work as expected (leaving me puzzeld as to who is responsible to feed the dummy, but that's another question): Property property; private Parent createContentBean() { ... // instantiate the field property = createJavaBeanProperty(); Bindings.bindBidirectional(label.textProperty(), property, NumberFormat.getInstance()); Long intro, but nearly there: jdk8 somehow changed the implementation so that the first approach is now working, there's no longer any need to keep a strong reference to a JavaBeanProperty. On the other hand, custom implementations of "chain links" still need a strong reference. Questions: is the change of behaviour intentional and if so, why? how is it achieved? The code looks very similar ... and I would love to try something similar in custom adapters A complete example to play with: public class BeanAdapterExample extends Application { private Counter counter; public BeanAdapterExample() { this.counter = new Counter(); } Property property; private Parent createContentBean() { VBox content = new VBox(); Label label = new Label(); // strong ref property = createJavaBeanProperty(); // local property Property property = createJavaBeanProperty(); Bindings.bindBidirectional(label.textProperty(), property, NumberFormat.getInstance…
downvote count: 0
has title: JavaBeanProperty: jdk7 vs jdk 8 - WeakOnTheFeet vs StrongInTheArm
upvote count: 3
linked to: http://stackoverflow.com/q/13906139
tagged with: binding
tagged with: javafx-8
has answer: http://stackoverflow.com/a/21579555
favorite count: 0
tagged with: javafx-2
type: UnansweredQuestion
tagged with: swing
type: Question
score: 3
has answer: http://stackoverflow.com/a/21560319
tagged with: java
answer count: 2

http://stackoverflow.com/comment/32678119
type: Comment
type: QuestionComment
score: 0
has text: [Look here](http://www.w3schools.com/js/js_obj_array.asp).
comment on: http://stackoverflow.com/q/21625978

methods
tags question: http://stackoverflow.com/q/21641800
tags question: http://stackoverflow.com/q/21562306
tags question: http://stackoverflow.com/q/21665628
tags question: http://stackoverflow.com/q/21592186
tags question: http://stackoverflow.com/q/21615767
tags question: http://stackoverflow.com/q/21559718
tags question: http://stackoverflow.com/q/21545787
tag name: methods
tags question: http://stackoverflow.com/q/21613231
tags question: http://stackoverflow.com/q/21624403
tags question: http://stackoverflow.com/q/21563040
tags question: http://stackoverflow.com/q/21562192
tags question: http://stackoverflow.com/q/21642862
tags question: http://stackoverflow.com/q/21664727
tags question: http://stackoverflow.com/q/21540604
tags question: http://stackoverflow.com/q/21527099
tags question: http://stackoverflow.com/q/21648262
tags question: http://stackoverflow.com/q/21540931
tags question: http://stackoverflow.com/q/21568612
tags question: http://stackoverflow.com/q/21555916
type: Tag
tags question: http://stackoverflow.com/q/21612702
tags question: http://stackoverflow.com/q/21638316
tags question: http://stackoverflow.com/q/21516770
tags question: http://stackoverflow.com/q/21518627
tags question: http://stackoverflow.com/q/21538697
tags question: http://stackoverflow.com/q/21587447
tags question: http://stackoverflow.com/q/21517394
tags question: http://stackoverflow.com/q/21620592
tags question: http://stackoverflow.com/q/21568102
tags question: http://stackoverflow.com/q/21618901
tags question: http://stackoverflow.com/q/21517956
tags question: http://stackoverflow.com/q/21648556
tags question: http://stackoverflow.com/q/21644186
tags question: http://stackoverflow.com/q/21630971
tags question: http://stackoverflow.com/q/21647988
tags question: http://stackoverflow.com/q/21593659
tags question: http://stackoverflow.com/q/21597991
tags question: http://stackoverflow.com/q/21636566
tags question: http://stackoverflow.com/q/21576363
tags question: http://stackoverflow.com/q/21519006
tags question: http://stackoverflow.com/q/21630966
tags question: http://stackoverflow.com/q/21642557
tags question: http://stackoverflow.com/q/21677781
tags question: http://stackoverflow.com/q/21607563
tags question: http://stackoverflow.com/q/21670169
tags question: http://stackoverflow.com/q/21578791
tags question: http://stackoverflow.com/q/21561295
tags question: http://stackoverflow.com/q/21658669
tags question: http://stackoverflow.com/q/21605480
tags question: http://stackoverflow.com/q/21544374
tags question: http://stackoverflow.com/q/21619705
tags question: http://stackoverflow.com/q/21565060
tags question: http://stackoverflow.com/q/21666404
tags question: http://stackoverflow.com/q/21527523
tags question: http://stackoverflow.com/q/21543066

http://stackoverflow.com/comment/32581159
comment on: http://stackoverflow.com/a/21570072
type: AnswerComment
has text: 2. This way needs when the rest 1 consumer finish; 3.would you elaborate more about listeners?
score: 0
type: Comment

http://stackoverflow.com/q/21615880
downvote count: 0
has comment: http://stackoverflow.com/comment/32661709
has comment: http://stackoverflow.com/comment/32661807
has comment: http://stackoverflow.com/comment/32662130
possible better answer: http://stackoverflow.com/a/21615950
has comment: http://stackoverflow.com/comment/32661663
has comment: http://stackoverflow.com/comment/32694105
accepted answer: http://stackoverflow.com/a/21887214
favorite count: 0
upvote count: 2
has body: I'm in the process of converting a function in OpenCV which is in C++ to Java. Link. I don't know too much about C++ and struggling to convert this part: /// Set the ranges ( for B,G,R) ) float range[] = { 0, 256 } ; //the upper boundary is exclusive const float* histRange = { range }; This is what I have so far: //Set of ranges float ranges[] = {0,256}; final float histRange = {ranges}; Edit: Thanks for your help, I have managed to get it working. This question was in the context of OpenCV (Sorry if I didn't make it clear). Code: //Set of ranges float ranges[] = {0,256}; MatOfFloat histRange = new MatOfFloat(ranges);
tagged with: c++
tagged with: opencv
score: 2
type: AnsweredQuestion
has title: Converting a pointer to an array in C++ to Java (OpenCV)
tagged with: java
has comment: http://stackoverflow.com/comment/32662734
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/21887214
has answer: http://stackoverflow.com/a/21615950

http://stackoverflow.com/q/21641889
tagged with: java
tagged with: eclipse
has body: I currently deal with a tutorial for beginners to build my first Android application in Eclipse. I created a new Android project with default values. Next, Eclipse reports an error in the AndroidManifest.xml file. Here is the line producing the error: android:icon="@drawable/ic_launcher" This is the error message: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_launcher'). How do I fix this?
type: Question
upvote count: 2
has title: Error in AndroidManifest.xml File of an Android Project With Default Values
answer count: 3
downvote count: 1
favorite count: 0
type: UnansweredQuestion
tagged with: android
has answer: http://stackoverflow.com/a/21641902
has comment: http://stackoverflow.com/comment/32706992
has answer: http://stackoverflow.com/a/21641901
has answer: http://stackoverflow.com/a/21642099
score: 1

http://stackoverflow.com/comment/32662619
score: 0
has text: If you want to get rid of `continue outerloop`, you need to have a flag variable which indicates whether you exited the inner loop because you found a match or because you failed to do so, and then you have to test that variable and use that to control whether the value gets added to the output. That wouldn't change the complexity, but would make the code a bit slower... but would also make it easier to read. (As I said in my notes, actually.)
type: Comment
comment on: http://stackoverflow.com/a/21615110
type: AnswerComment

http://stackoverflow.com/comment/32736491
comment on: http://stackoverflow.com/q/21659057
type: Comment
type: QuestionComment
has text: That is a lot of code. Please remove the irrelevant parts and post an example only showing the problem
score: 1

http://stackoverflow.com/comment/32551972
score: 0
type: AnswerComment
type: Comment
has text: I have modified XSSF to HSSF,still am getting the same error.
comment on: http://stackoverflow.com/a/21554526

http://stackoverflow.com/comment/32672149
type: Comment
comment on: http://stackoverflow.com/q/21622169
score: 0
has text: Thank you for your instant response. My 3 ports are 42010, 42020 and 42030. The HB port is 42030 (the port which I can only get response, the one which runs first). I queried from the terminal the netstat outputs for each 3 ports, and the process ID's for all are the same:
type: QuestionComment

http://stackoverflow.com/a/21623987
type: Answer
score: 1
accepted answer of: http://stackoverflow.com/q/21622917
answers question: http://stackoverflow.com/q/21622917
upvote count: 1
type: AcceptedAnswer
downvote count: 0
has body: In notepad++, you can search for &gt; and replace with &gt;\r\n just click the "Extended" search mode

http://stackoverflow.com/comment/32648383
type: QuestionComment
comment on: http://stackoverflow.com/q/21584563
score: 0
has text: @Charles Okey, I changed the question to be clearer.
type: Comment

http://stackoverflow.com/a/21559825
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21559718
has body: In both cases you are not account for the fact that you might not end up inside the loop(s). in your 1st case: double[] numbersArray; while (input.hasNextDouble() &amp;&amp; n&lt;MAX_SIZE){ double in = input.nextDouble(); if (inList(in,numbersArray)) numbersArray[n]=in; n++; } what if, input does not have double from the get go? if that is the case your numbersArray never initialized. Though in more general terms even if there is a double not initializing your numbersArray will cause an exception. in your second case: for (double i : list) { if (i == number){ return false; } else return true; } if list is empty, then there is no return statement to return from. Hope that helps

http://stackoverflow.com/a/35960237
answers question: http://stackoverflow.com/q/21667254
score: 0
type: Answer
has body: I also had same problem. If you are using ssl, try deleting conf/generated.keystore, restart server (with -Dhttps.port=9443 option). New certificate will be automatically created and problem is resolved

http://stackoverflow.com/comment/32741814
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21662145
has text: @NKN it already extends `Application` :)
score: 0

http://stackoverflow.com/a/21672164
answers question: http://stackoverflow.com/q/21672034
type: Answer
has body: Case 1 : false &amp;&amp; false || true =&gt; true Case 2 : (false &amp;&amp; false) || true =&gt; true Case 3 : false &amp;&amp; ( false || true ) =&gt; false operation in brackets should always be executed before other operations. case 2 : (false &amp;&amp; false) || true =&gt; false || true =&gt; true case 3 : false &amp;&amp; ( false || true ) =&gt; false &amp;&amp; true =&gt; false case 1 : false &amp;&amp; false || true =&gt; false || true =&gt; true
score: 0

android-dialog
type: Tag
tag name: android-dialog
tags question: http://stackoverflow.com/q/21561129

http://stackoverflow.com/a/21767620
type: Answer
upvote count: 1
has body: This looks like a bug to me. org.jboss.as.messaging.deployment.JMSContextProducer$JMSContextWrapper.getDelegate() shouldn't register a Synchronization with the Transaction. Instead, the TransactionSynchronizationRegistry should be used. Please create a https://issues.jboss.org/browse/WFLY bug report for this.
has comment: http://stackoverflow.com/comment/93980521
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/21523534
has comment: http://stackoverflow.com/comment/93976355

http://stackoverflow.com/a/21645761
accepted answer of: http://stackoverflow.com/q/21645188
has body: Check your build path mySql driver is added. and please add exception to the question what you getting, then easily can answer. mysql-connector-java-5.1.24-bin.jar you can get it from here have a look this SO How to avoid java code in jsp I suggest you to use Servlets instead of writing java code in jsp. If you write code in servlets then easily you can test/debug your code. To answer: how can I make the changes to insert the value? Create a PreparedStatement obj with sql insert query and call [executeUpdate()][3] to perform INSERT, UPDATE or DELETE operations. Add this piece of code in your ProductDataBean class to add a new record to table. public static void addRecord(DVD dvd) throws SQLException{ PreparedStatement pStatement = getConnection().prepareStatement("insert into products(movieName, movieRate, movieYear, moviePrice) values(?,?,?,?)"); pStatement.setString(1, dvd.getMovie()); pStatement.setString(2, dvd.getRating()); pStatement.setString(3, dvd.getYear()); pStatement.setDouble(4, dvd.getPrice()); pStatement.executeUpdate(); } Make your DVD class a POJO like package cart; public class DVD { private String movie; private String rating; private String year; private Double price; public DVD(){} public DVD(String movie, String rating, String year, Double price) { this.movie = movie; this.rating = rating; this.year = year; this.price = price; } public String getMovie() { return movie; } public void setMovie(String movie) { this.movie = movie; } public String getRating() { return rating; } public void setRating(String rating) { this.rating = rating; } public String getYear() { return year; } public void setYear(String year) { this.year = year; } public Double getPrice() { return price; } public void setPrice(Double price) { this.price = price; } @Override public String toString() { return "DVD [movie=" + movie + ", rating=" + rating + ", year=" + year + ", price=" + price + "]"; } } And in your jsp page call servlet url pattern to perform GET and POST, and to r…
score: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32715890
answers question: http://stackoverflow.com/q/21645188
type: Answer
has comment: http://stackoverflow.com/comment/32714059
has comment: http://stackoverflow.com/comment/32713760
has comment: http://stackoverflow.com/comment/32713217

http://stackoverflow.com/comment/32699179
type: AnswerComment
score: 0
type: Comment
has text: You said that you cannot use copy. So this solution is not making any copies. There is no constructor or `copy` method in my code. I'm only adding reference to object in my second list if news is from some category.
comment on: http://stackoverflow.com/a/21637386

http://stackoverflow.com/a/21648062
downvote count: 0
has body: You're trying to define twice the int number. Either remove the first declaration or change the line: int number = keyboard.nextInt(); with number = keyboard.nextInt(); You may also want to wrap the call in a try and catch to check for the expected exception coming from the Scanner.nextInt() method.
type: Answer
answers question: http://stackoverflow.com/q/21647995
upvote count: 2
score: 2

http://stackoverflow.com/q/21531333
answer count: 1
downvote count: 0
tagged with: events
tagged with: keyboard
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32512147
score: 6
has comment: http://stackoverflow.com/comment/32512486
upvote count: 6
tagged with: keyevent
has comment: http://stackoverflow.com/comment/32512401
tagged with: java
tagged with: swt
type: Question
has comment: http://stackoverflow.com/comment/32512541
has title: Custom Key Events
has body: How can I send a custom SWT key event such that it results in the typing of that exact literal character without any conversion? We are making a custom on-screen graphical keyboard that allows for multiple possible layouts - QWERTY being the main one, but several others planned, including ones that visually simulate the iPhone keyboard layout or others that are non-standard relative to the PC. I would like to be able to send any arbitrary character of my choosing as an event, such that it will result in the typing of that exact character. However, whenever I send an event with a given character, SWT seems to automatically interpret and convert it based on the system's keyboard settings and status, changing it to be capitalized/lowercase or using the shifted symbols depending on whether or not the shift key (the real one on the actual keyboard, for instance) is pressed. For instance, passing the character 'T' through a key event will result in either 't' or 'T' depending on the shift key. It performs similarly with the '4' character, doing either '4' or '$' based on shift. This is problematic, as I wish to perform the shifting of characters manually, and indeed may not wish to use the same shift characters as the standard QWERTY keyboard in any given case (perhaps, for instance, I want '$' to be the shifted (or 'function' key) version of 'R' on a smaller, cellphone-like keyboard). How can I use these events such that it does not assume the usage of QWERTY keys? The documentation for the 'character' field in the SWT events says the following: the character represented by the key that was typed. This is the final character that results after all modifiers have been applied. For example, when the user types Ctrl+A, the character value is 0x01. It is important that applications do not attempt to modify the character value based on a stateMask (such as SWT.CTRL) or the resulting character will not be correct. This makes me believe that it should not be converting my chara…
has answer: http://stackoverflow.com/a/21547194
has comment: http://stackoverflow.com/comment/32512356

http://stackoverflow.com/comment/32506487
score: 0
comment on: http://stackoverflow.com/a/21528427
type: Comment
has text: And no, not dependent on Guava, they just have a similar generic Optional class.
type: AnswerComment

http://stackoverflow.com/comment/32601527
comment on: http://stackoverflow.com/a/21581867
has text: See the very bottom of my answer. I added a line.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/21624156
has answer: http://stackoverflow.com/a/21624347
has answer: http://stackoverflow.com/a/21624271
accepted answer: http://stackoverflow.com/a/21624347
answer count: 4
has answer: http://stackoverflow.com/a/21624352
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21624271
has body: Consider: long n = Long.MAX_VALUE; ++n; With my JVM, this wraps round to Long.MIN_VALUE. Is this the defined behaviour? Will some JVMs throw an exception instead?
has title: Behaviour when incrementing a Java long past the maximum
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32675197
has answer: http://stackoverflow.com/a/21624427
score: 0

http://stackoverflow.com/a/21609447
downvote count: 1
answers question: http://stackoverflow.com/q/21609212
score: 0
type: Answer
upvote count: 1
has body: This will remove the first char ocurring in the String. Added a boolean to know if a char was already removed or not. String removeAll(char c, String s) { boolean removed = false; String to_return = ""; while(true) { if (s.equals("")) return to_return; // at this point s is not "" char c2 = s.charAt(0); if (c2 != c) { to_return += c2; } else { if(! removed) removed = true; else to_return += c2; } s = s.substring(1); } } Output example for removeAll('o',"oh, hello"): h, hello

http://stackoverflow.com/comment/32616151
type: QuestionComment
has text: @dvnrrs Thanks. In my googling to check out this question before I asked it I found a reference to `PATH`. That reference said it `java -version` works then java is in the `PATH`. My `java -version` does run. ||||| As for my problem, it could be totally non-Java related. I'm just trying to cover my Java-related bases so I can be sure it's not that. (given I know nothing about Java it's the hardest error to source, hence my ignorant question)
type: Comment
comment on: http://stackoverflow.com/q/21589631
score: 0

http://stackoverflow.com/comment/32675195
type: Comment
comment on: http://stackoverflow.com/a/21598861
has text: @ A Paul Hey can you tell me how to call a servlet which is in another project from a JSP page which is in other project.
score: 0
type: AnswerComment

http://stackoverflow.com/q/21583987
has body: This is the code in my arrayadapter that will set the RadioButtons status: public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; attendance_holder holder = null; People_Attendance people_array[] = people_attendance.toArray(new People_Attendance[people_attendance.size()]); if(row == null) { LayoutInflater inflater = ((Activity)context).getLayoutInflater(); row = inflater.inflate(layoutResourceId, parent, false); holder = new attendance_holder(); holder.txtName = (TextView)row.findViewById(R.id.name_txt); holder.txtNumber = (TextView)row.findViewById(R.id.number_txt); holder.attendance_group = row.findViewById(R.id.Attendance_Group); holder.not_attending = (RadioButton) holder.attendance_group.findViewById(R.id.not_attending_radio); holder.attending = (RadioButton) holder.attendance_group.findViewById(R.id.attending_radio); holder.invited = (RadioButton) holder.attendance_group.findViewById(R.id.invited_radio); row.setTag(holder); } else { holder = (attendance_holder)row.getTag(); } holder.txtName.setText(people_array[position].name); holder.txtNumber.setText(people_array[position].number); if (people_array[position].attendance_status == "INVITED"){ holder.invited.setChecked(true); }else if(people_array[position].attendance_status == "ATTENDING"){ holder.attending.setChecked(true); }else if(people_array[position].attendance_status == "NOT ATTENDING"){ holder.not_attending.setChecked(true); }else{ Log.d("ATTENDANCE", people_array[position].attendance_status); } return row; } I have used the Log.d() in my code to show the string, so I know it's not an empty string or bad string that's the problem. I would therefore think that either my if statements are wrong in someway, or that I am using RadioButton.setChecked() wrong. Then RadioButtons then do not get checked in the way they should do. The RadioButtons are in a RadioGroup. Any thoughts?? Thanks for the help!!
score: 0
linked to: http://stackoverflow.com/q/513832
answer count: 3
tagged with: radio-button
tagged with: string
possible better answer: http://stackoverflow.com/a/21584074
has comment: http://stackoverflow.com/comment/32607620
tagged with: android
has comment: http://stackoverflow.com/comment/32605222
has answer: http://stackoverflow.com/a/21584070
accepted answer: http://stackoverflow.com/a/21584070
type: AnsweredQuestion
has title: RadioButton.setChecked() doesn't appear to work
tagged with: java
has answer: http://stackoverflow.com/a/21584209
has answer: http://stackoverflow.com/a/21584074
type: Question
tagged with: if-statement
has comment: http://stackoverflow.com/comment/32608433

http://stackoverflow.com/a/48080179
downvote count: 0
score: 50
upvote count: 50
has body: Problem is that by definition putIfAbsent return old value and not new value (old value for absent is always null). Use computeIfAbsent - this will return new value for you. private static String get(final String key) { return map.computeIfAbsent(key, s -&gt; "value 3"); }
has comment: http://stackoverflow.com/comment/109919332
has comment: http://stackoverflow.com/comment/92035343
type: Answer
answers question: http://stackoverflow.com/q/21621803
has comment: http://stackoverflow.com/comment/92070564
has comment: http://stackoverflow.com/comment/109885040

http://stackoverflow.com/comment/32693463
score: 0
type: Comment
type: QuestionComment
has text: Can I suggest you put some logging into your application to see what is going on.
comment on: http://stackoverflow.com/q/21633997

http://stackoverflow.com/comment/118193372
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21638080
has text: 1<<30 means the 31th bit from the low, and 2nd bit from high. And this is the largest number of power of two of signed int in Java
score: 0

http://stackoverflow.com/comment/32680976
type: QuestionComment
has text: so you will go through all possible combinations, like (A,B,C,AB,AC,BC,ABC) if there are 3 fields A,B and C?
score: 0
comment on: http://stackoverflow.com/q/21626427
type: Comment

http://stackoverflow.com/q/21556736
has body: My application has plug in jars located in a folder of the main application src app_package modules //plug in jars located here My problem is I cant get the jars as files cause you cant have file objects when the main application is converted to a jar. Currently I am trying to obtain the jars by using an InputStream. Is there a way to use input stream to get the urls of all jars located in the modules folder? UPDATE I use java serviceloader in order to load the jar files. First I load all the jar files into file objects: File modules = new File("modules"); File[] fileList = providerFiles.listFiles(new FileFilter() { public boolean accept(File file) { return file.getPath().toLowerCase().endsWith(".jar"); } }); The next step is obtaining the urls using: URL[] urls = new URL[fileList.length]; for (int i = 0; i &lt; fileList.length; i++) urls[i] = fileList[i].toURI().toURL(); ucl = new URLClassLoader(urls); My problem is I realized I should use getResource() when accessing the jar files. However all I can accomplish is URL url = getClass().getResource(directory); InputStream inputStream = url.openConnection().getInputStream(); I am lost on how I can use the input stream to get the urls of all the jars.
answer count: 1
has comment: http://stackoverflow.com/comment/32556290
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21557412
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21557412
has title: Loading jar files dynamically using Inputstream
has comment: http://stackoverflow.com/comment/32556224
has comment: http://stackoverflow.com/comment/32556351
score: 0

http://stackoverflow.com/q/21609803
has comment: http://stackoverflow.com/comment/32650149
tagged with: java
tagged with: save
type: Question
tagged with: arrays
score: 0
has body: I'm working on a dice rolling project at the moment and would like to save my project to a .txt or .pdf file so I can graph it in excel. I just learned how to save a program as a file in my computer science class but I have a difficult time understanding my professor sometimes. Could someone point out what I'm missing and possibly explain the concept a little bit? I've tried to google some sort of explanation but all I need is the barebones explanation on how to save it to a file. import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.Random; import javax.swing.JOptionPane; public class Lab1 { private static int N = 0; private static int M = 0; private static Random rnd = new Random(); private final static int FACENUMBER = 6; static String output = "output.txt"; static File file = new File(output); public Lab1(){ } public static void main(String[] args) { N = Integer.parseInt(JOptionPane.showInputDialog("How many dice would you like to roll?")); System.out.println("Dice: "+N); M = Integer.parseInt(JOptionPane.showInputDialog("How many times would you like to roll?")); System.out.println("Rolls: "+M); System.out.println(); int total[] = new int[(M)+1]; for (int roll=1; roll&lt;=M; roll++){ total[roll] = rnd.nextInt((FACENUMBER-1)*N)+N; } System.out.printf("%3s%12s\n", "Rolls"," Sum of Rolls"); for(int k=1; k&lt;total.length; k++){ System.out.printf("%3s%12s\n", k, total[k]); } try{ BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.write(output); writer.close(); }catch(IOException e){ System.out.println("Can't open "+output); return; } } }
has title: Saving results to a text file
answer count: 1
has comment: http://stackoverflow.com/comment/32650638
type: UnansweredQuestion
tagged with: format
has answer: http://stackoverflow.com/a/21609995

http://stackoverflow.com/q/21542358
downvote count: 0
tagged with: arraylist
type: AnsweredQuestion
score: 3
tagged with: android
tagged with: sqlite
accepted answer: http://stackoverflow.com/a/21546366
favorite count: 0
possible better answer: http://stackoverflow.com/a/21542430
type: Question
has comment: http://stackoverflow.com/comment/32536648
answer count: 2
has answer: http://stackoverflow.com/a/21542430
has title: How to insert Arraylist into sqlite in Android ?
upvote count: 3
has body: I want to insert Arraylist into my sqlite without same value in anggota coloumn that have same id as below : helper=new DBSpaj(getActivity()); for (int i=0; i&lt;ListKeluargaPP.size();i++) { helper.insertTableMarital( a, ListKeluargaPP.get(i).getAnggota_pp(), ListKeluargaPP.get(i).getNama_Anggota_pp(), ListKeluargaPP.get(i).getTtl_Anggota_pp() ); This is my insert code : public void insertTableMarital( String master_id, String anggota, String nama, String ttl ) { String selectQuery = "SELECT master_id,anggota FROM table_marital " + "where master_id='"+Menu_SPPAJ.getX()+"'"; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.equals(null)){ ContentValues cv=new ContentValues(); cv.put("master_id", master_id); cv.put("anggota", anggota); cv.put("nama", nama); cv.put("ttl", ttl); getWritableDatabase().insert("table_marital",null, cv); } if (cursor.getString(1)!=PemegangPolis.getStrAnggota()){ ContentValues cv=new ContentValues(); cv.put("master_id", master_id); cv.put("anggota", anggota); cv.put("nama", nama); cv.put("ttl", ttl); getWritableDatabase().insert("table_marital",null, cv); }else { System.out.println("udah ada"); } } I got errors when I want to save it, and the logcat said as below : 02-04 10:15:31.274: E/AndroidRuntime(17174): FATAL EXCEPTION: main 02-04 10:15:31.274: E/AndroidRuntime(17174): android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 0 02-04 10:15:31.274: E/AndroidRuntime(17174): at android.database.AbstractCursor.checkPosition(AbstractCursor.java:418) 02-04 10:15:31.274: E/AndroidRuntime(17174): at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136) 02-04 10:15:31.274: E/AndroidRuntime(17174): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50) 02-04 10:15:31.274: E/AndroidRuntime(17174): at id.co.ajsmsig.espaj.DBSpaj.insertTableMarital(DBSpaj.java:912) 02-04 10:15:31.274: E/AndroidRuntime(171…
tagged with: java
has comment: http://stackoverflow.com/comment/32532923
has answer: http://stackoverflow.com/a/21546366
has comment: http://stackoverflow.com/comment/32537097

internationalization
tags question: http://stackoverflow.com/q/21534704
tags question: http://stackoverflow.com/q/21538462
type: Tag
tags question: http://stackoverflow.com/q/21553540
tags question: http://stackoverflow.com/q/21580638
tag name: internationalization
tags question: http://stackoverflow.com/q/21526200

http://stackoverflow.com/a/21521280
has body: Change it to: BigDecimal dec = new BigDecimal(input).setScale(3, BigDecimal.ROUND_HALF_EVEN);
type: Answer
answers question: http://stackoverflow.com/q/21521213
score: 0

forms
tags question: http://stackoverflow.com/q/21553290
type: Tag
tags question: http://stackoverflow.com/q/21597534
tags question: http://stackoverflow.com/q/21595719
tag name: forms

http://stackoverflow.com/a/21638866
accepted answer of: http://stackoverflow.com/q/21638808
upvote count: 5
has comment: http://stackoverflow.com/comment/32701810
has comment: http://stackoverflow.com/comment/32701943
answers question: http://stackoverflow.com/q/21638808
has body: The recursive loop is caused by the statement return WriteArray().toString(); at the end of the WriteArray() method. If you want the method to just print what it prints, then you should declare it as void, i.e. public static void WriteArray() Otherwise, you need to save all the printed lines as they are printed, e.g. public static String WriteArray() { StringBuilder sb = new StringBuilder(); // Buffer to store the printed lines for (int i = 0; i &lt; 2; i++) { for (String lines : ArrayColors()) { switch (i) { case 0: lines = lines.replace("Red", "Blood"); break; case 1: lines = lines.replace("Blue", "Ocean"); break; case 2: lines = lines.replace("Green", "Giant"); break; } System.out.println(lines); sb.append(lines); // Store the printed line } System.out.println(); sb.append("\n"); // Store a blank line } return sb.toString(); } Some other possible improvements: You don't need a method to access the colors, so you can put the MyColors variable directly in the loop, i.e. for (String lines : MyColors). If you still want to use a method, don't declare MyColors at all and return the { "Red", "Blue", "Green"} value directly. Try to follow Java naming conventions: only class names start with a capital letter, everything else starts with a lowercase letter, e.g. it should be arrayColors and not ArrayColors.
type: AcceptedAnswer
downvote count: 0
score: 5
type: Answer
has comment: http://stackoverflow.com/comment/32701786
has comment: http://stackoverflow.com/comment/32701983
has comment: http://stackoverflow.com/comment/32701863

http://stackoverflow.com/q/21625054
type: Question
answer count: 1
has comment: http://stackoverflow.com/comment/32679119
score: 0
has body: I am trying get all of my contacts from the ContactsConstract table through a ContentProvider in a query and save it to my own SQLite database, but I encountered a SQLiteException in getting this. At start I just wrote a query for getting data from contacts. Plz help me and suggest me how to get data and store into my own data base. Here is my source code: public class WebpreneurActivity extends ListActivity { private static final int CONTACT_CREATE = 0; private static final int CONTACT_EDIT = 1; public static long id1; //select the second one, Android view menu private static final int INSERT_ID = Menu.FIRST; private static final int DELETE_ID = Menu.FIRST + 1; private DBHandler dbHelper; private Cursor c; ImageButton imageButton; public static long rowId; @Override protected void onCreate(Bundle savedInstanceState) { Log.d("database1" ,"0"); Log.d("Your Location4", "ok4:"); super.onCreate(savedInstanceState); Log.d("database1" ,"1"); setContentView(R.layout.activity_webpreneur); Log.d("database1" ,"2"); //dbHelper = new DBHandler(this); Log.d("database1" ,"3"); // dbHelper.open(); **ContentResolver cr = getContentResolver(); c = cr.query( Data.CONTENT_URI, null, Data.HAS_PHONE_NUMBER + "!=0 AND (" + Data.MIMETYPE + "=? OR " + Data.MIMETYPE + "=?)", new String[]{Email.CONTENT_ITEM_TYPE, Phone.CONTENT_ITEM_TYPE}, Data.CONTACT_ID); while (c.moveToNext()) { long id = c.getLong(c.getColumnIndex(Data.CONTACT_ID)); String name = c.getString(c.getColumnIndex(Data.DISPLAY_NAME)); String data1 = c.getString(c.getColumnIndex(Data.DATA1)); System.out.println(id + ", name=" + name + ", data1=" + data1); }** } And my logcat is here: 02-07 15:08:32.827: D/database1(16568): 0 02-07 15:08:32.827: D/Your Location4(16568): ok4: 02-07 15:08:32.837: D/database1(16568): 1 02-07 15:08:32.977: D/database1(16568): 2 02-07 15:08:32.977: D/database1(16568): 3 02-07 15:08:33.027: D/AndroidRuntime(16568): Shutting down VM 02-07 15:08:33.027: W/dalvikvm(16568): threadid=1: thread exiting with …
tagged with: sqlite
tagged with: contactscontract
has answer: http://stackoverflow.com/a/21625334
accepted answer: http://stackoverflow.com/a/21625334
tagged with: android
has comment: http://stackoverflow.com/comment/32676904
has comment: http://stackoverflow.com/comment/32677297
type: AnsweredQuestion
tagged with: java
has title: Getting SQLITE Exception in getting data from ContactsContract table

http://stackoverflow.com/a/54204368
has body: I've just needed to do something similar. After a lot of playing around I was able to come up with this: final Bus bus = CXFBusFactory.getDefaultBus(); final ServerRegistry serverRegistry = bus.getExtension(ServerRegistry.class); final List&lt;Server&gt; servers = serverRegistry.getServers(); return servers.stream().map(s -&gt; s.getEndpoint().getService()) .filter(s -&gt; JAXRSServiceImpl.class.isAssignableFrom(s.getClass())).map(JAXRSServiceImpl.class::cast) .map(JAXRSServiceImpl::getClassResourceInfos).flatMap(Collection::stream) .map(ClassResourceInfo::getResourceClass).collect(Collectors.toSet()); It looks up all of service classes (not the instances, unfortunatly) but for my use case (and posably yours also, the class was sufficient)
score: 0
answers question: http://stackoverflow.com/q/21515313
type: Answer

http://stackoverflow.com/q/21578853
has title: Operations with BigDecimal and double in Java
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32596209
has answer: http://stackoverflow.com/a/29210350
linked to: http://stackoverflow.com/q/12218515
possible better answer: http://stackoverflow.com/a/21578938
downvote count: 0
tagged with: bigdecimal
has answer: http://stackoverflow.com/a/21578938
tagged with: variables
has comment: http://stackoverflow.com/comment/32595761
has answer: http://stackoverflow.com/a/21578963
has answer: http://stackoverflow.com/a/21579626
has body: I am trying to use Advogadro's number (6.022*10^23) in a java program and i use BigDecimal variable to store it. However i want to multiply it with an int or a double and still keep the precision, but it throws an error! bad operand types for binary operator '*' first type: double second type: BigDecimal Is there any simple way to do that? Also is there a way to print the result in scientific notation? Thanks in advance!
has answer: http://stackoverflow.com/a/21578934
has comment: http://stackoverflow.com/comment/32595797
answer count: 7
has answer: http://stackoverflow.com/a/74434011
favorite count: 0
has comment: http://stackoverflow.com/comment/32596282
accepted answer: http://stackoverflow.com/a/21578934
upvote count: 2
has comment: http://stackoverflow.com/comment/32600462
tagged with: double
has answer: http://stackoverflow.com/a/71518207
score: 2
type: AnsweredQuestion

http://stackoverflow.com/comment/32571184
has text: Each "Card" needs to be it's own object, which knows how to paint itself and where it should be painted (and it's how big it should be painted). This should separated into some kind of model for easier interactions. Then in you `paintComponent` method, you visualise this...
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21545615

http://stackoverflow.com/comment/32749221
type: AnswerComment
comment on: http://stackoverflow.com/a/21663815
score: 0
has text: Got it. Thanks a lot! Awesome, comprehensive answer.
type: Comment

http://stackoverflow.com/comment/32672424
comment on: http://stackoverflow.com/q/21622570
has text: Are you referring to linking files on a web server or from your personal machine?
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32815896
has text: @davmac Sure it does. It explains at length why that question cannot be answered in general, but only for a certain java compiler.
type: Comment
comment on: http://stackoverflow.com/a/21676422
type: AnswerComment
score: 0

http://stackoverflow.com/q/21523086
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32497502
has answer: http://stackoverflow.com/a/21523203
type: Question
has answer: http://stackoverflow.com/a/21523779
tagged with: java
has answer: http://stackoverflow.com/a/21523119
answer count: 3
has body: I just started learning Java... I need to input a txt. full of words and then output a histogram listing out the frequency by the length of the words. e.g.Length 0 1 2 3 4 // Frequency 0 20 6 1 0 // public static void main( String args[] ) throws Exception { if(args.length == 0) { System.out.println("blablabla"); } BufferedReader inFile = new BufferedReader ( new FileReader ( args[0] ) ); String[] wordList = new String[10]; // store the words int[] histogram = new int[5];// frequency counters int wordCnt = 0; while (inFile.ready()) { String word = inFile.readLine(); if ( word.length == wordCnt) { histogram[wordCnt]++; } if (wordCnt == wordList.length){ wordList = doubleTheArray(wordList); } wordList[wordCnt++] = word; } inFile.close(); wordList=trim(wordList); Q1: I'm not sure if I should put wordList=trim(wordList); in front of inFile.close(); System.out.printf( "List contains %d Strings.\n",wordList.length); System.out.println("LEN\tFREQ"); for ( int i = 0; i &lt; histogram.length ; ++i) // System.out.printf( "%2d\t%d\n",i,histogram[i] ); } // END MAIN Q2: I have trouble getting histogram[i]. Anyone can give me a hint?
tagged with: string
score: 0
has title: how to find the length of the string java

http://stackoverflow.com/comment/32640779
score: 0
type: Comment
type: QuestionComment
has text: Replace the `{}`'s with single-quotes `'` and you'll be fine, or use `PreparedStatement`'s and the `setString()`method instead.
comment on: http://stackoverflow.com/q/21604580

http://stackoverflow.com/comment/32623451
score: 1
has text: Try to use a profiler. Commercial( YourKit, jprofiler,...) or VisualVm(free)
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21594071

http://stackoverflow.com/comment/32690227
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/21632760
type: Comment
has text: That's from Apache Commons library.

http://stackoverflow.com/q/21592547
has title: Neither user 10031 nor current process has android.permission.INSTALL_PACKAGES
type: Question
answer count: 1
score: 0
tagged with: android
has body: I want to use PackageManager to install self apk, but I have some problems. Here is the code I am using: PackageManager pm = getPackageManager(); pm.installPackage(Uri.fromFile(file), null, PackageManager.INSTALL_REPLACE_EXISTING, pakcageName); Here is the exception: java.lang.SecurityException: Neither user 10031 nor current process has android.permission.INSTALL_PACKAGES. at android.os.Parcel.readException(Parcel.java:1322) at android.os.Parcel.readException(Parcel.java:1276) at android.content.pm.IPackageManager$Stub$Proxy.installPackage(IPackageManager.java:1951) at android.app.ContextImpl$ApplicationPackageManager.installPackage(ContextImpl.java:2549)
type: UnansweredQuestion
tagged with: android-package-managers
has answer: http://stackoverflow.com/a/21592718
tagged with: java

http://stackoverflow.com/a/21619048
score: 1
answers question: http://stackoverflow.com/q/21618921
has body: If you are not taking so many inputs from user then you can create a simple AlertDialog for getting those values on every item selected from Spinner or if there are lot of inputs needed then you should call a separate activity for that.
upvote count: 1
downvote count: 0
type: Answer

http://stackoverflow.com/a/21658200
has comment: http://stackoverflow.com/comment/32735262
type: Answer
has comment: http://stackoverflow.com/comment/32735125
score: 7
answers question: http://stackoverflow.com/q/21658187
upvote count: 7
has comment: http://stackoverflow.com/comment/32735171
has comment: http://stackoverflow.com/comment/32735416
accepted answer of: http://stackoverflow.com/q/21658187
has comment: http://stackoverflow.com/comment/32735451
has comment: http://stackoverflow.com/comment/32735164
has body: All of your methods are themselves generic. So, they have their own type parameter, that have nothing to do with the one declared with your class. The below method declaration is generic: public &lt;T&gt; boolean insertHead(T newEntry) So, whatever parameterized instance of the class you create, the method will accept any argument type, and type T for this method will be inferred as that type. To solve the issue, you should remove &lt;T&gt; part from every method. Change for example, above method to: public boolean insertHead(T newEntry) Also, your methods should have a return type of T instead of Object, else that would fail at the caller end. Change the method: public &lt;T&gt; Object get(int givenPosition) { if ((givenPosition &gt;= 1) &amp;&amp; (givenPosition &lt;= size)) return contents[givenPosition - 1]; return null; } to: public T get(int givenPosition) { if ((givenPosition &gt;= 1) &amp;&amp; (givenPosition &lt;= size)) return (T) contents[givenPosition - 1]; // Add cast return null; }
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32735382
has comment: http://stackoverflow.com/comment/32735080
has comment: http://stackoverflow.com/comment/32735064
has comment: http://stackoverflow.com/comment/32735245

http://stackoverflow.com/comment/32722645
comment on: http://stackoverflow.com/q/21651176
type: Comment
type: QuestionComment
score: 0
has text: Yep, I agree with @MartinDinov, and it looks like some careless mistakes are happening here.

http://stackoverflow.com/a/21555423
accepted answer of: http://stackoverflow.com/q/21555040
has comment: http://stackoverflow.com/comment/32553659
answers question: http://stackoverflow.com/q/21555040
type: Answer
has body: It can't be related to performance, actually: All the methods delegate to the same creation method, which expects an array anyhow. My guess is that it is related to warnings. Consider the following, minimal snippet: import java.util.List; class ImmutableSet&lt;T&gt; { } public class ParametersTest { public static void main(String[] args) { List&lt;String&gt; list0 = null; List&lt;String&gt; list1 = null; of(list0, list1); } @SuppressWarnings("unchecked") public static &lt;E&gt; ImmutableSet&lt;E&gt; of(E e1, E e2) { return create(e1, e2); } public static &lt;E&gt; ImmutableSet&lt;E&gt; of(E... elements) { return create(elements); } private static &lt;E&gt; ImmutableSet&lt;E&gt; create(E... elements) { return null; } } The call to of in the main method is fine: It matches the 2-args-version of the of method. Now comment out the 2-args-version of the of-method. Then the call is still OK, but will directly invoke the varags version. This will cause a generic array to be created, and cause a warning. (This warning is suppressed in the 2-args-version, obviously). So to summarize, I assume that this is in order to avoid warnings for clients of the library who want to invoke the of method with several objects of a generic type. Fortunately, things like this will no longer be necessary in the future, thanks to http://docs.oracle.com/javase/7/docs/api/java/lang/SafeVarargs.html
score: 4
upvote count: 4
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/21535648
tagged with: http://stackoverflow.com/tag/xml
tagged with: java
has answer: http://stackoverflow.com/a/21535990
upvote count: 1
type: Question
has body: I created a java xml parser which almost stores the data succesfully, atleast first time its called. It creates version number, UTF and the "tree", which its supposed to do. But second time the method is called, it simply creates a new "tree" and version, which it aint supposed to do (doesnt override, look attached picture! What i need the xml parser to do is, first time the method is called, it will make the version, UTF, and the "tree". Next time its called, it will just add the data into a new "songs" node. I apologize for my English, but i hope its explained clear enough. Else, please ask further in the comments, its easier for me to explain using comments! link to picture Code: public class Song { List&lt;String[]&gt; songs = new ArrayList&lt;String[]&gt;(); public void addSong(String s, String a, String yt){ String[] songarray= new String[3]; songarray[0] = s; songarray[1] = a; songarray[2] = yt; songs.add(songarray); saveSong(songarray); } public void editSong(int i, String s, String a, String yt){ String[] editsongarray = new String[3]; editsongarray[0] = s; editsongarray[1] = a; editsongarray[2] = yt; songs.remove(i); songs.add(i,editsongarray); } public void removeSong(int i){ songs.remove(i); } public String[] getList(int i){ String[] j = songs.get(i); return j; } public void saveSong(String[] songl){ try{ DocumentBuilderFactory song = DocumentBuilderFactory.newInstance(); DocumentBuilder songBuilder = song.newDocumentBuilder(); Document doc = songBuilder.newDocument(); Element playlist = doc.createElement("playlist"); doc.appendChild(playlist); Element songs = doc.createElement("songs"); playlist.appendChild(songs); Attr attr = doc.createAttribute("index"); attr.setValue("1"); playlist.setAttributeNode(attr); Element name = doc.createElement("name"); name.appendChild(doc.createTextNode(songl[0])); songs.appendChild(name); Element artistname = doc.createElement("artistname"); artistname.appendChild(doc.createTextNode(songl[1])); songs.appendChild(artistna…
has title: Java xml parser passes wrong
downvote count: 0
answer count: 1
score: 1
favorite count: 0
type: UnansweredQuestion

http://stackoverflow.com/comment/32493998
has text: Please format your code. It's horrible to read now.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21521378
type: Comment

http://stackoverflow.com/a/35985985
has body: for those who like methods: import java.util.*; public class MatmultD { private static Scanner sc = new Scanner(System.in); public static void main(String [] args) { int a[][] = {{1, 2, -2, 0}, {-3, 4, 7, 2}, {6, 0, 3, 1}}; int b[][] = {{-1, 3}, {0, 9}, {1, -11}, {4, -5}}; int[][] c=multMatrix(a,b); printMatrix(a); printMatrix(b); printMatrix(c); } public static int[][] readMatrix() { int rows = sc.nextInt(); int cols = sc.nextInt(); int[][] result = new int[rows][cols]; for (int i = 0; i &lt; rows; i++) { for (int j = 0; j &lt; cols; j++) { result[i][j] = sc.nextInt(); } } return result; } public static void printMatrix(int[][] mat) { System.out.println("Matrix["+mat.length+"]["+mat[0].length+"]"); int rows = mat.length; int columns = mat[0].length; for (int i = 0; i &lt; rows; i++) { for (int j = 0; j &lt; columns; j++) { System.out.printf("%4d " , mat[i][j]); } System.out.println(); } System.out.println(); } public static int[][] multMatrix(int a[][], int b[][]){//a[m][n], b[n][p] if(a.length == 0) return new int[0][0]; if(a[0].length != b.length) return null; //invalid dims int n = a[0].length; int m = a.length; int p = b[0].length; int ans[][] = new int[m][p]; for(int i = 0;i &lt; m;i++){ for(int j = 0;j &lt; p;j++){ for(int k = 0;k &lt; n;k++){ ans[i][j] += a[i][k] * b[k][j]; } } } return ans; } } and the output look like Matrix[3][4] 1 2 -2 0 -3 4 7 2 6 0 3 1 Matrix[4][2] -1 3 0 9 1 -11 4 -5 Matrix[3][2] -3 43 18 -60 1 -20
type: Answer
answers question: http://stackoverflow.com/q/21547462
score: 0

http://stackoverflow.com/q/21528938
tagged with: garbage-collection
has body: I have the following format in a class called Extract. This class has a main method that is supposed to read lines from a text file and output them to another text file. This is the overview: Public class Extract{ public static void main(String[] args){ try{ Scanner br = new Scanner(new FileInputStream(file_from)); // read from file Printwriter out = new PrintWriter ( new BufferedWriter (file_to))); // File to write to while(br.hasNextLine()) { ArrayList&lt;String&gt; sentences = new ArrayList&lt;String&gt;(); String some_sentence; for (int i = 0 ; i &lt; 1000 ; i++) { some_sentence = br.nextLine(); if (some_sentence != null){ sentence.add(some_sentence); } } for (int i = 0 ; i &lt; sentences.size() ; i++) { some_sentence = sentences.get(i); // prepare sentence to be parsed Tree parsed = lp.parse(some_sentence); TreebankLanguagePack tlp = new PennTreebankLanguagePack(); GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory(); GrammaticalStructure gs = gsf.newGrammaticalStructure(parsed); Collection&lt;TypedDependency&gt; tdl = gs.typedDependencies(); Iterator&lt;TypedDependency&gt; itr = tdl.iterator(); out.println(some_sentence); out.println("\n"); System.out.println(++count); while (itr.hasNext()) { TypedDependency temp = itr.next(); out.println(temp); } } } } catch (Exception e) { System.out.println("Something failed"); e.printStackTrace(); } } } Given that I am initializing the array sentences with 1000 new strings in each iteration of the while loop, could this cause my program to stop running? My program is exiting with the following error message: NOT ENOUGH MEMORY TO PARSE SENTENCES OF LENGTH 500 Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at edu.stanford.nlp.parser.lexparser.ExhaustivePCFGParser.createArrays(ExhaustivePCFGParser.java:2203) at edu.stanford.nlp.parser.lexparser.ExhaustivePCFGParser.considerCreatingArrays(ExhaustivePCFGParser.java:2173) at edu.stanford.nlp.parser.lexparser.ExhaustivePCFGParser.parse(Exhau…
type: Question
has answer: http://stackoverflow.com/a/21529187
accepted answer: http://stackoverflow.com/a/21529187
score: 0
has comment: http://stackoverflow.com/comment/32507277
answer count: 1
has comment: http://stackoverflow.com/comment/32507435
has comment: http://stackoverflow.com/comment/32507465
has comment: http://stackoverflow.com/comment/32507854
type: AnsweredQuestion
has title: Program stops running possibly because of garbage collection problems
has comment: http://stackoverflow.com/comment/32507445
tagged with: java

http://stackoverflow.com/comment/32594239
type: AnswerComment
comment on: http://stackoverflow.com/a/21577658
score: 0
type: Comment
has text: There is. How can that change my jLabel's Icon? I want my jLabel's icon to change when my mouse overlaps a button.

http://stackoverflow.com/comment/33214039
comment on: http://stackoverflow.com/a/21613903
type: AnswerComment
type: Comment
has text: I tried and it seems to be working, no duplicate issue. But messages with same UOO went to different node in cluster environment. Is it expected?
score: 0

http://stackoverflow.com/comment/32638856
type: Comment
has text: Have you checked the Base64 class in the commons-codec library version 20041127.091804 and made sure the method `encodeBase64String` is avaialble in that version?
comment on: http://stackoverflow.com/q/21603085
score: 0
type: QuestionComment

http://stackoverflow.com/comment/32712797
comment on: http://stackoverflow.com/a/21645052
has text: It wouldn't compile, you've to use `\\` as others have used.
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32705290
comment on: http://stackoverflow.com/q/21640759
score: 0
type: QuestionComment
has text: What you want is to make a decision - whether or not to enter a middle name. Decision making in programming is achieved with an `if` statement. There may be some workarounds possible but without _really_ trying at it, I don't see a way.
type: Comment

http://stackoverflow.com/a/21560368
score: 0
answers question: http://stackoverflow.com/q/21528651
type: Answer
has body: Possibly you need to make the following change: @WebFault( name = "MBFault", targetNamespace = "http://fault" ) See more in Java API for XML Web Services Annotations.
has comment: http://stackoverflow.com/comment/32911598

http://stackoverflow.com/q/21664566
tagged with: java
has body: Ignore the arguments being passed into the method. My code: public static void setEnabled(EntityPlayer p, Boolean b){ try{ FileReader fileReader = new FileReader(SLInfo.STORAGEFILE); BufferedReader bufferedReader = new BufferedReader(fileReader); FileWriter fileWriter = new FileWriter(SLInfo.STORAGEFILE); BufferedWriter bufferedWriter = new BufferedWriter(fileWriter); String line = null; boolean breakearly = false; bufferedWriter.write("HeLlo"); bufferedWriter.newLine(); bufferedWriter.write("World!"); System.out.println("GOT TO THIS FRICKIN POINT"); while((line = bufferedReader.readLine()) != null){ System.out.println(line); Thread.sleep(2000); } bufferedReader.close(); bufferedWriter.close(); }catch(Exception e){e.printStackTrace();} } This is simply outputting "GOT TO THIS FRICKIN POINT" (I decided this string in my fury). I have no idea why. In my file, it shows: "Hello" "World" I just don't get it. EDIT: Cool. I didn't know that. Unfortunately, that was just a simple example that I thought would solve my problem... it didn't. Taking a look at my code below, and assuming that the file contains p.username, which is a string, on line 1, why is "got here" never printed and "did this" always printed. What I expected it to do: If p.username is on line x, it changes line x to read "p.username booleanvalue" and if p.username is not anywhere in the file, "p.username booleanvalue" is appended to the last line in the file. public static void setEnabled(EntityPlayer p, Boolean b){ try{ FileReader fileReader = new FileReader(SLInfo.STORAGEFILE); BufferedReader bufferedReader = new BufferedReader(fileReader); FileWriter fileWriter = new FileWriter(SLInfo.STORAGEFILE); BufferedWriter bufferedWriter = new BufferedWriter(fileWriter); String line = null; boolean breakearly = false; while((line = bufferedReader.readLine()) != null) { System.out.println(line); if (line.contains(p.username)){ System.out.println("Got here"); bufferedWriter.write(p.username + " " + Boolean.toString(b…
tagged with: bufferedreader
type: UnansweredQuestion
answer count: 4
score: 3
has title: Java: while((line = bufferedReader.readLine()) != null) MISSING 2 LINES
downvote count: 0
has answer: http://stackoverflow.com/a/21664618
favorite count: 0
has answer: http://stackoverflow.com/a/21664670
type: Question
has comment: http://stackoverflow.com/comment/32746428
has answer: http://stackoverflow.com/a/21664652
tagged with: readline
has answer: http://stackoverflow.com/a/21664609
upvote count: 3

http://stackoverflow.com/q/21595590
type: UnansweredQuestion
has body: I have Login JButton on a panel and I need to execute it when I press ENTER key. Do we have any code snippet for that?
linked to: http://stackoverflow.com/q/7456227
has comment: http://stackoverflow.com/comment/32627086
has comment: http://stackoverflow.com/comment/32626417
tagged with: keyevent
has title: Execute JButton when ENTER key is pressed in panel - Swing
has comment: http://stackoverflow.com/comment/32626993
tagged with: java
has comment: http://stackoverflow.com/comment/32630168
has comment: http://stackoverflow.com/comment/32626624
score: -4
has comment: http://stackoverflow.com/comment/32647207
upvote count: 1
tagged with: swing
tagged with: jbutton
type: Question
has answer: http://stackoverflow.com/a/21602179
downvote count: 5
has comment: http://stackoverflow.com/comment/32627067
has comment: http://stackoverflow.com/comment/32626470
answer count: 2
has answer: http://stackoverflow.com/a/21603011
favorite count: 0
has comment: http://stackoverflow.com/comment/32627129

http://stackoverflow.com/comment/32710704
comment on: http://stackoverflow.com/q/21644142
type: QuestionComment
type: Comment
has text: I'd like the question to focus on the relevant code rather than imports and other (typically) irrelevant things. I'd expect someone with the same problem to be able to at least create a `JTable` without me having to show them how to do it.
score: 0

http://stackoverflow.com/comment/32672902
has text: I'm not using a container though?
comment on: http://stackoverflow.com/a/21622800
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/21550238
tagged with: spring
tagged with: spring-mvc
score: 2
upvote count: 2
tagged with: java
has body: I have to bind an abstract class to my controller request handler method. Before I instantiate the concrete class with @ModelAttribute annotated method: @ModelAttribute("obj") public AbstractObh getObj(final HttpServletRequest request){ return AbstractObj.getInstance(myType); } But now I try to do that without the @ModelAttribute annotated method, beacause every call to controller trigger model attribute annotated method too. So I try to get concrete class with InitBinder and a custom editor, but it doesn't work. My Init Binder: @InitBinder(value="obj") protected void initBinder(final WebDataBinder binder) { binder.registerCustomEditor(AbstractObj.class, new SchedaEditor()); } And My Post Handler: @RequestMapping(method = RequestMethod.POST) public String create(@Valid @ModelAttribute("obj") AbstractObj obj, final BindingResult bindingResult) { //my handler } This is my ObjEditor: @Override public void setAsText(final String text) throws IllegalArgumentException { try{ if(text == null){ setValue(new ConcreteObj()); }else{ setValue(objService.findById(Long.valueOf(text))); } }catch(Exception e) { setValue(null); } }
tagged with: model-binding
type: Question
has title: How instantiate a concrete class in init binder?
answer count: 1
downvote count: 0
has answer: http://stackoverflow.com/a/21550582
favorite count: 0
type: UnansweredQuestion

http://stackoverflow.com/a/21545981
has comment: http://stackoverflow.com/comment/139724906
has comment: http://stackoverflow.com/comment/32537374
upvote count: 83
downvote count: 1
has body: Shorter than above code will be this line: return str.replaceFirst("^abc", ""); But in terms of performance I guess there wont be any substantial difference between 2 codes. One uses regex and one doesn't use regex but does search and substring.
has comment: http://stackoverflow.com/comment/32537597
answers question: http://stackoverflow.com/q/21545933
has comment: http://stackoverflow.com/comment/32537262
has comment: http://stackoverflow.com/comment/32537573
score: 82
has comment: http://stackoverflow.com/comment/32537291
type: Answer

http://stackoverflow.com/comment/32733931
comment on: http://stackoverflow.com/a/21657573
type: AnswerComment
has text: thanks Jigar. This really makes me feel stupid. But what i was trying to do was create an 2D array from aTwoD[1][1] to aTwoD[2][2]. That is why i was using "<=" and N = 2. Is there a special way of doing that ?
score: 0
type: Comment

http://stackoverflow.com/q/21517889
favorite count: 0
has comment: http://stackoverflow.com/comment/32488324
tagged with: android
has title: Libgdx override keyDown using InputMultiplexer in Screen
has comment: http://stackoverflow.com/comment/32488358
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/21569899
type: AnsweredQuestion
tagged with: libgdx
tagged with: java
has answer: http://stackoverflow.com/a/21518127
has body: I have a screen and have created a new multiplexer and set an input processor. How can I override keyDown on my screen? public class Screen implements Screen, TextInputListener { ...stuff... public Screen(Game game) { multiplexer = new InputMultiplexer(); multiplexer.addProcessor(mySystem); multiplexer.addProcessor(aStage); Gdx.input.setInputProcessor(multiplexer); } ...more stuff.... } Thanks
answer count: 2
has comment: http://stackoverflow.com/comment/32488391
downvote count: 0
score: 1
possible better answer: http://stackoverflow.com/a/21518127
accepted answer: http://stackoverflow.com/a/21569899

http://stackoverflow.com/q/21613204
has comment: http://stackoverflow.com/comment/32658218
has comment: http://stackoverflow.com/comment/32656885
type: Question
has comment: http://stackoverflow.com/comment/32656723
linked to: http://stackoverflow.com/q/1532819
has answer: http://stackoverflow.com/a/21616505
tagged with: algorithm
score: -2
has comment: http://stackoverflow.com/comment/32656965
tagged with: arrays
has comment: http://stackoverflow.com/comment/32658967
has body: I am working on this famous interview question on removing duplicate elements in array without using auxillary storage and preserving the order; I have read a bunch of posts; Algorithm: efficient way to remove duplicate integers from an array, Removing Duplicates from an Array using C. They are either implemented in C (without explanation) or the Java Code provided just fails when there is consecutive duplicates such as [1,1,1,3,3]. I am not quite confident with using C, my background is Java. So I implemented the code myself; it follows like this: use two loops, the outer-loop traverses the array and inner loop checks for duplicates and if present replace it with null. Then I go over the duplicate-replaced-null array and remove null elements and replacing it with the next non-null element. The total run-time I see now is O(n^2)+O(n) ~ O(n^2). Reading the above posts, I understood this is the best we can do, if no sorting and auxiliary storage is allowed. My code is here: I am looking for ways to optimize any further (if there is a possibility) or a better/simplisitc logic; public class RemoveDup { public static void main (String[] args){ Integer[] arr2={3,45,1,2,3,3,3,3,2,1,45,2,10}; Integer[] res= removeDup(arr2); System.out.println(Arrays.toString(res)); } private static Integer[] removeDup(Integer[] data) { int size = data.length; int count = 1; for (int i = 0; i &lt; size; i++) { Integer temp = data[i]; for (int j = i + 1; j &lt; size &amp;&amp; temp != null; j++) { if (data[j] == temp) { data[j] = null; } } } for (int i = 1; i &lt; size; i++) { Integer current = data[i]; if (data[i] != null) { data[count++] = current; } } return Arrays.copyOf(data, count); } } EDIT 1; Reformatted code from @keshlam throws ArrayIndexOutofBound Exception: private static int removeDupes(int[] array) { System.out.println("method called"); if(array.length &lt; 2) return array.length; int outsize=1; // first is always kept for (int consider = 1; consider &lt; array.length; ++conside…
accepted answer: http://stackoverflow.com/a/21615110
has comment: http://stackoverflow.com/comment/32657709
possible better answer: http://stackoverflow.com/a/21613911
downvote count: 2
has comment: http://stackoverflow.com/comment/32658169
has comment: http://stackoverflow.com/comment/32660294
has comment: http://stackoverflow.com/comment/32657472
has comment: http://stackoverflow.com/comment/32656929
linked to: http://stackoverflow.com/q/9613960
has comment: http://stackoverflow.com/comment/32657350
has comment: http://stackoverflow.com/comment/32657627
favorite count: 0
has answer: http://stackoverflow.com/a/21615110
has comment: http://stackoverflow.com/comment/32657085
has comment: http://stackoverflow.com/comment/32656702
has comment: http://stackoverflow.com/comment/32658388
has comment: http://stackoverflow.com/comment/32657017
answer count: 4
has answer: http://stackoverflow.com/a/21615455
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21613911
has title: algorithm removing duplicate elements in array without auxillay storage
has comment: http://stackoverflow.com/comment/32657434
upvote count: 0
tagged with: java
tagged with: duplicates

http://stackoverflow.com/comment/32739926
has text: @tomjdog it's not a Java specific code. It's principal in math and algoritmic. I show you in answer this recursion in full form.
comment on: http://stackoverflow.com/a/21661054
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/21667254
favorite count: 0
accepted answer: http://stackoverflow.com/a/21709182
answer count: 5
has answer: http://stackoverflow.com/a/35430405
upvote count: 23
type: AnsweredQuestion
tagged with: java
score: 23
tagged with: https
type: Question
possible better answer: http://stackoverflow.com/a/21674863
tagged with: playframework
has answer: http://stackoverflow.com/a/21709182
has answer: http://stackoverflow.com/a/21674863
downvote count: 0
has answer: http://stackoverflow.com/a/21670966
has body: I am trying to run play framework 2.2.1 application on HTTPs in dev mode. I use the following command: Development/Play/ssltest$ JAVA_OPTS=-Dhttps.port=9443 play run I got the following, which seems to be OK --- (Running the application from SBT, auto-reloading is enabled) --- [info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000 [info] play - Listening for HTTPS on port /0:0:0:0:0:0:0:0:9443 (Server started, use Ctrl+D to stop and go back to the console...) However, when I try to connect to the app over HTTPS: "https://localhost:9443" The app crash and I go the following stack of exceptions: [error] play - Error loading fake key store java.security.cert.CertificateException: Subject class type invalid. at sun.security.x509.X509CertInfo.setSubject(X509CertInfo.java:888) ~[na:1.8.0-ea] at sun.security.x509.X509CertInfo.set(X509CertInfo.java:415) ~[na:1.8.0-ea] at play.core.server.netty.FakeKeyStore$.createSelfSignedCertificate(FakeKeyStore.scala:71) ~[play_2.10.jar:2.2.1] at play.core.server.netty.FakeKeyStore$.keyManagerFactory(FakeKeyStore.scala:34) ~[play_2.10.jar:2.2.1] at play.core.server.NettyServer$PlayPipelineFactory$$anonfun$sslContext$2.apply(NettyServer.scala:98) [play_2.10.jar:2.2.1] at play.core.server.NettyServer$PlayPipelineFactory$$anonfun$sslContext$2.apply(NettyServer.scala:94) [play_2.10.jar:2.2.1] [info] play - Application started (Dev) [error] p.nettyException - Exception caught in Netty java.lang.IllegalArgumentException: invalid version format: ﾎﾫ?BYFￅﾛ￵￣X￶￧ﾣﾇ$￀+￀/ﾞﾜ￀ at org.jboss.netty.handler.codec.http.HttpVersion.&lt;init&gt;(HttpVersion.java:102) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:189) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.deco…
has answer: http://stackoverflow.com/a/35960237
linked to: http://stackoverflow.com/q/17035690
has title: Play framework 2.2.1 HTTPs fails on connection attempt

http://stackoverflow.com/comment/32508794
score: 0
type: Comment
has text: Thanks for your response; However would you know why I am getting a "The method setProgressListener(FileUploadListener) is undefined for the type ServletFileUpload" yet FileUploadListener implements ProgressListener?
comment on: http://stackoverflow.com/a/21529390
type: AnswerComment

http://stackoverflow.com/comment/32567707
score: 1
type: AnswerComment
type: Comment
has text: Then check out the Unofficial API that I linked. It does that for you.
comment on: http://stackoverflow.com/a/21562744

m2e
type: Tag
tag name: m2e
tags question: http://stackoverflow.com/q/21670104

http://stackoverflow.com/q/21655028
has answer: http://stackoverflow.com/a/21655120
score: 0
has body: I did till this however it is not showing any output. import acm.program.*; import acm.graphics.*; import java.awt.*; public class Test5 extends GraphicsProgram { public void run() { GRect rect = new GRect(0,0,50,50); for(int i=1;i&lt;=8;i++){ for(int j=1;j&lt;=8;j++) { if(((i + j) % 2 == 0)) { rect.setColor(Color.WHITE);} else { rect.setColor(Color.BLACK); } add(rect); } } } }
answer count: 1
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32729794
has comment: http://stackoverflow.com/comment/32729762
tagged with: java
has comment: http://stackoverflow.com/comment/32729764
type: Question
has comment: http://stackoverflow.com/comment/32729876
has title: Create a Chess Board in Java

http://stackoverflow.com/comment/32575220
has text: Excuse me if I'm so busy with everything. I'm actually doing a full college semester for four months. Anyway, I'll try it out and see how it goes. In case I find something going wrong, I'll keep touch with you.
type: Comment
comment on: http://stackoverflow.com/a/21519409
type: AnswerComment
score: 0

http://stackoverflow.com/q/21557645
has comment: http://stackoverflow.com/comment/32559539
tagged with: encryption
has comment: http://stackoverflow.com/comment/32558022
type: AnsweredQuestion
has body: I'm working on a C# encryption program, and I am pretty much done with it. It encrypts and decrypts a string that I pass as an argument. The only problem is that when I compare to equivalent Java encryption program I notice that c# converts hexadecimal of special characters. Is there a way I can tell the program not to convert special characters and just represent them as hexadecimal? Here is an example Java : 4g8LAQXy%2B1M%3D C#: 4g8LAQXy+1M= As you can see, '+' in hex is 2B and '=' in hex is 3D.
has comment: http://stackoverflow.com/comment/32557925
tagged with: java
has comment: http://stackoverflow.com/comment/32557852
has comment: http://stackoverflow.com/comment/32562496
type: Question
tagged with: c#
has title: C# string encoding using ToBase64String
accepted answer: http://stackoverflow.com/a/21557717
score: 0
has comment: http://stackoverflow.com/comment/32559244
answer count: 1
has answer: http://stackoverflow.com/a/21557717

http://stackoverflow.com/q/21517507
tagged with: java
has comment: http://stackoverflow.com/comment/32487807
type: Question
has comment: http://stackoverflow.com/comment/32487499
score: -2
has comment: http://stackoverflow.com/comment/32487754
downvote count: 2
has comment: http://stackoverflow.com/comment/32487546
has body: My program has a menu with 3 choices. 1 is to display the deck(if the users enter 1 first a new deck will be displayed). 2 is to shuffle the deck without printing the deck. 3 just exits the program. So for example to print a shuffled deck the user must enter 2 to shuffle then press 1 to display the shuffled deck. I cannot figure out how to print the shuffled deck without printing the new deck. import java.util.Scanner; public class Prog4 { public static void main(String[] args){ double menuOption = 0; int z = 0; MyDeck d1 = new MyDeck(); MyCard c; System.out.println(); while (true){ Scanner option = new Scanner(System.in); try{ System.out.println("1. Display the deck"); System.out.println("2. Shuffle the cards"); System.out.println("3. Quit"); System.out.print("(Choose a menu 1, 2, or 3 : "); menuOption = option.nextDouble(); if (menuOption == 1) { System.out.println("You selected display deck!! "); while(true){ while(z&lt;=12){ c = d1.printDeck2(z); System.out.print(c.toString() + " "); z++; } System.out.println(); while(z&lt;=25){ c = d1.printDeck2(z); System.out.print(c.toString() + " "); z++; } System.out.println(); while(z&lt;=38){ c = d1.printDeck2(z); System.out.print(c.toString() + " "); z++; } System.out.println(); while(z&lt;=51){ c = d1.printDeck2(z); System.out.print(c.toString() + " "); z++; } if(z&gt;51) break; } System.out.println(); } else if(menuOption == 2){ System.out.println("You selected Shuffle the cards!! "); c = d1.shuffle3(); } else if(menuOption == 3){ System.out.println("You selected exit!!"); break; } else break; } catch (Exception e) { System.out.println("Invalid menu selected. Please choose menu 1, 2, or 3"); } } } } public class MyCard { private int suit; private int rank; private String[] suits = {"S","D","H","C"}; private String[] ranks = {"01","02","03","04","05","06","07","08","09","10","11","12","13" }; public MyCard(int suit, int rank) { this.suit = suit; this.rank = rank; } public int getSuit() { return suit; } public void setSu…
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/32487583
has title: Print a deck of cards after they have been shuffled using a menu
has answer: http://stackoverflow.com/a/21517563
upvote count: 0
type: UnansweredQuestion

http://stackoverflow.com/comment/32660923
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21614832
has text: I still don't know what to do about every third item having data... (help!) : )
type: AnswerComment

http://stackoverflow.com/a/21634658
has body: You are getting 0 cause 5 / 9 is always 0. What you can do something like this celsius = ((fahrenheit - 32.0) * 5.0) / 9.0;
type: Answer
downvote count: 0
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/21634617

http://stackoverflow.com/q/21653677
tagged with: character
type: AnsweredQuestion
has title: Calculating character values in Java given an initial character and an offset
tagged with: java
type: Question
tagged with: math
has answer: http://stackoverflow.com/a/21653788
accepted answer: http://stackoverflow.com/a/21653788
score: 0
tagged with: char
has body: I want to generate single character strings to use as default labels -- think of column labels in a spreadsheet application. In my particular case, I simply need to draw from the set of Strings in ["A".."Z"], but the solutions I am trying could apply to lowercase Latin1 letter, numerals, characters from the Greek alphabet, etc. A common solution in Java is something like: static final String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; static public char getLabel( int index ) { return alphabet.charAt( index ); } It is reasonably efficient and a run-time error will result if index is not in [0..25], but it is typical Java in that it is verbose and requires even more code to verify it works correctly -- forgot the 'U' or is it transposed with 'V', etc... So instead, I looked into theCharacter class to see if it provided methods for retrieving an ordinal value -- or Unicode index or numeric value -- which could be returned for a starting letter such a 'A' in a Unicode block and category which could then be added to an integer producing a result used to "look up" the character required using another method which would return a char given a valid integer value where "valid" is dependent on the Unicode encoding. Sure enough, there are methods to do just that and quite a bit more. In fact there seem to be several methods which do the same thing, some which do the same with additional options such as specifying a radix for numeric values, and then a big time-sink in trying to grok the differences among "code points," "numeric values," "digits" (which are more convoluted than the method names would suggest), etc. In short, Character seems to offer useful methods for my simple requirement, but wrapped in a package which is far to complex to puzzle out for what I need to do. Finally, there is the option of performing arithmetic on char primitives. Something like: assert 'B' == 'A' + 1; Well, almost. Java complicates things by converting all "integer" types smaller than an int to a…
has comment: http://stackoverflow.com/comment/32727343
answer count: 1
tagged with: unicode
has comment: http://stackoverflow.com/comment/32727246

http://stackoverflow.com/a/21673943
type: Answer
has body: This is a division by zero problem and not NPE. Tip: Before you do division, check your DIVISOR first. Also, you can improve your code by: public boolean combine(int a, int b, int c) { boolean check = checkIfOk(a,b,c); check = checkIfOk(b,a,c); check = checkIfOk(c,a,b); return check; } public boolean checkIfOk(int a, int b, int c) { boolean ret = a==(b+c) || a==(b-c) || a==(b*c); if(c != 0) ret = ret || a==(b/c); return ret; }
score: 0
answers question: http://stackoverflow.com/q/21673802

http://stackoverflow.com/comment/32528337
comment on: http://stackoverflow.com/a/21540342
type: AnswerComment
score: 0
type: Comment
has text: @bcrist I have to say, the code is terrible, but also oddly amusing.

http://stackoverflow.com/q/21612969
downvote count: 0
favorite count: 0
upvote count: 9
tagged with: binding
tagged with: javafx-2
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/40522964
tagged with: java
tagged with: javafx
type: Question
has answer: http://stackoverflow.com/a/21628439
accepted answer: http://stackoverflow.com/a/21628634
has body: I have a situation where I want to bind a BooleanProperty to the non-empty state of an ObservableList wrapped inside an ObjectProperty. Here's a basic synopsis of the behavior I'm looking for: ObjectProperty<ObservableList<String>> obp = new SimpleObjectProperty<ObservableList<String>>(); BooleanProperty hasStuff = new SimpleBooleanProperty(); hasStuff.bind(/* What goes here?? */); // ObservableProperty has null value assertFalse(hasStuff.getValue()); obp.set(FXCollections.<String>observableArrayList()); // ObservableProperty is no longer null, but the list has not contents. assertFalse(hasStuff.getValue()); obp.get().add("Thing"); // List now has something in it, so hasStuff should be true assertTrue(hasStuff.getValue()); obp.get().clear(); // List is now empty. assertFalse(hasStuff.getValue()); I'd like to use the builders in the Bindings class rather than implementing a chain of custom bindings. The Bindings.select(...) method theoretically does what I want, except that there's no Bindings.selectObservableCollection(...) and casting the return value from the generic select(...) and passing it to Bindings.isEmpty(...) doesn't work. That is, the result of this: hasStuff.bind(Bindings.isEmpty((ObservableList<String>) Bindings.select(obp, "value"))); causes a ClassCastException: java.lang.ClassCastException: com.sun.javafx.binding.SelectBinding$AsObject cannot be cast to javafx.collections.ObservableList Is this use case possible using just the Bindings API?
has comment: http://stackoverflow.com/comment/82179748
tagged with: observable
score: 9
has answer: http://stackoverflow.com/a/40522964
has title: Is it possible to bind the non-empty state of an ObservableList inside an ObjectProperty with the Bindings API?
answer count: 3
has answer: http://stackoverflow.com/a/21628634

http://stackoverflow.com/q/21548945
tagged with: annotations
has comment: http://stackoverflow.com/comment/32543994
has title: Is there a way to convert Hibernate XML mappings to Annotational Mappings?
linked to: http://stackoverflow.com/q/962231
answer count: 0
tagged with: java
tagged with: hibernate
tagged with: orm
type: Question
has body: Is there a possibility to convert my existing hbm.xml mapping to annotational mapping? The goal is to get through an automatic mechanism all my xml mappings to annotational Mappings.
has comment: http://stackoverflow.com/comment/32546576
score: 0
tagged with: hbmxml
has comment: http://stackoverflow.com/comment/94083944
type: UnansweredQuestion

http://stackoverflow.com/comment/32498445
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21523840
has text: okay, tomorrow if i want ot use any other implemenation then i can just change the vendor secific dependency right? Also do i need to keep ejb3 persistence jar? is it also implementation of javax persistence API ?

http://stackoverflow.com/comment/32724378
comment on: http://stackoverflow.com/a/21652113
type: Comment
has text: If you found some information in documentation that would state otherwise, please send a link for that, it will be fixed.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32553465
has text: no that doesnt make sense. .. because ALL of the web services on that link are giving the same error
score: 0
comment on: http://stackoverflow.com/q/21555130
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32745187
comment on: http://stackoverflow.com/q/21663766
score: 0
type: QuestionComment
type: Comment
has text: it should throws an exception when the whole row just contains zero elements

http://stackoverflow.com/a/21618462
has body: Like said in the comments, mazeString is declared and initialized as a String Literal. All .next() methods are reserved for Scanner objects. Java doesn't let you use scan
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21618232

http://stackoverflow.com/comment/32752278
has text: @PaulHicks Yeah, I was going for subtle... ;)
comment on: http://stackoverflow.com/a/21667808
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/21634008
tagged with: sorting
favorite count: 0
has comment: http://stackoverflow.com/comment/32695367
has title: Comparator to be used with Collections.sort() for a alphanumberic list
type: AnsweredQuestion
downvote count: 0
type: Question
score: 3
accepted answer: http://stackoverflow.com/a/21634140
has comment: http://stackoverflow.com/comment/32695299
has comment: http://stackoverflow.com/comment/32695653
tagged with: java
has comment: http://stackoverflow.com/comment/32693173
upvote count: 3
has body: So I have a list of a bunch of alphanumeric items like... "123456" "alpha" "tango" "beta" ... I was looking to use Collections.sort() for the sorting of this list, but I need to sort in the order (1234,AAAA,aaaa,BBBB,bbbb,...) with numbers first, followed by upper then lower case words. All the elements are strings including any apparent numbers. Would Collections.sort() handle this case since they are all actually strings, or if not what Comparator would I use to accomplish this? Or is there some other way that might be more efficient to accomplish this like using regular expressions? Thanks.
has answer: http://stackoverflow.com/a/21634140
answer count: 1

http://stackoverflow.com/a/21673567
answers question: http://stackoverflow.com/q/21673293
type: Answer
score: 0
has body: The constructor call must be the first statement in a constructor. so super() should be at the beginning

http://stackoverflow.com/comment/32741473
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21661983
has text: your equals and hashcode method have problem.
score: 0

http://stackoverflow.com/comment/32695540
type: Comment
type: QuestionComment
has text: We need two things: (1) a better description of what you're trying to do - "placing counters in the recursive method for comparisons and assignments" doesn't tell us how that will measure efficiency, and (2) a decent description of "that did not work" for the method you've already tried.
comment on: http://stackoverflow.com/q/21635545
score: 0

http://stackoverflow.com/q/21613416
tagged with: java
tagged with: resttemplate
has title: Why RestTemplate GET response is in JSON when should be in XML?
type: Question
score: 14
accepted answer: http://stackoverflow.com/a/21637522
has comment: http://stackoverflow.com/comment/32659410
upvote count: 14
has comment: http://stackoverflow.com/comment/32658123
has answer: http://stackoverflow.com/a/21637522
has comment: http://stackoverflow.com/comment/32657490
answer count: 1
has comment: http://stackoverflow.com/comment/32661077
has body: I struggled with an extrange spring behavior using RestTemplate (org.springframework.web.client.RestTemplate) without success. I use in my hole application below code and always receive an XML response, which I parse and evaluate its result. String apiResponse = getRestTemplate().postForObject(url, body, String.class); But can't figure out why a server response is in JSON format after executing: String apiResponse = getRestTemplate().getForObject(url, String.class); I've debugged at low level RestTemplate and the content type is XML, but have no idea why the result is in JSON. When I access from a browser the response is also in XML, but in apiResponse I got JSON. I tried many options after reading Spring documentation http://docs.spring.io/spring/docs/3.0.x/api/org/springframework/web/client/RestTemplate.html Also tried to modify explicitly the headers but still can't figure it out. I debugged RestTemplate class and noticed that this method is always setting application/json: public void doWithRequest(ClientHttpRequest request) throws IOException { if (responseType != null) { List&lt;MediaType&gt; allSupportedMediaTypes = new ArrayList&lt;MediaType&gt;(); for (HttpMessageConverter&lt;?&gt; messageConverter : getMessageConverters()) { if (messageConverter.canRead(responseType, null)) { List&lt;MediaType&gt; supportedMediaTypes = messageConverter.getSupportedMediaTypes(); for (MediaType supportedMediaType : supportedMediaTypes) { if (supportedMediaType.getCharSet() != null) { supportedMediaType = new MediaType(supportedMediaType.getType(), supportedMediaType.getSubtype()); } allSupportedMediaTypes.add(supportedMediaType); } } } if (!allSupportedMediaTypes.isEmpty()) { MediaType.sortBySpecificity(allSupportedMediaTypes); if (logger.isDebugEnabled()) { logger.debug("Setting request Accept header to " + allSupportedMediaTypes); } request.getHeaders().setAccept(allSupportedMediaTypes); } } } Could you give an idea?
favorite count: 0
has comment: http://stackoverflow.com/comment/32658918
tagged with: rest
has comment: http://stackoverflow.com/comment/32659958
has comment: http://stackoverflow.com/comment/32657213
has comment: http://stackoverflow.com/comment/32657917
tagged with: spring
has comment: http://stackoverflow.com/comment/32657148
has comment: http://stackoverflow.com/comment/32660346
linked to: http://stackoverflow.com/q/19238715
type: AnsweredQuestion
downvote count: 0

http://stackoverflow.com/a/21523889
has comment: http://stackoverflow.com/comment/32498254
has body: /* * jsch-0.1.50 - MyPane.java, Feb 3, 2014 3:05:03 PM * * Copyright 2014 Varra Ltd, Inc. All rights reserved. * Varra proprietary/confidential. Use is subject to license terms. */ package com.varra.threading.voltaile; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextField; /** * TODO Description go here. * * @author Rajakrishna V. * Reddy * @version 1.0 * */ public class MyPane extends JPanel { /** The Constant serialVersionUID. */ private static final long serialVersionUID = 3089223598850357054L; /** The tf. */ final JTextField tf = new JTextField(30); /** The button. */ final JButton button = new JButton("BUTTON"); /** * Instantiates a new my pane. */ public MyPane() { add(tf); add(button); button.setEnabled(false); new Thread(target).start(); tf.addActionListener(actionListener); } final ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equalsIgnoreCase("Enable")) { button.setEnabled(true); } else if (e.getActionCommand().equalsIgnoreCase("Disable")) { button.setEnabled(false); } } }; final Runnable target = new Runnable() { public void run() { while (true) { final ActionListener[] listeners = tf.getActionListeners(); for (ActionListener listener : listeners) { if (tf.getText().trim().length() > 0) { final ActionEvent event = new ActionEvent(tf, 1, "Enable"); listener.actionPerformed(event); } else { final ActionEvent event = new ActionEvent(tf, 1, "Disable"); listener.actionPerformed(event); } } } } }; /** * Entry point to the entire application, contains the list of args to pass * the user defined values. * * @param args * the arguments */ public static void main(String... args) { final JFrame frame = new JFrame(); frame.getContentPane().add(new MyPane()); frame.setSize(800, 600); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }…
type: Answer
accepted answer of: http://stackoverflow.com/q/21522902
answers question: http://stackoverflow.com/q/21522902
score: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32500583

http://stackoverflow.com/comment/32485860
has text: Fixes the error but still does not work.. Is it how I registered the events?
type: Comment
comment on: http://stackoverflow.com/a/21515359
type: AnswerComment
score: 0

http://stackoverflow.com/q/21602821
type: Question
has comment: http://stackoverflow.com/comment/33109982
type: AnsweredQuestion
tagged with: client-library
tagged with: java
has title: Catch and wrap runtime exceptions when creating library?
has comment: http://stackoverflow.com/comment/32637729
answer count: 1
has comment: http://stackoverflow.com/comment/32638720
has answer: http://stackoverflow.com/a/21603705
score: 0
tagged with: exception
accepted answer: http://stackoverflow.com/a/21603705
has body: I am writing a client library for a range of our APIs to be used by third party libraries. There underlying http client we are using only throws RuntimeExceptions. I don't want to let these exceptions bubble up, but instead wrap them in our own ClientException. However everything I read seems to suggest that catching runtime exceptions is really bad practice? Is this an exception to the rule when writing libraries to be used by third parties?

html-sanitizing
tags question: http://stackoverflow.com/q/21569988
tag name: html-sanitizing
type: Tag

http://stackoverflow.com/comment/32581278
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21570278
has text: Do you mean only the first letter of the name? If not how many letters you want to display?

http://stackoverflow.com/comment/32686358
type: Comment
type: QuestionComment
has text: I just have to comment that I get way more amusement than I should from the member name `ConfigFieldses`
comment on: http://stackoverflow.com/q/21627953
score: 0

http://stackoverflow.com/comment/32766442
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/21676313
has text: Relevant section of the JLS: http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.10.5 - "Moreover, a string literal always refers to the same instance of class String. This is because string literals - or, more generally, strings that are the values of constant expressions (§15.28) - are "interned" so as to share unique instances, using the method String.intern."
type: Comment

http://stackoverflow.com/comment/32692047
type: AnswerComment
has text: Ok,it means I can use some com.xxx.xx as group id right?
type: Comment
comment on: http://stackoverflow.com/a/21633452
score: 0

http://stackoverflow.com/q/21604760
tagged with: facebook
has comment: http://stackoverflow.com/comment/32643003
tagged with: java
has answer: http://stackoverflow.com/a/27802923
tagged with: grails
type: Question
has title: Facebook API: Uploading a cover photo to a Facebook page
answer count: 1
tagged with: upload
has comment: http://stackoverflow.com/comment/32641062
score: 0
tagged with: facebook-graph-api
has body: I'm trying to use the Facebook API upload a photo to the cover photo gallery (or any other gallery for that matter) on my page. Unfortunately, I'm receiving a 403 Permission Denied error as such: java.io.IOException: Server returned HTTP response code: 403 for URL: https://graph.facebook.com/540282086069155/photos?url=http%3A%2F%2Fflyh2.com%2Fstatic%2Fimages%2Fflyh2-logo.png&amp;app_id=643252662393755&amp;method=POST&amp;no_story=true&amp;access_token=CAAJJCO5xW5sBAACKZBGjh9x8RfLg7krbjBA7hp0ZCEd3ZCcKvWs9NbmY3cQZBVIn3TZAcLaCZCRpYXiOU8m63lvXZBaMSWda5xOaAvbTVw6ZB9CTc8O00WGaTRZBKNYTPDqOHl35VMzNeoBNiTo251VZA2E4ZBUqouJhKTaMXyVXZAkNNg1wQ5St5SCkFn8lVmDy9oAZD { "error": { "message": "(#220) Application does not have the capability to make this API call", "type": "OAuthException", "code": 220 } } When doing the OAuth, I requested the following permissions: "manage_pages, publish_stream, photo_upload, publish_actions" Interestingly enough, I can access the page and change the cover photo, but I can't access the album and upload to it.
type: UnansweredQuestion

http://stackoverflow.com/a/21546642
has comment: http://stackoverflow.com/comment/32538308
type: Answer
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/32541929
answers question: http://stackoverflow.com/q/21546388
upvote count: 2
has body: Sure it is possible. On the top of my head: You can control tomcat using scripts (startup, shutdown, catalina) that you can find in tomcat bin directory. The files extension depends on platform (.bat for windows, .sh for Unix To run these scripts remotely use ssh or telnet connection. You can also control tomcat using service manager. The tools depend on your platform.

http://stackoverflow.com/comment/32723634
type: Comment
type: QuestionComment
score: 2
has text: You need `spring-context` and all of its dependencies.
comment on: http://stackoverflow.com/q/21651732

http://stackoverflow.com/comment/32728999
type: Comment
score: 0
type: AnswerComment
has text: I'm not sure what a StringBuffer is, so probably not.
comment on: http://stackoverflow.com/a/21654625

http://stackoverflow.com/a/21563016
has comment: http://stackoverflow.com/comment/32568817
type: Answer
has body: You never want to explicitly call paintComponent. Instead if you want the panel to repaint, you can call panel.repaint(), and the panel with implicitly call its own paintComponent method for you. Don't do every thing inside the main method, you'll find you're going to run into a lot of problems with static references. Don't use Thread.sleep(), it will block the Event Dispatch Thread., as that's where you should be running you Swing apps from. Instead use a java.swing.Timer. See this example for Timer usage. As noted in 3, run your Swing apps from the EDT like this public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable(){ public void run() { new MyApp(); } }); } Don't set the size of your frame. Instead override getPreferredSize() of your DrawingPanel and just pack() the frame. You can center the frame by using setLocationRelativeTo(null) Should make it a habit to use the @Override annotation to make sure you are override correctly. Add-on to 2. What you make a habit of doing, is doing your work from the constructor, then just calling the constructor in the main. Here is a refactor of your code with all the above mentioned things fixed. You can run it. import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.Timer; public class Birthday { DrawString panel = new DrawString(); public Birthday() { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(panel); f.setTitle("Happy Birthday!"); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); f.setResizable(false); Timer timer = new Timer(500, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { panel.repaint(); } }); timer.start(); } public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { @…
has comment: http://stackoverflow.com/comment/32569446
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/32568765
accepted answer of: http://stackoverflow.com/q/21562638
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21562638

http://stackoverflow.com/a/21562711
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21562103
has comment: http://stackoverflow.com/comment/32567164
has body: This is not going to work, you forgot to disable texture comparison. You cannot sample a texture with a texutre comparison mode other than GL_NONE using sampler2D. The results will be undefined. sampler2DShadow is necessary to read a texture with comparison enabled. And when you do this, the first two texture coordinates work as normal but the third is the depth value to compare against and the return of texture (...) is a floating-point value (1.0 for pass, 0.0 for fail). It can be somewhere inbetween if you have a linear filter.
answers question: http://stackoverflow.com/q/21562103
has comment: http://stackoverflow.com/comment/32567579
type: Answer
has comment: http://stackoverflow.com/comment/32567380
has comment: http://stackoverflow.com/comment/32568210
score: 1
has comment: http://stackoverflow.com/comment/32568486
has comment: http://stackoverflow.com/comment/32567908
upvote count: 1
has comment: http://stackoverflow.com/comment/32567297
has comment: http://stackoverflow.com/comment/32567741
has comment: http://stackoverflow.com/comment/32567331
has comment: http://stackoverflow.com/comment/32567693

http://stackoverflow.com/comment/32616109
type: QuestionComment
comment on: http://stackoverflow.com/q/21572198
score: 0
has text: @p1erz: If I understand Thomas Mueller's comment in the linked thread correctly, you were using autocommit. This makes no sense.
type: Comment

http://stackoverflow.com/q/21515631
tagged with: java
linked to: http://stackoverflow.com/q/3211156
score: 0
has answer: http://stackoverflow.com/a/21515704
has title: Getting the binary of an image in java http
has comment: http://stackoverflow.com/comment/32484338
answer count: 1
has body: I need to read an image file and send it to a web browser using HTTP protocol, and I cannot figure out how to send the bytes of the image. I cannot for the life of me figure it out. Thanks in advance. Here is my code: import java.awt.image.BufferedImage; import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; import java.util.ArrayList; import javax.imageio.ImageIO; public class Main { byte[] byt=null; public String read(String message){ String httpHeader=""; String toReturn=""; try{ if(message!=null){ String[] parts=message.split("\n"); String[] RequstParts=parts[0].split(" "); System.out.println("This is a "+RequstParts[0]+" request for "+RequstParts[1]); if(RequstParts[1].equals("/"))RequstParts[1]="index.html"; if(RequstParts[0].equals("GET")){ if(RequstParts[1].endsWith(".html")){ httpHeader="HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"; BufferedReader in = new BufferedReader(new FileReader(new File("WebContent/"+RequstParts[1]))); String line=""; while(null!=(line=in.readLine())){ toReturn+=line; } }else if(RequstParts[1].endsWith(".jpg")){ httpHeader="HTTP/1.1 200 OK\r\nContent-Type: image/jpg\r\nContent-Length: 13312\r\n\r\n"; } } } }catch(Exception e){ toReturn+="&lt;br&gt;ERROR: "+e.toString(); return httpHeader+toReturn; } return httpHeader+toReturn; } public Main(){ try{ ServerSocket listener = new ServerSocket(9090); System.out.println("HTTP server started!"); while(true){ Socket socket = listener.accept(); System.out.println("\nRecieved Data!"); BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); String message=read(in.readLine()); PrintWriter out = new PrintWriter(socket.getOutputStream(), true); System.…
has comment: http://stackoverflow.com/comment/32484646
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32484665
tagged with: http
type: Question

http://stackoverflow.com/comment/32517903
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21534663
type: Comment
has text: I also think this, it's a third party server not well documented, therefore the problems.

http://stackoverflow.com/q/21525260
answer count: 2
has body: ^_^ I'm using DOM Parser to parse the XML data. I want to know whether there exist tag or not. for example .. &lt;a&gt; &lt;aa&gt; &lt;bb&gt; &lt;/a&gt; In this XML code, If I want to know &lt;aa&gt; exist in the XML code, how can I do this? I've not found out the way yet..T_T If you know the way .. please let me know..^^;;
upvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/32500894
accepted answer: http://stackoverflow.com/a/21532161
tagged with: http://stackoverflow.com/tag/xml
has answer: http://stackoverflow.com/a/21525498
has comment: http://stackoverflow.com/comment/32504634
downvote count: 1
has title: How to find out whether there exist tag or not in the XML?
possible better answer: http://stackoverflow.com/a/21525498
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/21532161
score: -1
type: Question

http://stackoverflow.com/comment/32799519
has text: I have weblogic 12.1.2
score: 0
comment on: http://stackoverflow.com/a/21679154
type: Comment
type: AnswerComment

http://stackoverflow.com/q/21558400
score: 0
has title: Get Certificate and Signature values in Java
tagged with: digital-signature
has answer: http://stackoverflow.com/a/21559211
has answer: http://stackoverflow.com/a/25382973
has body: I have a requirement where I need to invoke a webservice. For invoking that webservice I need to provide certificate chain and signature value (datatype in webservice is String) in the SOAP request, from Java. I have generated the source code from the wsdl using wsimport and using that in my Java program. I have a digital signature certificate file (certificateFile.pfx) (with password available to me) . The final SOAP message sample should be like &lt;soapenv:Envelope xmlns:soapenv = "http://schemas.xmlsoap.org/soap/envelope/" xmlns:v = "http://www.something.com"&gt; &lt;soapenv:Header/&gt; &lt;soapenv:Body&gt; &lt;v:Auth&gt; &lt;v:userID&gt;xxxxxxxxxx&lt;/v:userID&gt; &lt;v:password&gt;xxxxxxxxxx&lt;/v:password&gt; &lt;v:certChain&gt;xxxxxxxxxx&lt;/v:certChain&gt; &lt;v:signature&gt;xxxxxxxxxx&lt;/v:signature&gt; &lt;/v:Auth&gt; &lt;/soapenv:Body&gt; &lt;/soapenv:Envelope&gt; After generating the java source code from WSDL, for Auth, I am setting value like this. (all the below 4 fields are string datatype) Auth authInfo = new Auth(); authInfo.setUserID(userId); authInfo.setPassword(password); authInfo.setCertChain(""); authInfo.setSignature(""); Here I am not getting what to set for CertChain and Signature. Since I have a certificate file, I tried this XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM"); // Load the KeyStore and get the signing key and certificate. KeyStore ks = KeyStore.getInstance("PKCS12"); ks.load(new FileInputStream(new File(certificateName)), certificatePassword.toCharArray()); KeyStore.PrivateKeyEntry keyEntry = (KeyStore.PrivateKeyEntry) ks.getEntry( certificateAlias, new KeyStore.PasswordProtection( certificatePassword.toCharArray())); X509Certificate cert = (X509Certificate) keyEntry.getCertificate(); and used authInfo.setSignature(new String(cert.getSignature())); But none worked. cert.getSignature() returns binary data not really a string. I am not getting what to set for those two fields. How to do make use of my certific…
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21559211
possible better answer: http://stackoverflow.com/a/25382973
tagged with: java
tagged with: certificate
type: Question
answer count: 2

http://stackoverflow.com/comment/32793742
type: Comment
has text: Are you just looking for an algorithm that rotates/translates ABDE to make BO perpendicular to AC?
score: 0
comment on: http://stackoverflow.com/q/21642862
type: QuestionComment

http://stackoverflow.com/q/21658566
type: Question
tagged with: jakarta-ee
accepted answer: http://stackoverflow.com/a/21658700
tagged with: java
tagged with: jboss
tagged with: ejb
has title: java.lang.ClassCastException: com.sun.proxy.$Proxy is thrown when casting an EJB
downvote count: 0
answer count: 1
score: 1
favorite count: 0
tagged with: exception
has body: I am having trouble using remote EJB objects. JNDI look-up succeeds but casting to an object and later usage fails. The EJB interface and implementation are as follows: UserViewBeanRemote.java package books.pointejb; import java.util.List; import javax.ejb.Remote; import books.pointejb.User; import books.pointejb.Book; @Remote public interface UserViewBeanRemote { public boolean register(User user); // A user can delete his/her account, note that two users with the same username cannot exist public void delete(User user); public boolean login(User user); public boolean logout(User user); // Search only by book titles public List&lt;Book&gt; search(String title); } UserViewBean.java package books.pointejb; import java.util.ArrayList; import java.util.Collection; import java.util.List; import javax.ejb.Stateful; import javax.management.Query; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; // import javax.ejb.Remote; import books.pointejb.User; import books.pointejb.Book; /** * Session Bean implementation class UserView */ @Stateful // @Remote(UserViewBeanRemote.class) public class UserViewBean implements UserViewBeanRemote { @PersistenceContext private EntityManager entityManager; /** * Default constructor. */ public UserViewBean() { // TODO Auto-generated constructor stub } public static &lt;T&gt; List&lt;T&gt; castList(Class&lt;? extends T&gt; clazz, Collection&lt;?&gt; c) { List&lt;T&gt; r = new ArrayList&lt;T&gt;(c.size()); for(Object o: c) r.add(clazz.cast(o)); return r; } @Override public boolean register(User user) { // We have servlets that validate these fields, so we don't validate anything here // We check to see whether there is already a user with the same user name or not Query query = (Query) entityManager.createQuery("SELECT u FROM users u WHERE u.username=:userName"); ((javax.persistence.Query) query).setParameter("userName", user.getUsername()); // We check each returned value. If we find anything than we do not …
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21658700
upvote count: 1

http://stackoverflow.com/comment/32726293
comment on: http://stackoverflow.com/a/21643327
score: 0
type: AnswerComment
has text: Actually, every part of this answer is wrong (Garbage collection is automatic; if an OOMError is thrown then the JVM has already tried garbage collecting but it was still out of memory). I would just delete it.
type: Comment

http://stackoverflow.com/comment/33311468
type: Comment
score: 0
has text: Thanks a lot for the links. I've already seen the bottom ones and we're already implementing the **JSInterface** (we need it to allow communication between the web pages and the native App).
type: AnswerComment
comment on: http://stackoverflow.com/a/21979123

http://stackoverflow.com/comment/32659788
has text: is there any error log you can share with us? thanks
score: 0
comment on: http://stackoverflow.com/q/21614894
type: QuestionComment
type: Comment

http://stackoverflow.com/q/21554988
favorite count: 0
has body: My colleague just asked me a really interesting question and I cannot give him an answer. Let's assume that we have got the following class: public class Person { String name; public Person(String name) { this.name = name; } public void print() { System.out.println("xxx"); } } Now, we are creating the objects: Person p1 = new Person("a"); Person p2 = new Person("b"); Person p3 = new Person("c"); Person p4 = new Person("d"); Person p5 = new Person("e"); Person p6 = new Person("f"); Person p7 = new Person("g"); Person p8 = new Person("h"); The question was: Do we keep information about the available methods in each single object? If we create a new object p9, will the JVM create the object with information about only fields or will it also add to this object information about methods? Another question: What happens if I invoke p1.print()? Does p1 have to ask the Person class to provide this method, or is it already saved in p1 object?
accepted answer: http://stackoverflow.com/a/21555104
linked to: http://stackoverflow.com/q/8204595
answer count: 4
type: AnsweredQuestion
tagged with: java
type: Question
tagged with: object
score: 5
has comment: http://stackoverflow.com/comment/32552722
has answer: http://stackoverflow.com/a/21555104
upvote count: 5
possible better answer: http://stackoverflow.com/a/21555153
has comment: http://stackoverflow.com/comment/32552664
tagged with: memory
duplicate of: http://stackoverflow.com/q/8204595
tagged with: class
has answer: http://stackoverflow.com/a/21555153
has answer: http://stackoverflow.com/a/21555435
has title: Where is information about methods of Java objects kept?
has answer: http://stackoverflow.com/a/21555169
downvote count: 0
has comment: http://stackoverflow.com/comment/32552699
tagged with: jvm

http://stackoverflow.com/comment/32658487
type: QuestionComment
score: 9
comment on: http://stackoverflow.com/q/21614298
type: Comment
has text: It's O(1) since this meta-data is saved into the array object.

http://stackoverflow.com/comment/32707169
has text: What does e.printStackTrace() says?
score: 0
comment on: http://stackoverflow.com/q/21642032
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32667593
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21617326
has text: Yes! exactly. Is this possible with JAXB ? And if yes, how do I start ?? And if possible the list of child elements as a list !
score: 0

http://stackoverflow.com/a/21632701
upvote count: 3
has comment: http://stackoverflow.com/comment/32691301
has comment: http://stackoverflow.com/comment/32691104
answers question: http://stackoverflow.com/q/21632585
downvote count: 0
has comment: http://stackoverflow.com/comment/32690035
has comment: http://stackoverflow.com/comment/32690333
type: Answer
has comment: http://stackoverflow.com/comment/32690528
has comment: http://stackoverflow.com/comment/32690764
has comment: http://stackoverflow.com/comment/32690219
has body: The PrintStream source suggests that it is thread safe. If you want to write to the same file from different threads, why not share the same PrintStream instance across the threads? The PrintStream does the syncing for you. /** * Prints a String and then terminate the line. This method behaves as * though it invokes {@link #print(String)} and then * {@link #println()}. * * @param x The String to be printed. */ public void println(String x) { synchronized (this) { print(x); newLine(); } }
score: 3

http://stackoverflow.com/q/21658410
upvote count: 0
tagged with: apache
answer count: 1
favorite count: 0
tagged with: android-asynctask
tagged with: android
score: -1
type: AnsweredQuestion
tagged with: java
has title: HttpClient.execute error =(
downvote count: 1
type: Question
has body: And Error's are: error opening trace file:No Such file or directory(2); java.lang.IllegalStateException: Manager is shut down. at org.apache.http.impl.conn.SingleClientConnManager.assertStillUp(SingleClientConnManager.java:174) org.apache.http.impl.conn.SingleClientConnManager.getConnection(bla bla bla .java:212) org.apache.http.impl.conn.SingleClientConnManager$1.getConnection(---.java:190) org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:326) org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555) org.apache.http.impl.client.AbstractHttpClient.xecute(AbstractHttpClient.java:487) org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465) and more... public class ReqClass { public static final String TAG = ReqClass.class.getSimpleName(); //creating new ResClass object ResClass resp = new ResClass(); //sending request HttpResponse response; //making the request - containst (url,header,entity); HttpPost request; //New HTTP Client HttpClient httpClient = new DefaultHttpClient(); //our code in JSON or XML to Send Request private String s; //This variable contains the total number of keys private int size; // Map Map&lt;String,String&gt; code = new HashMap&lt;String, String&gt;(); // Adding only Key Value parameters public void addparametr (String key, String value){ code.put(key,value); } public String getS(){ return s; } //Adding Key Value and size of new map. public void addparametr (String key, String value, int nOfValues){ } public void Build(String lang){ //List Of keys List&lt;String&gt; keys=new ArrayList&lt;String&gt;(code.keySet()); //k = keys; v = values; String k="",v=""; // size = size of Map; size=code.size(); // if we want to make our JSON Code to send Request if (lang=="json"){ s=""; s+="{"; for (int i=0; i&lt;size; i++){ k=keys.get(i); v=code.get(k); if (i==size-1) s=s+'"'+k+'"'+": "+'"'+v+'"'; else s=s+'"'+k+'"'+": "+'"'+v+'"'+','; } s=s+"}"; } if (lang =="xml"){ …
has answer: http://stackoverflow.com/a/21658464
tagged with: eclipse
accepted answer: http://stackoverflow.com/a/21658464

http://stackoverflow.com/q/21541501
has title: Issue adding statements to JTextArea with delays in between
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/21541591
score: 0
has answer: http://stackoverflow.com/a/21541594
type: UnansweredQuestion
has body: In the code below I am running my method which adds text to a JTextArea, then i wait 4 seconds and add more text. However it simply waits four seconds then puts all the text down at once. How can I make it so it adds the first text, waits then adds the second block of text? public static void configuresettings() { GUI.add("To Begin, Go to www.opionsxo.com"); try { Thread.sleep(4000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } GUI.add("Welcome to Configure Settings!"); } I figured it out, if anyone is interested in how. Then view the code below... public static void configuresettings() { GUI.add("To Begin, Go to www.opionsxo.com"); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { GUI.add("Welcome to Configure Settings!"); } }; Timer timer = new Timer( 4000, actionListener ); timer.setRepeats(false); timer.start(); }
tagged with: java

http://stackoverflow.com/q/21515125
answer count: 1
tagged with: serversocket
type: UnansweredQuestion
tagged with: sockets
tagged with: object
tagged with: java
has answer: http://stackoverflow.com/a/21516230
type: Question
has title: Socket reset by peer without reseting myself
has comment: http://stackoverflow.com/comment/32485648
score: 0
has body: For some reason every time I try to write a Object to a Socket and it errors with the following error: java.net.SocketException: Connection reset by peer: socket write error Full stack trace at end. Here is my client code: note: ObjectOutputStream.writeObject() has a custom written writeObject() SerializedImage si = new SerializedImage(); si.setImage((BufferedImage) image); NetworkObject no = new NetworkObject(si); try { Socket s = new Socket(hostname, 912);//hostname is 192.168.1.12 OutputStream os = s.getOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(os); oos.writeObject(no);//error start when this is called oos.close(); os.close(); s.close(); } catch (UnknownHostException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ObjectOutputStream private void writeObject(java.io.ObjectOutputStream out) throws IOException { out.writeObject(name); ImageWriter writer = (ImageWriter) ImageIO.getImageWritersBySuffix("jpg").next(); writer.setOutput(ImageIO.createImageOutputStream(out)); ImageWriteParam param = writer.getDefaultWriteParam(); param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); param.setCompressionQuality(1f); BufferedImage bImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB); //obtain it's graphics Graphics2D bImageGraphics = bImage.createGraphics(); //draw the Image (image) into the BufferedImage (bImage) bImageGraphics.drawImage(image, null, null); // cast it to rendered image RenderedImage rImage = (RenderedImage) bImage; writer.write(rImage); } private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { name = (String) in.readObject(); image = ImageIO.read(ImageIO.createImageInputStream(in)); } and then I have a Server receiving ServerSocket ss = new ServerSocket(912); Socket s = ss.accept(); InputStream is = s.getInputStream(); ObjectInputStream ois = new ObjectInputStream(is); NetworkObject net = (NetworkObject) ois.readObje…

http://stackoverflow.com/comment/32679141
type: Comment
type: QuestionComment
has text: Some people are so proud that they know what the square is, that they immediately punish the one who doesn't know that, because of not being English or old enough. Pfuj! +1 to the question, Hold on, boy! Or girl.
score: 0
comment on: http://stackoverflow.com/q/21625445

http://stackoverflow.com/a/21585910
has body: Don't set null values for the model. No point. Just do this String[] colNames = {"name", "surname","job"}; DefaultTableModel model = new DefaultTableModel(colNames, 0): JTable table = new JTable(model); Then split the String into an array by the $ String[] lines = longString.split("\\$"); Just loop through that array and split again and add the array from the second split to the model for (String line : lines) { model.addRow(line.split("#"); } That's all there really is to it :) Run this test import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.SwingUtilities; import javax.swing.table.DefaultTableModel; public class TestTable5 { public TestTable5() { String blah = "pee#skillet#assassin$pee#skillet#stackoverflow"; String[] colNames = {"name", "surname", "job"}; DefaultTableModel model = new DefaultTableModel(colNames, 0); JTable table = new JTable(model); String[] lines = blah.split("\\$"); // escape the $ for (String line : lines) { model.addRow(line.split("#")); } JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(table)); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { new TestTable5(); } }); } }
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21585604
answers question: http://stackoverflow.com/q/21585604
type: Answer
score: 4
upvote count: 4

http://stackoverflow.com/a/21651817
type: Answer
accepted answer of: http://stackoverflow.com/q/21641022
answers question: http://stackoverflow.com/q/21641022
score: 5
upvote count: 5
has body: So, the RTTAF approach was a push in the right direction, but it expects me to have a field that denotes which subtype I'm using. In my specific case, I have subtypes and subtypes of those subtypes. This is what I ended up doing: UPDATE: Created Github gist Note: In my test project (below), I'm using GSON and Lombok for annotations. The Type Factory public class CustomTypeAdapterFactory implements TypeAdapterFactory { @Override public &lt;T&gt; TypeAdapter&lt;T&gt; create (final Gson gson, final TypeToken&lt;T&gt; type) { if (type.getRawType () != SuperType.class) return null; final TypeAdapter&lt;T&gt; delegate = gson.getDelegateAdapter (this, type); return new TypeAdapter&lt;T&gt; () { @Override public void write (final JsonWriter jsonWriter, final T t) throws IOException { delegate.write (jsonWriter, t); } @Override public T read (final JsonReader jsonReader) throws IOException, JsonParseException { JsonElement tree = Streams.parse (jsonReader); JsonObject object = tree.getAsJsonObject (); if (object.has ("a")) return (T) readTypeA (tree, object.getAsJsonObject ("a")); if (object.has ("b")) return (T) readTypeB (tree, object.getAsJsonObject ("b")); throw new JsonParseException ("Cannot deserialize " + type + ". It is not a valid SuperType JSON."); } private TypeA readTypeA (final JsonElement tree, final JsonObject a) { if (a.has ("aa")) return gson.getDelegateAdapter (CustomTypeAdapterFactory.this, TypeToken.get (TypeA_A.class)).fromJsonTree (tree); if (a.has ("ab")) return gson.getDelegateAdapter (CustomTypeAdapterFactory.this, TypeToken.get (TypeA_B.class)).fromJsonTree (tree); if (a.has ("ac")) return gson.getDelegateAdapter (CustomTypeAdapterFactory.this, TypeToken.get (TypeA_C.class)).fromJsonTree (tree); throw new JsonParseException ("Cannot deserialize " + type + ". It is not a valid TypeA JSON."); } private TypeB readTypeB (final JsonElement tree, final JsonObject b) { if (b.has ("ba")) return gson.getDelegateAdapter (CustomTypeAdapterFactory.this, TypeTo…
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/21646047
tagged with: android-intent
score: 2
type: AnsweredQuestion
tagged with: java
tagged with: gson
type: Question
has title: GSON not retrieving the key in the linkedHashMap<object, String> as object. Instead retrieved as String
downvote count: 0
has answer: http://stackoverflow.com/a/21646819
answer count: 1
has body: I was trying to send a LinkedHashMap through Gson from one activity. But in another activity, when I am trying to get the key of the LinkedHashMap, it is retrieved as a key of type String and not as a key of type Object. I have presented my code below. Activity 1: LinkedHashMap&lt;TravelMode, String&gt; polyPoints=(LinkedHashMap&lt;TravelMode, String&gt;) gData.values().toArray()[0]; Gson gson = new Gson(); Type entityType= new TypeToken&lt; LinkedHashMap&lt;TravelMode, String&gt; &gt;(){}.getType(); String list = gson.toJson(polyPoints,entityType); mapIntent.putExtra(EXTRA_MESSAGE, list); Activity 2: String str= getIntent().getStringExtra(EXTRA_MESSAGE); Gson gson = new Gson(); Type entityType= new TypeToken&lt; LinkedHashMap&lt;TravelMode, String&gt; &gt;(){}.getType(); LinkedHashMap&lt;TravelMode, String&gt;polypoint = gson.fromJson(str, entityType); This is the Error I am getting while executing my program com.google.gson.JsonSyntaxException) com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 3 android TravelMode: class TravelMode implements Serializable{ /** * */ private static final long serialVersionUID = 1L; public String travelMode; /** * @return the travelMode */ public String getTravelMode() { return travelMode; } /** * @param travelMode the travelMode to set */ public void setTravelMode(String travelMode) { this.travelMode = travelMode; } public TravelMode(String travelMode) { super(); this.travelMode = travelMode; } } Please help me out folks.
tagged with: android
favorite count: 0
accepted answer: http://stackoverflow.com/a/21646819
upvote count: 2

http://stackoverflow.com/a/21588835
score: 3
has comment: http://stackoverflow.com/comment/32618288
upvote count: 3
accepted answer of: http://stackoverflow.com/q/21586660
has body: The PKIX error means that the client didn't trust the server certificate, where the server in this case was the Registry. To clarify, you need two private keys and two keystores to hold them in, one each. You then need to create certificates in each keystore, export them, and import them into the peer's truststore. The server's truststore must trust the client's keystore, and vice versa. Your code looks mostly OK. The result of createRegistry() should be stored in a static variable, to prevent it being GC'd. You don't need a serialVersionUID in the server class, whatever your IDE may tell you. It doesn't get serialized, at least not by RMI. EDIT The problem is here: System.setProperty("javax.net.ssl.keyStore", "C:\\ssl\\keystore-server.jks"); System.setProperty("javax.net.ssl.trustStore", "C:\\ssl\\truststore-client.jks"); which should be: System.setProperty("javax.net.ssl.keyStore", "C:\\ssl\\keystore-server.jks"); System.setProperty("javax.net.ssl.trustStore", "C:\\ssl\\truststore-server.jks"); and here: System.setProperty("javax.net.ssl.keyStore", "C:\\ssl\\keystore-client.jks"); System.setProperty("javax.net.ssl.trustStore", "C:\\ssl\\truststore-server.jks" which should be: System.setProperty("javax.net.ssl.keyStore", "C:\\ssl\\keystore-client.jks"); System.setProperty("javax.net.ssl.trustStore", "C:\\ssl\\truststore-client.jks" EDIT 2 The underlying problem is that the trust store you need when binding to the Registry is the client truststore, but the truststore you need when running the server is the server truststore. There are at least three possible solutions, in increasing order of merit: Set up a subclass of SslRMIClientSocketFactory with its own SSLContext with its own TrustManager loaded from the client truststore, and override createSocket(). Ouch. Import the server's certificate into the server's truststore as well. Use the return value of createRegistry() to do the bind() instead of calling getRegistry() in the server at all, and avoid the whole prob…
answers question: http://stackoverflow.com/q/21586660
has comment: http://stackoverflow.com/comment/32657089
has comment: http://stackoverflow.com/comment/32619396
has comment: http://stackoverflow.com/comment/32618797
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/44030387
has comment: http://stackoverflow.com/comment/32619953
type: Answer

spdy
tag name: spdy
tags question: http://stackoverflow.com/q/21540379
type: Tag

http://stackoverflow.com/comment/32602025
type: QuestionComment
comment on: http://stackoverflow.com/q/21581742
has text: Welcome to SO. Please indicate the language tag that is related to your question. I've added java for your question.
score: 0
type: Comment

http://stackoverflow.com/comment/32516961
comment on: http://stackoverflow.com/q/21534091
type: QuestionComment
type: Comment
has text: You're not calling `addTopping`, and even if you were, you'd be adding the string literal `"topping"`, not the passed in `topping` variable.
score: 0

http://stackoverflow.com/comment/32526779
score: 0
comment on: http://stackoverflow.com/a/21539106
type: AnswerComment
type: Comment
has text: i forgot to mention that my takephoto method is not a boolean type. what should i do in order for me to make it a condition?

http://stackoverflow.com/comment/32716843
type: QuestionComment
comment on: http://stackoverflow.com/q/21647854
score: 0
has text: Ouch, my eyes, you can do that in two lines of code (or less)
type: Comment

http://stackoverflow.com/comment/32556759
type: QuestionComment
has text: Hi Alvin,Client.java a Hadoop API, I am not working there
comment on: http://stackoverflow.com/q/21538162
score: 0
type: Comment

http://stackoverflow.com/q/21638579
type: Question
tagged with: java
has comment: http://stackoverflow.com/comment/32701282
has comment: http://stackoverflow.com/comment/32702114
accepted answer: http://stackoverflow.com/a/21638767
has comment: http://stackoverflow.com/comment/32701270
score: 0
answer count: 3
has title: How to reuse input value
has body: public double getInput() { System.out.print("Percentage of attacks that will be aimed low: "); Scanner data = new Scanner(System.in); double low = data.nextDouble(); return(low); } public static void main(String[] args) { for ( int i = 0 ; i &lt; round ; i++) { xxxx.getInput(); } I didn't include all of it, but I hope you get what I mean.
favorite count: 0
has comment: http://stackoverflow.com/comment/32701300
has answer: http://stackoverflow.com/a/21638615
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21638767
upvote count: 2
possible better answer: http://stackoverflow.com/a/21638615
downvote count: 2
has answer: http://stackoverflow.com/a/21638962

http://stackoverflow.com/a/21603599
answers question: http://stackoverflow.com/q/21601897
has body: We are using the solution 4. Our GWT app inherits from the project with the back-end logic. When launching dev mode the back-end logic runs as usual. Do you have to call a main() whenever you want to start the background application ? We are using Spring and the beans managing the background processes are created automatically on start-up. Your local server could also just call that process on start-up.
type: Answer
score: 0

http://stackoverflow.com/comment/32610908
comment on: http://stackoverflow.com/a/21585651
type: Comment
has text: @user1635354 No, Strings do not overload `==`. Nothing does or can overload `==` in Java. It compares the objects for reference equality, same as it does for any reference types.
score: 0
type: AnswerComment

http://stackoverflow.com/q/21637562
tagged with: comparison
has answer: http://stackoverflow.com/a/21637962
score: 0
answer count: 1
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32699390
tagged with: linked-list
tagged with: java
has title: Comparing the contents of in two linked lists
has body: This is my first time working with linked lists and I've created both of my lists from two separate files and tokenized the data. Now I need to compare the data and look for similarities, by that I mean the same data. Such has list 1: 1, 3, dog and list 2: 1, dog, cat. Both have 1 and dog. I am unsure how to approach this, and would love some tips, input, or hints.
type: Question

http://stackoverflow.com/comment/32765109
score: 0
type: QuestionComment
type: Comment
has text: `If JVisualVM is required, I have this.` So what stopping you to use that ?
comment on: http://stackoverflow.com/q/21675709

http://stackoverflow.com/q/21518730
possible better answer: http://stackoverflow.com/a/21518806
answer count: 2
score: 1
favorite count: 0
has title: How to implement synchronized checks for Bounded Buffer to avoid Race Conditions?
accepted answer: http://stackoverflow.com/a/21518787
tagged with: multithreading
type: AnsweredQuestion
tagged with: java
has body: Working with the classic multiple Consumer/Producer problem, and I have an issue that is driving me around the bend, regarding how to avoid race conditions when inserting/removing from a circular buffer. Appreciate any help in advance! Sample code for circular buffer for example purposes. Similar to my implementation (Note: I cannot use collection types, only arrays for this): import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public class BoundedBuffer { private final String[] buffer; private final int capacity; private int front; private int rear; private int count; private final Lock lock = new ReentrantLock(); private final Condition notFull = lock.newCondition(); private final Condition notEmpty = lock.newCondition(); public BoundedBuffer(int capacity) { super(); this.capacity = capacity; buffer = new String[capacity]; } public void deposit(String data) throws InterruptedException { lock.lock(); try { while (count == capacity) { notFull.await(); } buffer[rear] = data; rear = (rear + 1) % capacity; count++; notEmpty.signal(); } finally { lock.unlock(); } } public String fetch() throws InterruptedException { lock.lock(); try { while (count == 0) { notEmpty.await(); } String result = buffer[front]; front = (front + 1) % capacity; count--; notFull.signal(); return result; } finally { lock.unlock(); } } } What I need to know is how can I implement a method for checking if the buffer is full/Empty? This method needs to be included in this BoundedBuffer and must be called from another class (Producer/Consumer) before giving the go ahead for/Calling Inserting/Writing methods. Pseudocode for method in Producer class. if (!bufferFull) { buffer.addelement; } else { thread.sleep(5) threadHasSleptFor++; } I am using threads, and there are multiple producers/consumers (In this case 2 producers/consumers, but I may require more). I need it so that if the buffer is full, the thread has to wait u…
tagged with: concurrency
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/21518806
has answer: http://stackoverflow.com/a/21518787
tagged with: race-condition
downvote count: 0
tagged with: producer-consumer

http://stackoverflow.com/q/21631624
has answer: http://stackoverflow.com/a/21632520
score: -1
favorite count: 0
has comment: http://stackoverflow.com/comment/32688067
has body: Below is my code which checks the date which is stored in database with the current system date and calculates the days and if that days is lesser than the 180 days it will print something else print nothing,this code works great in an normal java program(with out using swings concept) if it is used with the swing program i changed the sql query to check get the date from the database based on the department and staff names which is entered in the text fields,i coded this code inside an jbutton,in the output it just prints the current system date but not calculates the days between the selected date and the current system dates,friends this is the problem am facing kindly need your help friends....thanks in advance.. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try { Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/leave", "root", ""); Statement stm = conn.createStatement(); ResultSet rs = stm.executeQuery("select * from staff where depmt='" + txt1 + "' AND staffs='" + txt2 + "'"); Calendar javaCalendar = null; String currentDate = ""; javaCalendar = Calendar.getInstance(); currentDate = javaCalendar.get(Calendar.DATE) + "/" + (javaCalendar.get(Calendar.MONTH) + 1) + "/" + javaCalendar.get(Calendar.YEAR); int cdate = javaCalendar.get(Calendar.DATE); int cmonth = (javaCalendar.get(Calendar.MONTH) + 1); int cyear = javaCalendar.get(Calendar.YEAR); int z = 0; int date = 0, month = 0, year = 0; System.out.println("Current Date\t" + currentDate); System.out.println("\n"); while (rs.next()) { date = rs.getInt(3); month = rs.getInt(4); year = rs.getInt(5); System.out.println("Random Date\t" + date + "/" + month + "/" + year + "\n"); int d = (date - cdate); int m = month - cmonth; int y = year - cyear; int d1 = java.lang.Math.abs(d); int d2 = java.lang.Math.abs(m); int d3 = java.lang.Math.abs(y); z = d1 + (d2 * 30) + (d3 * 365); if (z &gt;= 180) { System.out.println("something"); 0 }…
downvote count: 2
has answer: http://stackoverflow.com/a/21631736
upvote count: 1
has comment: http://stackoverflow.com/comment/32688105
has answer: http://stackoverflow.com/a/22292496
tagged with: java
answer count: 5
tagged with: date
has title: How to find the days between dates using my code?
has answer: http://stackoverflow.com/a/22292263
has comment: http://stackoverflow.com/comment/32688215
has comment: http://stackoverflow.com/comment/32688097
has comment: http://stackoverflow.com/comment/32688164
type: UnansweredQuestion
type: Question
tagged with: sql
has comment: http://stackoverflow.com/comment/32688242
has answer: http://stackoverflow.com/a/22293549
has comment: http://stackoverflow.com/comment/32688231

http://stackoverflow.com/a/21622030
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/32671677
has comment: http://stackoverflow.com/comment/32671903
has body: You need to use the value returned by the RequireJS dependency (CoffeeScript approximative...): define ['core'], (Core) -&gt; class Core.Classes.Models.Account extends Backbone.Model initialize: -&gt; login: (username, password) -&gt; Otherwise, RequireJS won't wait for Core to be loaded before trying to access the Classes attribute. See for example https://github.com/davidsulc/structuring-backbone-with-requirejs-and-marionette/blob/master/assets/js/apps/contacts/edit/edit_controller.js
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/21621922
has comment: http://stackoverflow.com/comment/32671938

http://stackoverflow.com/comment/32583565
type: Comment
has text: It is not allowing the import statement because the `jar` is probably not on the class path.
type: QuestionComment
comment on: http://stackoverflow.com/q/21553008
score: 0

http://stackoverflow.com/q/21659393
answer count: 1
downvote count: 0
favorite count: 0
upvote count: 2
has answer: http://stackoverflow.com/a/21660306
tagged with: spring-mvc
score: 2
type: AnsweredQuestion
tagged with: java
has title: Accepting DateTime (Jodatime) as request method argument in SpringMVC
has body: I have a model class class SomeClass { private DateTime myDate; // setter &amp; getter } and a controller: @Controller class MyController { @RequestMapping("...") public String doStuff(@ModelAttribute("myAttribute") SomeClass value) { // ... } } When calling this controller from a HTML5 form with an appropriate &lt;input type="datetime" .../&gt; field I get the following error: Field error in object 'myAttribute' on field 'myDate': rejected value [2014-02-08T23:00:00.00Z]; codes [typeMismatch.myAttribute.myDate,typeMismatch.myDate,typeMismatch.org.joda.time.DateTime,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [myAttribute.myDate,myDate]; arguments []; default message [myDate]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'org.joda.time.DateTime' for property 'myDate'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.joda.time.DateTime] for property 'myDate': no matching editors or conversion strategy found] This confuses me because as I understand 7.6.5 Configuring Formatting in Spring MVC in the manual: Full support for the Joda Time formatting library is also installed if Joda Time is present on the classpath. The conversion should just work out of the box (I am using spring 4.0 and Joda time 2.3). At least it should find a converter even if the format may be wrong. However I thought that should try to configure the date format as explained in section 7.7 Configuring a global date &amp; time format. With some additional help from google about the format of HTML5 date fields and Javadoc I came up with this: &lt;bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean"&gt; &lt;property name="formatterRegistrars"&gt; &lt;set&gt; &lt;bean class="org.springframework.format.datetime.joda.JodaTimeFormatterRegistrar"&gt; &lt;property name="useI…
type: Question
tagged with: jodatime
accepted answer: http://stackoverflow.com/a/21660306

http://stackoverflow.com/comment/32795469
has text: @user3196742 I'll edit my answer and append something relevant to your issues.
comment on: http://stackoverflow.com/a/21682593
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/32688569
score: 1
comment on: http://stackoverflow.com/q/21630966
has text: I could not reproduce your problem. Probably your mistake is in another part of the code. (Maybe a wrong getter or setter in `MyRectangle2D`?)
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21640172
score: 2
has comment: http://stackoverflow.com/comment/32704345
has body: You can do it using the distanceTo() method. What you do is create two locations, then use that method to calculate the distance between them. This does give you the result in meters. It would look like this: Location location1 = new Location("first location"); location1.setLatitude(latitude1); location1.setLongitude(longtitude1); Location location2 = new Location("second location"); location2.setLatitude(latitude2); location2.setLongitude(longtitude2); float distanceBetween = location1.distanceTo(location2);
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21639993
has comment: http://stackoverflow.com/comment/32741391
upvote count: 2
answers question: http://stackoverflow.com/q/21639993
has comment: http://stackoverflow.com/comment/32746730
type: AcceptedAnswer
type: Answer
has comment: http://stackoverflow.com/comment/32704290
has comment: http://stackoverflow.com/comment/32733959

http://stackoverflow.com/comment/42017219
has text: I was never able to solve this problem. I had to reimplement my method replacing: "Image img = Image.getInstance(image, null);" by: "Image img = Image.getInstance(image);" to avoid the code passing in the place it was stuck. Hope it helps nate
type: Comment
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/21601166

http://stackoverflow.com/comment/32763802
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21664709
has text: How do you want to execute a Java program in the client browser? A servlet in a different tab or window? A separate Java program? (Or do you actually mean Java Script in the browser? Or in the PDF?)

http://stackoverflow.com/q/21530257
tagged with: server-communication
has answer: http://stackoverflow.com/a/21530528
has answer: http://stackoverflow.com/a/21532722
has body: Here's my situation: I'm running a JBoss 7 in Domain Mode with several nodes. One node is in charge of my Liferay 6.2 another one runs several other web applications. Now I'd like to implement some kine of Single Sign On routine. So to use my web applications you have to go through liferay first. Authenticate agains liferay, then go one to one of the web applications. So the question is whether there is a way to expose some of liferays methods to access the user store and check if the user, who's accessing a web application is the same as logged in on liferay. Developing some sort of bridge is fine with me. I'm thinking of a portlet which does all the interaction with liferay and exposes some methods like readUser(). Maybe I can do a jndi lookup for this portlet or a component embedded in this portlet to call readUser() from my other web applications. I think this sounds a bit like EJB stuff. Using Liferays API, Services and LocalServices to read user information etc. shouldn't be that difficult (already played a little with that). I just don't know how to establish a communication between a web application and liferay. If it's not working this way, I would settle for something else, maybe a webservice or an other way that makes sense but I'd like to try the EJB/JNDI approach first (except this makes completely no sense). Maybe someone can point me in the right direction. Turning my applications into portlets is not really an option because these applicaions are quite large and already exsist for quite some time. So I'd like to leave them mostly unchanged - outside of auth stuff. Thanks and regards Sebastian
has title: Expose Liferay functions to another web application
type: UnansweredQuestion
score: 0
tagged with: java
type: Question
tagged with: liferay
answer count: 2

http://stackoverflow.com/a/21553643
downvote count: 0
has body: get rid of &lt;K&gt; in the constructor of A get rid of &lt;K, V&gt; in the constructor of B Constructors do not need to redefine the type parameters of the class. If you do that, they are defined as new type parameters which hide the ones in the class (Eclipse warns you about that).
accepted answer of: http://stackoverflow.com/q/21553532
has comment: http://stackoverflow.com/comment/32551580
answers question: http://stackoverflow.com/q/21553532
score: 5
has comment: http://stackoverflow.com/comment/32551633
type: AcceptedAnswer
upvote count: 5
type: Answer

http://stackoverflow.com/q/21604009
accepted answer: http://stackoverflow.com/a/21604088
has answer: http://stackoverflow.com/a/21604190
answer count: 4
type: AnsweredQuestion
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/32639810
tagged with: java
has answer: http://stackoverflow.com/a/21604088
has answer: http://stackoverflow.com/a/21604066
type: Question
possible better answer: http://stackoverflow.com/a/21604066
has answer: http://stackoverflow.com/a/21604236
upvote count: 2
has title: Make calculations with hexadecimal/decimal numbers
has comment: http://stackoverflow.com/comment/32639706
has comment: http://stackoverflow.com/comment/32639786
has body: I have the rather simple method naf public int naf(int NN, int AA, int FF, int Q) { int mike = FF + 0x20 * AA + 0x200 * NN; if (Q == 1) { mike += 0x4000; } return mike; } I can understand that this method accepts 4 integers and returns an integer. In the second line, the calculations are a bit confusing. I feel that the 0x parts have to do with hexadecimal number format, but the input arguments are in decimal. I have also the feeling that the 0x may make those calculations doable, but I am not certain. What does the 0x offer and how can the method make hexadecimal calculations, when the input is decimal?
favorite count: 0
has comment: http://stackoverflow.com/comment/32639784

http://stackoverflow.com/comment/32691150
type: AnswerComment
comment on: http://stackoverflow.com/a/21632985
type: Comment
has text: `str1= str1.toLowerCase(); System.out.println(str1); System.out.println(str1.substring(Love) );` is this true now
score: 0

http://stackoverflow.com/comment/32562593
comment on: http://stackoverflow.com/q/21559951
score: 0
type: Comment
type: QuestionComment
has text: I have the coordinates of the starting point but I don't have the coordinates of the center.

http://stackoverflow.com/comment/32721165
type: Comment
has text: Don't you need a comma to separate arguments? `"test", new Float(1)`? Maybe this is only a error display issue. It would be better if you posted the code.
score: 2
comment on: http://stackoverflow.com/q/21650276
type: QuestionComment

http://stackoverflow.com/comment/32734435
score: 1
type: Comment
type: QuestionComment
has text: Check if your manager app is functional and check if maven uses it on behalf of user that is allowed to deploy apps through the manager app.
comment on: http://stackoverflow.com/q/21655137

http://stackoverflow.com/comment/32655234
score: 0
comment on: http://stackoverflow.com/q/21612593
type: QuestionComment
type: Comment
has text: Could you include the input provided to the program?

instantiation
type: Tag
tags question: http://stackoverflow.com/q/21640444
tag name: instantiation

http://stackoverflow.com/a/21585262
answers question: http://stackoverflow.com/q/21584922
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/32620984
has body: Fix 1: Remove super.paint(getGraphics()); from constructor. Reason: You should never do it. Use of repaint() is recommended although none is needed in this case. Fix 2: Call super.paint(g) at the end of overridden paint method. Reason: This method is responsible for drawing children (Your button in this case). Button won't appear if you don't call it every time the frame is painted. Fix3: Call setBackGround(new java.awt.Color(0, 0, 0, 0)); in the constructor. Reason: If you don't do this, the super.paint(g); would erase everything you painted manually. Personally I'd suggest using a JPanel for custom painting. It's painting mechanism is much cleaner (Separate paintComponent, paintBorder, paintChildren methods). Good luck.
has comment: http://stackoverflow.com/comment/32609675
has comment: http://stackoverflow.com/comment/32621023

http://stackoverflow.com/comment/32554403
comment on: http://stackoverflow.com/q/21555710
score: 0
type: Comment
type: QuestionComment
has text: Ah interesting. I'll have to add that.

http://stackoverflow.com/q/21675709
has title: How to find which objects are creating the most garbage
type: AnsweredQuestion
tagged with: performance
tagged with: java
type: Question
upvote count: 4
answer count: 2
possible better answer: http://stackoverflow.com/a/21676977
downvote count: 0
score: 4
has comment: http://stackoverflow.com/comment/32765109
has body: I have an application with about 80 instances of 80 different classes. The amount of garbage generated by some subset of these classes is unacceptable and stop the world pauses are too long, since my application is real time. What I want to find is which classes are responsible for creating the largest number of objects on heap (not aggregate size, but raw number of objects), since this is what causes stop the world pauses to take so long. How do I find this out? If JVisualVM is required, I have this.
tagged with: heap-memory
has answer: http://stackoverflow.com/a/21676977
has comment: http://stackoverflow.com/comment/32765142
has answer: http://stackoverflow.com/a/21685250
favorite count: 0
accepted answer: http://stackoverflow.com/a/21685250
linked to: http://stackoverflow.com/q/8126868
tagged with: garbage-collection
has comment: http://stackoverflow.com/comment/121286020

http://stackoverflow.com/q/21545615
has comment: http://stackoverflow.com/comment/32571184
has comment: http://stackoverflow.com/comment/32536821
score: 0
tagged with: user-interface
answer count: 1
has body: I have code here that displays a swing window with four jacks on it. I would like to be able to click and move the jacks around the window. I know they need to be redrawn but I'm not sure how to go about that. How can I make it so a user could click and move the cards? package p2test; import javax.swing.*; import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.awt.*; public class main { public static final int PERIMETER_BEVEL = 20; //space between panel border and perimeter cards public static final int LEFT_PERIMETER_BEVEL = 98; public static final int INTERIOR_BEVEL = 5; //space between cards public static final int CARD_HEIGHT = 97; public static final int CARD_WIDTH = 73; public static final int PANEL_HEIGHT = (2*PERIMETER_BEVEL) + (4*CARD_HEIGHT) + (3*INTERIOR_BEVEL); public static final int PANEL_WIDTH = (2*PERIMETER_BEVEL) + (14*CARD_WIDTH) + (13*INTERIOR_BEVEL); public static final String BACKGROUND_COLOR = "#64C866"; //window background color [hex] public static final String CARD_FOLDER = "cardImages"; //default folder containing images public static final String [] RANKS = { "jack"}; public static final ArrayList&lt;String&gt; ranks = new ArrayList&lt;String&gt;(Arrays.asList(RANKS)); public static void main(String[] args) { JFrame window = new JFrame("deck"); JPanel panel = new JPanel() { public void paintComponent(Graphics g) { //find each rank of card in increasing super.paintComponent(g); //order as specified in the array. All File[] files = new File(CARD_FOLDER).listFiles(); //ranks appear in the same suit order in //the filesystem so suits will automatically //be in order when printing in groups of four //cards. int counter = 0; for(String rank : ranks) { for(File filename : files) { if(filename.getName().contains(rank)) { new ImageIcon(filename.getPath()).paintIcon(this, g, LEFT_PERIMETER_BEVEL + (counter/4) * (CARD_WIDTH + INTERIOR_BEVEL), PERIMETER_BEVEL + (3-(counter%4)) * (CARD_HEIGHT …
has answer: http://stackoverflow.com/a/21921645
linked to: http://stackoverflow.com/q/21142686
has title: Move objects in Java Swing Window
type: AnsweredQuestion
tagged with: java-2d
linked to: http://stackoverflow.com/q/21507506
has comment: http://stackoverflow.com/comment/32565872
accepted answer: http://stackoverflow.com/a/21921645
tagged with: swing
has comment: http://stackoverflow.com/comment/32536537
type: Question
tagged with: java

http://stackoverflow.com/q/21569725
answer count: 1
has title: How to select a region of an image during drawing in LWGJL?
score: 0
tagged with: textures
type: AnsweredQuestion
tagged with: lwjgl
type: Question
tagged with: java
has body: I am trying to select a specific region of a texture in LWJGL during the drawing process, but my efforts have been fruitless. How (if possible) can I select only a region of a whole texture during drawing. Please note that I am nowhere new to Java, I am an experienced programmer, but not when it comes to LWGJL, as I'm still getting the full grasps with it. Below is my code. Sprite.java public class Sprite { private Icon icon; private int width; private int height; private int offcutX; // all below and this for selecting the region of the image. private int offcutY; private int imageX; private int imageY; public Sprite(TextureRegistry registry, String ref) { this(registry, ref, 0, 0, 0, 0); } public Sprite (TextureRegistry registry, String ref, int offcutX, int offcutY, int imageX, int imageY) { try { icon = registry.getIcon("net/blockbuster/resources/" + ref); // loads the icon and converts it to opengl-readable format. width = icon.getIconWidth(); height = icon.getIconHeight(); this.offcutX = offcutX; this.offcutY = offcutY; this.imageX = imageX; this.imageY = imageY; } catch (IOException e) { e.printStackTrace(); System.exit(-1); } } public int getWidth() { return icon.getIconWidth(); } public int getHeight() { return icon.getIconHeight(); } public void draw(int x, int y) // drawing method, called on every loop. { glPushMatrix(); icon.bind(); glTranslatef(x, y, 0); glBegin(GL_QUADS); { // I would like to be able to do this within this block. glTexCoord2f(0, 0); glVertex2f(0, 0); glTexCoord2f(0, 1); glVertex2f(0, height); glTexCoord2f(1, 1); glVertex2f(width, height); glTexCoord2f(1, 0); glVertex2f(width, 0); } glEnd(); glPopMatrix(); } } TextureRegistry.java public class TextureRegistry { private HashMap&lt;String, Icon&gt; table = new HashMap&lt;String, Icon&gt;(); // map to hold all loaded textures public Icon getIcon(String resourceName) throws IOException { Icon tex = table.get(resourceName); if (tex != null) { return tex; } tex = getIcon(resourceName, GL_TEXT…
has answer: http://stackoverflow.com/a/21570598
accepted answer: http://stackoverflow.com/a/21570598

http://stackoverflow.com/a/50882857
score: 32
type: Answer
has comment: http://stackoverflow.com/comment/90955495
has comment: http://stackoverflow.com/comment/124240537
has comment: http://stackoverflow.com/comment/116323186
has body: if you use spring data jpa , spring boot you can add this line in application.properties spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
answers question: http://stackoverflow.com/q/21574236
has comment: http://stackoverflow.com/comment/137162427
has comment: http://stackoverflow.com/comment/133499003
upvote count: 37
downvote count: 5

http://stackoverflow.com/q/21545063
score: -5
tagged with: java
downvote count: 5
has comment: http://stackoverflow.com/comment/32535818
type: Question
upvote count: 0
has comment: http://stackoverflow.com/comment/32536118
has title: Convertings mills to hh mm ss
has answer: http://stackoverflow.com/a/21545115
has body: import java.util.Scanner; public class Mills { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter milliseconds"); long mills= sc.nextLong(); System.out.println(convertMillis(mills)); } public static String convertMillis(long millis){ long s = (millis / 1000) % 60; long m = (millis / (1000 * 60)) % 60; long h = (millis / (1000 * 60 * 60)) % 24; String time = String.format("%02d:%02d:%02d:%d",s,m,h); return time; } } I am stuck, I don't know what to do after. Exception in thread "main" java.util.MissingFormatArgumentException: Format specifier 'd' at java.util.Formatter.format(Unknown Source) at java.util.Formatter.format(Unknown Source) at java.lang.String.format(Unknown Source) at Mills.convertMillis(Mills.java:19) at Mills.main(Mills.java:10)
answer count: 3
has answer: http://stackoverflow.com/a/21545175
linked to: http://stackoverflow.com/q/4142313
has comment: http://stackoverflow.com/comment/32535632
favorite count: 0
linked to: http://stackoverflow.com/q/625433
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21545129
has comment: http://stackoverflow.com/comment/32535661

http://stackoverflow.com/a/21529513
upvote count: 7
downvote count: 0
answers question: http://stackoverflow.com/q/21529448
has body: Yes, the database parameter may be omitted: String url = "jdbc:mysql://" + host + ":" + port;
type: Answer
score: 7

http://stackoverflow.com/q/21539055
has answer: http://stackoverflow.com/a/21539746
possible better answer: http://stackoverflow.com/a/21539064
has answer: http://stackoverflow.com/a/21539082
has answer: http://stackoverflow.com/a/21539064
score: 0
tagged with: android
answer count: 7
favorite count: 0
has answer: http://stackoverflow.com/a/21539106
accepted answer: http://stackoverflow.com/a/21539082
has title: Is it possible the condition in IF ELSE statement is a method?
upvote count: 1
downvote count: 1
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21539159
tagged with: java
has answer: http://stackoverflow.com/a/21539080
has body: i was wondering if its possible for method to be the condition in if else statements. i have a method called takephoto(). if takephoto() was successfully done it will do another method. i did it this way if (takephoto() == true) { anothermethod(); } i get an error that says The operator == is undefined for the argument type(s) void, boolean for the line if (takephoto() == true) this is my takephoto()method public static void takePhoto() { if(camera != null) { camera.takePicture(null, null, pictureTakenHandler); } }
type: Question
has answer: http://stackoverflow.com/a/21539514

http://stackoverflow.com/comment/106543545
comment on: http://stackoverflow.com/a/25246396
type: Comment
score: 1
has text: that this entity doesnt exist anymore... the transaction that created it was rollbacked
type: AnswerComment

http://stackoverflow.com/q/21609400
has body: I am having an issue with Dates and timezones. I have a MySQL InnoDB database which holds two fields DATE(yyyy-MM-dd) and TIME(HH:mm:ss). These are known as to be UTC (0 GMT). My computer is based in CET (+1 GMT). • dateObject is the result from this resultSet.getTime("date_field") (java.sql.Date) • timeObject is a result from this resultSet.getDate("time_field") (java.sql.Time) In the database DATE is stored as 2014-02-22 and TIME 15:00 System.out.println("Untouched "+dateObject+" "+timeObject); long date = dateObject.getTime(); long time = timeObject.getTime(); System.out.println("Touched "+new Date(date+time)); Results in the following output: Untouched 2014-02-22 15:00:00 Touched Sat Feb 22 14:00:00 CET 2014 Why is one hour being skipped off the Touched output? I was expecting the following: Untouched 2014-02-22 15:00:00 Touched Sat Feb 22 15:00:00 CET 2014 To rumble things up I have tried with the following also: SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); System.out.println(sdf.format(new Date(date+time))); And result: 2014-02-22 14:00:00 All in all. I am expecting GMT+1 to show 16:00(local) and GMT+0 to display 15:00
type: AnsweredQuestion
upvote count: 3
tagged with: java
tagged with: mysql
has comment: http://stackoverflow.com/comment/32649596
type: Question
score: 3
has title: Java: Date/Time from Database to milliseconds, hour disappearing
accepted answer: http://stackoverflow.com/a/21609660
tagged with: date
has comment: http://stackoverflow.com/comment/32649620
has comment: http://stackoverflow.com/comment/32649595
answer count: 2
possible better answer: http://stackoverflow.com/a/21610742
downvote count: 0
has answer: http://stackoverflow.com/a/21610742
favorite count: 0
has comment: http://stackoverflow.com/comment/32649520
linked to: http://stackoverflow.com/q/21604194
tagged with: datetime
has answer: http://stackoverflow.com/a/21609660

http://stackoverflow.com/q/21640881
has body: For those who aren't familiar, the game is a number guessing game, where a number is chosen (non repeating; e.g 1223 is NOT chosen) and the user makes a guess and obtains information whether the number AND digit is correct, number is correct but in a wrong digit, or the number is not contained. http://en.wikipedia.org/wiki/Bulls_and_cows (e.g number chosen => 1234, guessing 3789 will give 1 cow) Instead of the computer choosing the number and telling the properties and player guesses, I would like to do the reverse; I type in a number and the properties - the computer gives a list of possible numbers. Anyways, my method is: Add all numbers that do not repeat itself to the arraylist Delete numbers that do not satisfy the conditions. Here is how the cow cases are done : //Case 5: property is 4 cows; if (property.equals("040")) { //delete if numbers don't appear EXACTLY 4 times if (contains != 4) { numbers.remove(i); } //removes if the digits of the number tried corresponds with the actual number (Cow!) else if (n.charAt(0) == first.charAt(0)) { numbers.remove(i); } else if (n.charAt(1) == second.charAt(0)) { numbers.remove(i); } else if (n.charAt(2) == third.charAt(0)) { numbers.remove(i); } else if (n.charAt(3) == fourth.charAt(0)) { numbers.remove(i); } } It has worked for cows. Upon trying to implement bulls, it seems like using this sort of approach won't be possible. How can I do a method for bulls!? Would I need to create four more arraylists and calculate for each case? Or is ArrayList not the way to go? For example, 1234 with 1bull would mean the number to guess is 1XXX, X2XX, XX3X or XXX4 but I can't use this approach as it will delete all number except the input. Thanks.
tagged with: reverse-engineering
has title: Bulls and Cows game?
type: AnsweredQuestion
tagged with: java
type: Question
possible better answer: http://stackoverflow.com/a/28700426
has answer: http://stackoverflow.com/a/28700426
score: 0
has answer: http://stackoverflow.com/a/21641261
answer count: 3
accepted answer: http://stackoverflow.com/a/21641261
has answer: http://stackoverflow.com/a/55643432

http://stackoverflow.com/comment/32629344
comment on: http://stackoverflow.com/q/21597735
has text: Note that you have two `if` in one line, and without brackets, the `else` will always be an else to the last if. Maybe this is the problem. Try fixing your indentation and/or adding brackets to see the true structure of that "if-else-tree". Also, try to replace that second `if` in the same line with `&&` in the first if`s condition.
type: Comment
type: QuestionComment
score: 1

http://stackoverflow.com/comment/32520275
type: Comment
comment on: http://stackoverflow.com/a/21535241
has text: You can also override `mouseEntered` and do something when the mouse enters the panel. Also `mouseExited`
type: AnswerComment
score: 0

http://stackoverflow.com/comment/32718198
has text: @user3144349 your edit isn't absolutely clear to me, however you don't want to hit the url directly with htmlunit. You fill in the form as a step by step process and invoke submit (or a js or an Ajax call) and that's it. You can refer to its documentation as it aligns to your requirement
comment on: http://stackoverflow.com/a/21648146
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/21626579
has answer: http://stackoverflow.com/a/21626715
tagged with: java
has title: Singly Linked List nullpointerexception
has answer: http://stackoverflow.com/a/21626614
has answer: http://stackoverflow.com/a/21626640
possible better answer: http://stackoverflow.com/a/21626614
has body: I'm trying to write a method that removes all instances of a value from a singly linked list, but I'm having some trouble. I'm receiving a nullpointerexception on line 8 of this code: public void remove (int value) { IntegerNode temp=head; while (temp !=null) { if (temp.value == value) { temp.next = temp.next.next; count--; } temp=temp.next; } } Not certain what it is I'm doing that's bringing up this error...
has answer: http://stackoverflow.com/a/21626730
score: 0
has answer: http://stackoverflow.com/a/21627381
accepted answer: http://stackoverflow.com/a/21626730
answer count: 5
type: Question
type: AnsweredQuestion

http://stackoverflow.com/q/21664094
has comment: http://stackoverflow.com/comment/32745913
upvote count: 0
answer count: 1
tagged with: arrays
tagged with: while-loop
favorite count: 0
has comment: http://stackoverflow.com/comment/32745605
accepted answer: http://stackoverflow.com/a/21664519
downvote count: 1
has body: I'm having trouble with my online lab, I'm given this code below and I can only modify the places where it says '// FIX ME'. I've already added the following answers in the blanks but I still don't have it quite right. I was thinking about writing another code on top asking for how many items I would like to input and then creating a DO Loop centered around that but this isn't what the question wants from me. It's possible that I'm just looking at this the wrong way, any help would be appreciated! Here is the Lab; The following program should input a list of items, including the description of the item, the number of items purchased and the unit price of the item; then calculate the total bill. The input of the list is complete when "Finish" is entered for the description. Complete the program so that it works correctly. import java.util.Scanner; public class CalculateBill { public static void main( String[] args ) { double sum = 0; double cost; int items; double unitPrice; Scanner scan = new Scanner(System.in); System.out.println("Please enter the name of the item (Finish to end):"); String description = scan.next(); while( items != 0 ) { // FIX-ME System.out.println("Please enter the quantity of " + description + ": " ); items = scan.nextInt(); System.out.println("Please enter the unit price of " + description + ": "); unitPrice = scan.nextDouble(); cost = Price++ ; // FIX-ME System.out.printf("Cost of %d %s(s) is $%.2f%n", items, description, cost); sum = sum+1; // FIX-ME System.out.println("Please enter the name of the item (Finish to end):"); description = scan.next(); } System.out.printf("The total bill is $%.2f%n" ??? ); // FIX-ME } }
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21664519
tagged with: java
score: -1
type: Question
has comment: http://stackoverflow.com/comment/32745645
has title: Calculating Bill (Array and Do Loop for Java)

http://stackoverflow.com/comment/32743325
type: QuestionComment
comment on: http://stackoverflow.com/q/21662932
score: 3
has text: read this: http://en.wikipedia.org/wiki/Projectile_motion
type: Comment

http://stackoverflow.com/comment/32737998
has text: I've tried to add `synchronized` but the result is always the same; so I will try with a loop
type: Comment
comment on: http://stackoverflow.com/a/21648925
score: 0
type: AnswerComment

http://stackoverflow.com/a/21539381
has comment: http://stackoverflow.com/comment/32526717
type: Answer
has comment: http://stackoverflow.com/comment/32527245
answers question: http://stackoverflow.com/q/21539211
score: 3
has comment: http://stackoverflow.com/comment/32527051
downvote count: 0
has comment: http://stackoverflow.com/comment/32526576
has body: You're main problem comes down to two main issues... 1- You are using a KeyListener KeyListeners are notorious for being problematic in that they only respond to keystrokes when the component they are registered to are focusable AND have focus. 2- You never call repaint from within the keyPressed method to request that the applet be repainted. You should avoid Applet as it is woefully out of date and generally not used by many people anymore. Instead use JApplet, in fact, I would recommend avoiding applets altogether until you understand the API better Don't call setSize on an applet, the size of applet is defined by the html tag it is created from. Don't call repaint or anything that might call repaint from within any paint method Don't override paint, it's too easy to break the paint chain (which you have) and for top level containers like Applet, isn't double buffered. In fact AWT generally isn't double buffered, which will cause flickering when the component is repainted. Instead, you should use something like a JPanel and override it's paintComponent method Don't use KeyListener, it has too many issues with focus. Instead, make use of the Key Bindings API which provides you with more control and a much more reusable API Take a look at: Creating a GUI With JFC/Swing Performing Custom Painting Painting in AWT and Swing For more details
upvote count: 3

http://stackoverflow.com/comment/32647547
has text: i did as you said but now when i ask for number of purchases it gives me one less input
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21605334
type: Comment

http://stackoverflow.com/q/21555936
upvote count: 6
accepted answer: http://stackoverflow.com/a/21560460
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32650785
has body: The soon to be introduced function literals in Java 8 use invokedynamic rather than being statically compiled. This seems to give the benefits of less compiled 'noise' in the emitted bytecode, which I'm assuming means comparably less compilation time (ignoring all of the other reasons that Scala compilation is slower), as well as less classes to load. Does anyone now if there are any plans to move Scala in this direction? If not, could someone elucidate on the reasons the Scala team aren't going to? This is kind of a follow on from question / point 9 in this question.
tagged with: java
has title: Scala lambdas implementation vs. Java 8
has comment: http://stackoverflow.com/comment/32554572
downvote count: 1
linked to: http://stackoverflow.com/q/6142068
type: Question
score: 5
tagged with: function
has comment: http://stackoverflow.com/comment/32573849
has answer: http://stackoverflow.com/a/21560460
answer count: 1
favorite count: 0
tagged with: scala
has comment: http://stackoverflow.com/comment/32555401
tagged with: lambda
tagged with: java-8

http://stackoverflow.com/comment/32540128
type: Comment
has text: This page will help you. http://stackoverflow.com/q/21545682/1098601
score: 0
comment on: http://stackoverflow.com/q/21546787
type: QuestionComment

http://stackoverflow.com/comment/32568210
comment on: http://stackoverflow.com/a/21562711
score: 0
type: AnswerComment
has text: Unfortunately it didn't help, I think my next thing to tackle are the light Model, View and Projection matrices. Because I think that is literally the only other thing now that could go wrong.
type: Comment

http://stackoverflow.com/a/21609822
type: Answer
upvote count: 3
answers question: http://stackoverflow.com/q/21609212
score: 3
downvote count: 0
has body: An efficient method is to use a StringBuilder: public static String removeFirst(char ch, String s) { int charPos = s.indexOf(ch); if (charPos &lt; 0) { return s; } return new StringBuilder(s).deleteCharAt(charPos).toString(); } Alternatively, concatenate the substring before the character and the substring after it: public static String removeFirst(char ch, String s) { int charPos = s.indexOf(ch); if (charPos &lt; 0) { return s; } return s.substring(0, charPos) + s.substring(charPos + 1, s.length()); } Or use the built-in String method replaceFirst(): public static String removeFirst(char ch, String s) { return s.replaceFirst(Pattern.quote("" + ch), ""); } Notes: The replaceFirst() method uses a regular expression to match, so you should make sure you properly quote the character to avoid problems with special characters that are meaningful in regular expressions (e.g. $). Instead of "" + ch you could use String.valueOf(ch) but I find that more of a mouthful (though more "correct"). If you're worried about making this code fast, I'd avoid using replaceFirst() as it's very slow - behind the scenes it compiles your expressions into regular expression patterns each time it's run. You ought to name your method removeFirst() and not removeAll(), otherwise it's going to be very confusing to the next developer!

http://stackoverflow.com/comment/32732541
type: Comment
type: QuestionComment
score: 3
has text: Anonymous classes: http://docs.oracle.com/javase/tutorial/java/javaOO/anonymousclasses.html
comment on: http://stackoverflow.com/q/21656769

http://stackoverflow.com/a/21599683
has comment: http://stackoverflow.com/comment/32632647
score: 0
has comment: http://stackoverflow.com/comment/32632853
has comment: http://stackoverflow.com/comment/32632803
type: Answer
has body: From the stacktrace above, it seems you need more dependencies. In your case the Java WordNet Library. http://mvnrepository.com/artifact/net.sf.jwordnet/jwnl Do you have this one inside your classpath?
answers question: http://stackoverflow.com/q/21598788
has comment: http://stackoverflow.com/comment/32667130

http://stackoverflow.com/comment/32578719
has text: @ClickUpvote Just use my example with the properties of the other question example.
type: Comment
comment on: http://stackoverflow.com/a/21518677
score: 0
type: AnswerComment

http://stackoverflow.com/a/21649470
type: AcceptedAnswer
downvote count: 0
score: 1
accepted answer of: http://stackoverflow.com/q/21610701
type: Answer
answers question: http://stackoverflow.com/q/21610701
has body: This question is much more easy to solve using W3C DOM as keshlam suggested. Here's my solution to update the value 4 to another value in the line &lt;parameter key="k" value="4"/&gt; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException;*/ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Element; public class XMLParser { public void modifyDocument(String inputXml) { try { FileInputStream file = new FileInputStream(new File(inputXml)); DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); Document xml…
upvote count: 1

math
tags question: http://stackoverflow.com/q/21664300
tags question: http://stackoverflow.com/q/21521807
tags question: http://stackoverflow.com/q/21642489
type: Tag
tags question: http://stackoverflow.com/q/21566824
tags question: http://stackoverflow.com/q/21586960
tags question: http://stackoverflow.com/q/21600878
tags question: http://stackoverflow.com/q/21562229
tags question: http://stackoverflow.com/q/21622451
tags question: http://stackoverflow.com/q/21662932
tags question: http://stackoverflow.com/q/21516811
tags question: http://stackoverflow.com/q/21561909
tags question: http://stackoverflow.com/q/21642862
tags question: http://stackoverflow.com/q/21633984
tags question: http://stackoverflow.com/q/21617162
tags question: http://stackoverflow.com/q/21647374
tags question: http://stackoverflow.com/q/21515341
tags question: http://stackoverflow.com/q/21658907
tag name: math
tags question: http://stackoverflow.com/q/21648073
tags question: http://stackoverflow.com/q/21653677
tags question: http://stackoverflow.com/q/21604850
tags question: http://stackoverflow.com/q/21621735
tags question: http://stackoverflow.com/q/21559951

http://stackoverflow.com/a/21641024
upvote count: 1
answers question: http://stackoverflow.com/q/21624965
has comment: http://stackoverflow.com/comment/32706955
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21624965
has body: But I don't want to prompt user for a path. Put it in a sub-directory of user.home1. Then after it is saved I strongly advise to display it to the user, using the Desktop2 API (so they can know where it is). As described in this answer to "Java Applet Download File". As described in this answer to "How can I display an HTML file as a web page?".
type: Answer
score: 1

http://stackoverflow.com/comment/32654876
has text: How come? Did you make another frame as child frame?
comment on: http://stackoverflow.com/a/21611788
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/21525631
score: 4
type: Answer
upvote count: 4
downvote count: 0
has body: The first output is correct, because the locks are granular to method calls. Your output describes the plausible execution which justifies your output: main calls dec(), grabs the lock, decrements, exits, releases the lock; other calls inc(); grabs the lock, increments, exits, releases the lock; main calls print(); grabs the lock, reads 0, exits, releases the lock; other calls print(), grabs the lock, reads 0, exits, releases the lock.
answers question: http://stackoverflow.com/q/21525372

http://stackoverflow.com/comment/32546888
type: QuestionComment
has text: just add recent data entered to the adapter of ACTV
comment on: http://stackoverflow.com/q/21551318
score: 0
type: Comment

http://stackoverflow.com/comment/32642956
comment on: http://stackoverflow.com/a/21605286
type: Comment
has text: The way you had it is a worse practice, IMO. Better to just get rid of that line entirely. I don't think I'm alone in this opinion: http://www3.nd.edu/~ccl/operations/condor/hostname.shtml
score: 2
type: AnswerComment

wifi
tag name: wifi
type: Tag
tags question: http://stackoverflow.com/q/21624534

http://stackoverflow.com/comment/32582330
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21570876
type: AnswerComment
has text: Thanks, let me give a go to creating the Book class.

http://stackoverflow.com/a/21702421
upvote count: 4
has comment: http://stackoverflow.com/comment/32812692
downvote count: 0
has comment: http://stackoverflow.com/comment/44222744
has comment: http://stackoverflow.com/comment/44223480
has body: createDecipher actually does not use a key as you do in Java. It uses a password, which is fed into a Password Based Key Derivation Function (PBKDF) to derive the key. Hence with a different key and no method of checking the correctness of the key, you will get random plain text. The Node.js API is not very well named, the functions createDecipher and createDecipheriv suggest that the latter is just the same as the former, with the addition of an IV. Instead, createDecipher adds an entire key derivation function to the mix.
score: 4
accepted answer of: http://stackoverflow.com/q/21655286
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32843793
answers question: http://stackoverflow.com/q/21655286
type: Answer

http://stackoverflow.com/comment/32744969
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21663766
score: 1
has text: Well the problem will most probably be that you are putting `Double`s in and `equals` on doubles is always tricky. Could you post the testing data to reproduce the problem?

http://stackoverflow.com/q/21579733
has answer: http://stackoverflow.com/a/21579934
has answer: http://stackoverflow.com/a/21580233
answer count: 3
tagged with: sqlite
favorite count: 0
tagged with: android
accepted answer: http://stackoverflow.com/a/21579934
linked to: http://stackoverflow.com/q/2279706
type: AnsweredQuestion
score: 0
upvote count: 1
has title: Retrieving random data from SQLite
downvote count: 1
has body: I want to design a language learning Android application where random set of questions are retrieved from the database and displayed to the user. I have different type of questions such as multiple choice questions, fill in the blanks, matching the correct choice, arranging the words into a proper sentence and listening to audio and answering the comprehension questions. How to store these different types of questions in the database and retrieved randomly and displayed to the user to be answered? I am using SQLite.
has answer: http://stackoverflow.com/a/21579811
type: Question
tagged with: java
possible better answer: http://stackoverflow.com/a/21579811

http://stackoverflow.com/comment/32772654
score: 0
type: Comment
type: QuestionComment
has text: Sorry, I am as new to posting as I am to programming. I don't know what part the code if relevant or irrelevant to my issue. Not sure that I have the displayContacts right anywhere in the class to even be able to call it correctly from main. When I try to add in another else statement to call the method from the Personal class it tells me: non-static method displayContact() can not be referenced from a static content. This is what I am putting at the end of main if else(type == 3); PersonalContact.displayContacts();
comment on: http://stackoverflow.com/q/21668268

http://stackoverflow.com/comment/32669192
score: 0
comment on: http://stackoverflow.com/q/21620329
type: Comment
type: QuestionComment
has text: Check out this http://www.hscripts.com/tutorials/regular-expression/metacharacter-list.php

http://stackoverflow.com/comment/32571135
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21564692
has text: Apparently he is trying to pass default values to the 4th ("full") constructor with the 3 parameters.
score: 0

http://stackoverflow.com/a/21619457
type: Answer
has comment: http://stackoverflow.com/comment/32668116
score: 0
answers question: http://stackoverflow.com/q/21619114
has body: Seems like there's a misunderstanding of the base requirements. Consider this: you want to remove all but the last element from the list. Mutating the list (or sublist) is a bad idea, since what that results in is state not defined by natural recursion. That said, let's throw out a few things: Treat the List passed in as final - that's to say that you can't reassign to it or modify it safely. Deplete the list as you recurse down. Each slice should be one less than the slice above it. Return a List only containing that slice. Don't care about how large the list is, either. Recursion should be able to work as deep as the call stack will allow you. That said...consider this: private static &lt;Type&gt; List&lt;Type&gt; listToReverse(int index, final List&lt;Type&gt; list) { final List&lt;Type&gt; reversedList = new ArrayList&lt;&gt;(); if(index == list.size()) { return reversedList; } else { reversedList.addAll(listToReverse(index++, list.subList(index, list.size()))); reversedList.add(list.get(index - 1)); } return reversedList; } I intentionally made this generic and left out the public invocation as exercises to the reader. Bear in mind the base case - if the current "index" location I'm reading is equivalent to the size of the list itself, I've got nothing to do, so I can safely return the empty list. From there, I then progressively begin adding elements from index 0 to size - 1. E.g. If I make this recursive call with my index starting position at 0, then by the time I've hit the size of my list, I'm adding the element at size - 1 into the list.

http://stackoverflow.com/q/21533748
tagged with: android
has body: After using this code: public void getContent() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); try { startActivityForResult(intent, REQUEST_CODE_GET_CONTENT); } catch (ActivityNotFoundException e) { // No compatible file manager was found. Toast.makeText(this, R.string.no_filemanager_installed, Toast.LENGTH_SHORT).show(); } } the phone pops up a window where you can choose between audio or images file. I just want the audio and I don't want that the user can choose the image files. how can I do to not show this window and automatically go to audio selection?
tagged with: android-intent
tagged with: audio
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21533779
has title: how can I use GET_CONTENT for audio only?
tagged with: java
tagged with: file
type: Question
score: 0
has answer: http://stackoverflow.com/a/21533779
answer count: 1

http://stackoverflow.com/q/21645869
favorite count: 0
has answer: http://stackoverflow.com/a/21647467
type: Question
tagged with: keystore
has title: How can one obtain both non-repudiation and digital signature certificates?
accepted answer: http://stackoverflow.com/a/21647467
answer count: 2
possible better answer: http://stackoverflow.com/a/21736459
upvote count: 1
has answer: http://stackoverflow.com/a/21736459
tagged with: java
tagged with: ssl
has body: For a Public Key Infrastructure (PKI) client, it is required to obtain both non-repudiation and digital signature certificates. The following code has been implemented to obtain those certificates: keyStore.load(null, null); Enumeration&lt;String&gt; aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { String alias = aliases.nextElement(); if (keyStore.isKeyEntry(alias)) { java.security.cert.Certificate certificate = keyStore.getCertificate(alias); } } However, both digital and non-repudiation certificates have the same alias. so when keystore.getCertificate was called, the system will always return the first result, although in the certmgr.msc window, it was observed that there were 2 certificates, and the LOOP block executed two times, but the system will always return duplicate result from the first certificate. How can one resolve this issue?
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: pki

http://stackoverflow.com/q/21548741
has answer: http://stackoverflow.com/a/21556274
has title: Replace "\'" with any other character with String's replace()
answer count: 6
tagged with: replace
downvote count: 0
has answer: http://stackoverflow.com/a/21548968
has answer: http://stackoverflow.com/a/21548902
tagged with: string
favorite count: 0
score: 8
has answer: http://stackoverflow.com/a/21549024
upvote count: 8
type: UnansweredQuestion
has body: I can't do a simple operation with String, replace \' with *. Example: t'est\' -> t'est* I have tried with replace and replaceAll methods: String s has the value: "t'est\'"; s.replaceAll("\'", "*"); -&gt; result: t*est* s.replaceAll("\\'", "*"); -&gt; result: t*est* s.replaceAll("\\\'", "*"); -&gt; result: t*est* s.replaceAll("\\\\'", "*"); -&gt; result: t'est' s.replace("\'", "*"); -&gt; result: t'est' s.replace("\\'", "*"); -&gt; result: t'est' s.replace("\\\'", "*"); -&gt; result: t'est' s.replace("\\\\'", "*"); -&gt; result: t'est' But I don't get the result t'est* in any case.
tagged with: java
tagged with: special-characters
type: Question
has answer: http://stackoverflow.com/a/21548792
has comment: http://stackoverflow.com/comment/32542113
has answer: http://stackoverflow.com/a/21548848

izpack
tag name: izpack
tags question: http://stackoverflow.com/q/21575945
type: Tag
tags question: http://stackoverflow.com/q/21674778

http://stackoverflow.com/a/21633569
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/32692150
accepted answer of: http://stackoverflow.com/q/21632736
answers question: http://stackoverflow.com/q/21632736
score: 4
upvote count: 4
has body: I would look at this answer. In short its a known problem with Ubuntu. From their site on the subject. "The problem happens because Xorg takes a conservative approach to copying. It copies only a reference to the original data when the user performs a select or copy. It doesn't go and retrieve the actual data from the source program until the user requests a paste. It saves a lot of unneeded transfer of data this way, at the expense of having no way of retrieving data from a closed program that hasn't saved its clipboard somewhere else. "
type: AcceptedAnswer

http://stackoverflow.com/a/21659416
type: Answer
answers question: http://stackoverflow.com/q/21658569
has body: Depending what do you mean by efficient. You have many options and much depends on the types of the queries. For example if efficient means more scientific, then the possibility is to try to match the query to Wikipedia concept and then use TFIDF to calculate the distance between the Yahoo answers and Wiki document. The one with the higher similarity have higher importance, etc. link: http://en.wikipedia.org/wiki/Vector_space_model You can implement more weighting schemes as well and then use a combination of them to get the final weighting of the answers.
score: 0

http://stackoverflow.com/a/21605735
answers question: http://stackoverflow.com/q/21605431
score: 0
type: Answer
has body: You should change your data structure. new Object[]{412, 491, 312, 265, 295, 253, 278} //this will return an array of objects and now you store it in a list as a object: ArrayList&lt;Object&gt; List = new ArrayList&lt;Object&gt;(); then your problem is you cant access it. Change to: ArrayList&lt;Object[]&gt; List = new ArrayList&lt;Object[]&gt;(); and then you can print it out like this: for(Object[] objarray : List) for(Object number : objarray) System.out.println(number);

http://stackoverflow.com/comment/32696517
type: Comment
comment on: http://stackoverflow.com/a/21636125
has text: gives me a IllegalArgumentException :/
score: 0
type: AnswerComment

http://stackoverflow.com/a/21546630
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/97455733
type: Answer
score: 3
accepted answer of: http://stackoverflow.com/q/21546128
has body: Your aspect is wrong. You are returning void from your @Around method making every method that this aspect touches return null. Around aspects must always return Object and you must always return the result of the call to proceed(). If you don't you will run into trouble. @Around("execution(* org.springframework.jdbc.core.JdbcOperations.*(String, ..))") public Object log(final ProceedingJoinPoint jp) throws Throwable { Object[] methodArgs = jp.getArgs(), sqlArgs = null; CustomUser customUser = (CustomUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); methodArgs[0] = new String ("SELECT * FROM (" + methodArgs[0] + ") AS domain_object WHERE (ktn = "+ customUser.getKtn() +") OR (ktn is NULL)"); return jp.proceed(methodArgs); }
answers question: http://stackoverflow.com/q/21546128
upvote count: 3
has comment: http://stackoverflow.com/comment/32596752

http://stackoverflow.com/comment/32484404
type: QuestionComment
has text: @MarkusA. Anonymous classes are implementations of existing class definitions. If you wanted both, you'd need a class defined with both as in your first example.
score: 0
comment on: http://stackoverflow.com/q/21515693
type: Comment

http://stackoverflow.com/comment/32574613
score: 0
type: AnswerComment
has text: excellent, thank you so much. I think that will help me complete my requirement
type: Comment
comment on: http://stackoverflow.com/a/21566101

http://stackoverflow.com/comment/32735719
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21653397
has text: It can be adjusted by using quotes as part of the delimiter like ','

http://stackoverflow.com/comment/32626332
has text: Use a typecast then.. You can type cast whatever comes out of iter.next() to a double. double var = (double)iter.next(); Although, if you have a Double ArrayList, you should be able to directly assign it to a double variable only if you are using a double Iterator like : Iterator < Double > ;
type: Comment
comment on: http://stackoverflow.com/a/21595731
score: 0
type: AnswerComment

http://stackoverflow.com/a/21546000
has comment: http://stackoverflow.com/comment/32538436
has comment: http://stackoverflow.com/comment/32537520
has comment: http://stackoverflow.com/comment/32538417
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/32537193
has comment: http://stackoverflow.com/comment/32537475
answers question: http://stackoverflow.com/q/21545933
score: 1
has comment: http://stackoverflow.com/comment/32537448
has body: Using String#split can do this, but it's not better solution. Actually it'll be vague and I wouldn't recommend using it for that purpose. Don't waste time about efficiency in this case, it's not significant, focus on logic and clarity. But note that working with regex is usually slower because it involves additional operations so you might want to keep startsWith. Your approach is fine, if you want to check if the String begins with "abc", String#startsWith was designed for that. You can easily measure the time that takes a code to run. Here what you can do: Create a big loop, inside it you can append the counter of it to some dummy String in order to simulate the Strings you want to check, then try to have startsWith once, and replaceAll after: for(int i = 0;i&lt;900000;i++) { StringBuilder sb = new StringBuilder("abc"); sb.append(i); if(sb.toString().startsWith("abc")) { ... } } long time = System.currentTimeMillis() - start; System.out.println(time); //Prints ~130 for(int i = 0;i&lt;900000;i++){ StringBuilder sb = new StringBuilder("abc"); sb.append(i); sb.toString().replaceAll("^abc", ""); } long time = System.currentTimeMillis() - start; System.out.println(time); //Prints ~730
downvote count: 1

http://stackoverflow.com/comment/32600502
score: 2
comment on: http://stackoverflow.com/q/21581253
has text: This sounds like a classpath issue. Sounds like you need to get the classpath ordered so ojdbc6.jar is at the front of the list.
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21577767
has comment: http://stackoverflow.com/comment/32633593
has comment: http://stackoverflow.com/comment/32634271
type: Answer
has body: The answer by @injecteer is correct (apart from the fact that he uses com.lowagie classes which tells me he is using an obsolete version of iText), but he suggests creating the final PDF in two passes. First the PDF is created without a watermark, then it's created with a watermark. As @mkl indicates in his comment, you can create the PDF in one go if you use page events. I've written a small Watermarking example. This is the page event class: public class Watermark extends PdfPageEventHelper { protected Phrase watermark = new Phrase("WATERMARK", new Font(FontFamily.HELVETICA, 60, Font.NORMAL, BaseColor.LIGHT_GRAY)); @Override public void onEndPage(PdfWriter writer, Document document) { PdfContentByte canvas = writer.getDirectContentUnder(); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, watermark, 298, 421, 45); } } This event is added to the PdfWriter like this: PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(dest)); writer.setPageEvent(new Watermark()); From now on, the text defined in the Watermark event class will be added under the existing content every time a page is completed.
score: 1
answers question: http://stackoverflow.com/q/21575630
upvote count: 1
has comment: http://stackoverflow.com/comment/44808982
has comment: http://stackoverflow.com/comment/32632921
downvote count: 0

http://stackoverflow.com/q/21639465
has answer: http://stackoverflow.com/a/27048129
type: UnansweredQuestion
tagged with: jboss
tagged with: servlets
has body: I am trying to debug a servlet. After setting the break point and launching jboss in debug mode, the application hangs and eventually times out and throws a set of errors. 00:00:57,692 INFO [org.jboss.modules] JBoss Modules version 1.1.1.GA 00:00:58,404 INFO [org.jboss.msc] JBoss MSC version 1.0.2.GA 00:00:58,569 INFO [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting 00:01:01,251 INFO [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http) 00:01:01,252 INFO [org.xnio] XNIO Version 3.0.3.GA 00:01:01,290 INFO [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA 00:01:01,321 INFO [org.jboss.remoting] JBoss Remoting version 3.2.3.GA 00:01:01,392 INFO [org.jboss.as.configadmin] JBAS016200: Activating ConfigAdmin Subsystem 00:01:01,432 INFO [org.jboss.as.clustering.infinispan] JBAS010280: Activating Infinispan subsystem. 00:01:01,431 INFO [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers 00:01:01,491 INFO [org.jboss.as.security] (ServerService Thread Pool -- 42) JBAS013101: Activating Security Subsystem 00:01:01,512 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 46) JBAS015537: Activating WebServices Extension 00:01:01,588 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 36) JBAS011800: Activating Naming Subsystem 00:01:01,591 INFO [org.jboss.as.osgi] (ServerService Thread Pool -- 37) JBAS011940: Activating OSGi Subsystem 00:01:01,676 INFO [org.jboss.as.connector] (MSC service thread 1-1) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final) 00:01:01,851 INFO [org.jboss.as.security] (MSC service thread 1-1) JBAS013100: Current PicketBox version=4.0.7.Final 00:01:01,887 INFO [org.jboss.as.naming] (MSC service thread 1-6) JBAS011802: Starting Naming Service 00:01:01,913 INFO [org.jboss.as.mail.extension] (MSC service thread 1-6) JBAS015400: Bound mail session [java:jboss/mail/Default] 00:01:02,195 INFO [org.jboss.as.connector.subsystems.datasources] (Se…
has comment: http://stackoverflow.com/comment/32703164
tagged with: jboss7.x
type: Question
has title: Unable to start JBoss-as-7.1.1 in debug mode
linked to: http://stackoverflow.com/q/15001342
score: 0
tagged with: java
tagged with: eclipse
answer count: 1

http://stackoverflow.com/comment/32746260
score: 5
type: QuestionComment
comment on: http://stackoverflow.com/q/21664478
type: Comment
has text: `if(books[i] != null)` ?

http://stackoverflow.com/comment/32579585
has text: I understood that Runnables can't run on the UI thread, so they can't modify View objects. Doesn't it need to send a message to the UI thread to tell it to update the background color?
comment on: http://stackoverflow.com/a/21565618
score: 1
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32718632
comment on: http://stackoverflow.com/a/21641211
score: 0
type: Comment
type: AnswerComment
has text: Okay, this looks good but how can I set it up so that the user can choose which letter to input?

http://stackoverflow.com/a/21515727
has comment: http://stackoverflow.com/comment/32484557
upvote count: 1
has body: If you would like to learn about compression, I would suggest you start with something easier than the Jpeg Algorithm. In my jounger days, we started with Huffman and Shannon-Fano coding. But if you feel up to a more challenging start, you can also start with the matrix normalisation of a none lossless compression like jpeg. In any case, I would rather suggest you use the wikipedia as starting point, than SO.
score: 1
has comment: http://stackoverflow.com/comment/32493190
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21515552
has comment: http://stackoverflow.com/comment/32546155
accepted answer of: http://stackoverflow.com/q/21515552
type: Answer

http://stackoverflow.com/comment/32644887
type: Comment
type: QuestionComment
has text: What have you tried? What's wrong with it? (Asking folks to do your assignment/homework for you is going to draw down-votes. You need to show that you've made some reasonable amount of effort to learn and to solve the problem yourself.)
score: 4
comment on: http://stackoverflow.com/q/21606789

http://stackoverflow.com/comment/32644303
comment on: http://stackoverflow.com/a/21598484
type: Comment
has text: @Cruncher Hmm okay... Thought it was the method gc used to clean memory.
score: 0
type: AnswerComment

http://stackoverflow.com/q/21517974
linked to: http://stackoverflow.com/q/494465
tagged with: strong-references
score: 0
answer count: 1
tagged with: weakhashmap
tagged with: java-websocket
has answer: http://stackoverflow.com/a/21518027
type: AnsweredQuestion
has title: How to prevent a value from strongly referring to its key?
tagged with: java
accepted answer: http://stackoverflow.com/a/21518027
type: Question
has body: A much better programmer than me informed me that he holds a map of his WebSocket connections with java-websocket in a WeakHashMap. I've looked into that map for myself and it seems perfect since a connection will close without the thread responsible for holding the map being immediately aware thus allowing the closed connections to be garbage collected. In the docs, I noticed that "The value objects in a WeakHashMap are held by ordinary strong references. Thus care should be taken to ensure that value objects do not strongly refer to their own keys, either directly or indirectly, since that will prevent the keys from being discarded.". Does that mean that a value should never refer to its or any other key at all in the WeakHashMap so not to prevent garbage collection? And how exactly is a strong reference by a value to its key made? As an example, I need to hold a list of IP and DNS addresses associated with the key, a connection. How can I ensure that those are not strong references to the key's InetSocketAddress then InetAddress?

http://stackoverflow.com/comment/32483800
score: 0
type: Comment
type: QuestionComment
has text: Have you read http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation ?
comment on: http://stackoverflow.com/q/21515341

http://stackoverflow.com/comment/32506553
has text: Interesting! Thanks @Evgeniy
comment on: http://stackoverflow.com/a/21528591
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/21555602
has comment: http://stackoverflow.com/comment/32554089
has body: Change your 'max' method to this. You are comparing each row with the next one. e.g. 5,3,2,4,1 would end up as 4. You need to store the highest one, compare to that, and return the one you end up with. public static int max(int[] array) { if(array.length == 0) return; //array should have elements int maxt = array[0]; for(int i=1;i &lt; array.length;i++) { if(array[i] &gt; maxt) maxt = array[i]; } return maxt; }
score: 0
has comment: http://stackoverflow.com/comment/32554041
has comment: http://stackoverflow.com/comment/32553968
type: Answer
answers question: http://stackoverflow.com/q/21555393

http://stackoverflow.com/a/21519840
downvote count: 0
type: Answer
has body: Use this function to display label in pie-chart. private PieDataset createSampleDataset() { final DefaultPieDataset result = new DefaultPieDataset(); result.setValue("Java", new Double(20)); result.setValue("Visual Basic", new Double(20)); result.setValue("C/C++", new Double(20)); result.setValue("PHP", new Double(20)); result.setValue("Perl", new Double(20)); return result; } Look at this Example: package piechart3D; import java.text.AttributedString; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.labels.PieSectionLabelGenerator; import org.jfree.chart.plot.PiePlot3D; import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.PieDataset; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities; import org.jfree.util.Rotation; public class Piechart3D extends ApplicationFrame { public Piechart3D(final String title) { super(title); final PieDataset dataset = createSampleDataset(); final JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); } private PieDataset createSampleDataset() { final DefaultPieDataset result = new DefaultPieDataset(); result.setValue("Java", new Double(20)); result.setValue("Visual Basic", new Double(20)); result.setValue("C/C++", new Double(20)); result.setValue("PHP", new Double(20)); result.setValue("Perl", new Double(20)); return result; } private JFreeChart createChart(final PieDataset dataset) { final JFreeChart chart = ChartFactory.createPieChart3D( "3D Pie Chart", // chart title dataset, // data true, // include legend true, false ); final PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage("No data to display"); plot.setLabelGenerator(new CustomLabelGenerator() { @Override public…
answers question: http://stackoverflow.com/q/21519774
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/32491615

http://stackoverflow.com/a/21602660
has comment: http://stackoverflow.com/comment/32638196
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/32637495
accepted answer of: http://stackoverflow.com/q/21602506
has body: The factory pattern uses a factory to return objects of a base type. I expect what he was expecting was something like this: public abstract class AbstractBase() {} public class Concrete1 extends AbstractBase() {} public class Concrete2 extends AbstractBase() {} public class Factory() { enum BaseType { Type1, Type2 }; public static AbstractBase getObject(BaseType baseType) { if (baseType == Type1) { return new Concrete1(); } else if (baseType == Type2) { return new Concrete2(); } throw new IllegalArgumentException(); } }
has comment: http://stackoverflow.com/comment/32645079
upvote count: 3
score: 3
answers question: http://stackoverflow.com/q/21602506
has comment: http://stackoverflow.com/comment/32638573

http://stackoverflow.com/q/21546388
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21546642
has answer: http://stackoverflow.com/a/21546836
downvote count: 0
score: 1
tagged with: java
type: Question
tagged with: tomcat
has body: I would like to restart remote tomcat instance using batch file. Is it possible? flow: Stop tomcat execute some sql script start tomcat Is it possible? If so, could you please give me some insight to achieve this? Thanks!
tagged with: batch-file
answer count: 3
upvote count: 1
tagged with: windows
tagged with: cmd
has title: Restart remote tomcat using batch file to stop manual intervention to restart?
has answer: http://stackoverflow.com/a/33677517
favorite count: 0

http://stackoverflow.com/comment/32532120
comment on: http://stackoverflow.com/q/21542479
type: QuestionComment
score: 0
has text: Take a look at [How to use tables](http://docs.oracle.com/javase/tutorial/uiswing/components/table.html)
type: Comment

http://stackoverflow.com/a/21606165
answers question: http://stackoverflow.com/q/21606103
upvote count: 2
has comment: http://stackoverflow.com/comment/32643778
type: AcceptedAnswer
has body: It's not possible in the way you think it is. It is important to realize that Javascript is executed in the browser after your server has finished running the Java process that sends back the content. There is no connection between code that runs in Javascript and your JVM process on the server - this code is running in two different places. You are able to read Java session attributes in the Javascript when the server is generating the Javascript to send down the pipe to the user. But once the user's browser is executing the code, that code running on someone else's computer can't magically change values back on your server. You'll want to look into sending asynchronous HTTP requests from the user's browser (in JavaScript) to your server.
type: Answer
score: 2
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21606103

http://stackoverflow.com/a/21578066
has comment: http://stackoverflow.com/comment/32599976
has comment: http://stackoverflow.com/comment/32597626
has comment: http://stackoverflow.com/comment/32597194
has comment: http://stackoverflow.com/comment/32610961
has comment: http://stackoverflow.com/comment/32640116
has comment: http://stackoverflow.com/comment/32600364
score: 0
has comment: http://stackoverflow.com/comment/32601090
has comment: http://stackoverflow.com/comment/32603605
has body: You have the iText jar in your CLASSPATH, but you forgot to add the (correct) itext-asian.jar. Please download version 2.3 of the extra jars ZIP-file that is available here: http://sourceforge.net/projects/itext/files/extrajars/ This jar contains metrics for Chinese glyphs. Such a font will never be embedded. When you open a document using such a font in Adobe Reader, you may be asked to install an extra font pack.
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21577944
has comment: http://stackoverflow.com/comment/32600113
has comment: http://stackoverflow.com/comment/32597459
type: Answer
has comment: http://stackoverflow.com/comment/32599919
answers question: http://stackoverflow.com/q/21577944
has comment: http://stackoverflow.com/comment/32639988
has comment: http://stackoverflow.com/comment/32640391

http://stackoverflow.com/a/21654367
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21654300
has body: something like: SwingUtilities.invokeLater ( new Runnable ( public void run() { label.setText(lblText); } ) ); It needs to be in something like invokeLater to guarantee that it runs in the event dispatch thread. You'll need to get a reference of the label object down to the method that calls this, somehow.

http://stackoverflow.com/q/21557917
tagged with: inner-classes
accepted answer: http://stackoverflow.com/a/21557945
upvote count: 1
has comment: http://stackoverflow.com/comment/32558354
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32558379
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32559155
downvote count: 0
has body: I have defined the static inner class Tetromino but I am getting a compile error in the line: Tetrominoes.add(tetr); and I cannot figure out why. Am I missing something blatantly obvious? import java.util.ArrayList; public class Tetris{ public static void main(String[] args) { // TODO Auto-generated method stub } static class Tetromino { ArrayList&lt;Tetromino&gt; Tetrominoes = new ArrayList&lt;Tetromino&gt;(); Tetromino tetr = new Tetromino(); Tetrominoes.add(tetr); //This line generates an error } } In Eclipse, it underlines the line I stated above with red, however when I compile, It says: Exception in thread "main" java.lang.Error: Unresolved compilation problem: at Tetris.main(Tetris.java:5) where line 5 is my declaration of the main method.
answer count: 1
score: 1
has answer: http://stackoverflow.com/a/21557945
has title: Static inner class issue in Java
favorite count: 0

http://stackoverflow.com/comment/32673860
type: Comment
type: AnswerComment
has text: That worked but there is other problem now. My table is partially covering my graph.
comment on: http://stackoverflow.com/a/21623450
score: 0

http://stackoverflow.com/q/21625205
favorite count: 0
possible better answer: http://stackoverflow.com/a/21626623
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21627184
accepted answer: http://stackoverflow.com/a/21627184
downvote count: 0
score: 1
tagged with: java
type: Question
has title: Write own compiler on JVM with ASM Library, How ? First Steps?
has answer: http://stackoverflow.com/a/21626623
answer count: 2
upvote count: 1
has body: I want create own jvm language as university project ! after investigation I found ASM library HERE seems some languages in world use that for create own jvm language but my question is What is first steps for this purpose ? for example I want create syntax like this : public class A : B,IC,ID // Inheritance,Interfaces { public A(z:Integer) = // Constructor { } public Method(x:Integer,y:String):Float = // Method { } } How do I get started? focus on own Syntax or focus on language features Is ASM Library useful for that ? if yes , How can i found good tutorial for it ? ASM 4 User Guide is so complicated Is there any step by step tutorial for beginning ? please guide me for first steps Thanks
tagged with: jvm

http://stackoverflow.com/a/21547025
score: 1
has body: The formula contains matrix operations that are expensive to code from scratch each time. Use some matrix library like Jama, for instance, to perform matrix operations. Sums are trivial to compute. Also, some commercial packages like Maple can generate Java (C actually but conversion is easy) code to perform vector, matrix and other operations from the formulas like you give above.
has comment: http://stackoverflow.com/comment/32538881
downvote count: 0
answers question: http://stackoverflow.com/q/21546885
type: Answer
upvote count: 1

http://stackoverflow.com/a/21625173
has body: You are calling default hashCode() method from Object class, since you having overrides it. So, doen't matter, you call from sub class or super class, it internally calls Object's class hashCode() method. Reason for third one to be different, it's a called on new object. And it has different Virtual memory address, and Object class hashCode() methods returns it.
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/32677339
has comment: http://stackoverflow.com/comment/32677465
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/21625127

http://stackoverflow.com/a/21678307
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33828773
has comment: http://stackoverflow.com/comment/32773592
has comment: http://stackoverflow.com/comment/33832083
type: Answer
answers question: http://stackoverflow.com/q/21674522
score: 3
upvote count: 3
accepted answer of: http://stackoverflow.com/q/21674522
has body: This answer simply updates my answer from How to reuse saved classifier created from explorer(in weka) in eclipse java. I will show how to obtain the predicted instance value and the prediction percentage (or distribution). The example model is a J48 decision tree created and saved in the Weka Explorer. It was built from the nominal weather data provided with Weka. It is called "tree.model". import weka.classifiers.Classifier; import weka.core.Instances; public class Main { public static void main(String[] args) throws Exception { String rootPath="/some/where/"; Instances originalTrain= //instances here //load model Classifier cls = (Classifier) weka.core.SerializationHelper.read(rootPath+"tree.model"); //predict instance class values Instances originalTrain= //load or create Instances to predict //which instance to predict class value int s1=0; //perform your prediction double value=cls.classifyInstance(originalTrain.instance(s1)); //get the prediction percentage or distribution double[] percentage=cls.distributionForInstance(originalTrain.instance(s1)); //get the name of the class value String prediction=originalTrain.classAttribute().value((int)value); System.out.println("The predicted value of instance "+ Integer.toString(s1)+ ": "+prediction); //Format the distribution String distribution=""; for(int i=0; i &#60;percentage.length; i=i+1) { if(i==value) { distribution=distribution+"*"+Double.toString(percentage[i])+","; } else { distribution=distribution+Double.toString(percentage[i])+","; } } distribution=distribution.substring(0, distribution.length()-1); System.out.println("Distribution:"+ distribution); } } The output from this is: The predicted value of instance 0: no Distribution: *1, 0
has comment: http://stackoverflow.com/comment/33826669

http://stackoverflow.com/a/21598764
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/32631450
type: Answer
answers question: http://stackoverflow.com/q/21598414
upvote count: 1
has body: The size of the code in the question is small, so any implementation would be as efficient as the other. If the objType comes from different class instances, say TypeOne and TypeTwo, then you could overload the getConfig() method, e.g. public ConfigInterface getConfig(TypeOne type) { // Create and return the "one-type" object } public ConfigInterface getConfig(TypeTwo type) { // Create and return the "one-type" object } Otherwise, especially if there are many different types, consider creating an enum with all the possible values to objType, as opposed to using a string. You can then use a switch statement, which is more efficient than the consecutive string equals checks.

http://stackoverflow.com/comment/32555829
score: 0
comment on: http://stackoverflow.com/q/21556594
type: Comment
type: QuestionComment
has text: http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#prepareStatement(java.lang.String)

http://stackoverflow.com/q/21621449
score: 0
has comment: http://stackoverflow.com/comment/32671498
has comment: http://stackoverflow.com/comment/32671165
has comment: http://stackoverflow.com/comment/32671078
has body: The code below is what I have wrote for my assignment for class. I have not learned from the instructor yet about the arrays, and data. I have understood how to use the arrays, but not quite sure about the data yet. I have marked where I need help for the code below. Although I have managed to write it, still not sure if it is optimal. Could someone help me to better it perhaps? *I asked previously about finding the mode, and people told me to do it with the map implementation, I tried to do it, but my brain won't work for it.. any suggestions? ================================================================================= import java.util.Scanner; import java.util.Arrays; public class CodeVer2 { public static void main(String[] args) { Double num1, num2, num3, num4, num5, sum, avg; Scanner keyboard = new Scanner(System.in); System.out.println("Enter the first number:"); num1 = keyboard.nextDouble(); System.out.println("Enter the seond number:"); num2 = keyboard.nextDouble(); System.out.println("Enter the third number:"); num3 = keyboard.nextDouble(); System.out.println("Enter the fourth number:"); num4 = keyboard.nextDouble(); System.out.println("Enter the fifth number:"); num5 = keyboard.nextDouble(); keyboard.close(); double[] num = new double[5]; // array named num is declared with 5 variables num[0] = num1; num[1] = num2; num[2] = num3; num[3] = num4; num[4] = num5; Arrays.sort(num); double[] data = {num1, num2, num3, num4, num5}; // I need help from here, int mode = 0; int[] index = new int[999]; int maximum = Integer.MIN_VALUE; for (int i = 0; i &lt; data.length; i++){ index[(int) data[i]]++; } for (int i = 0; i &lt; index.length; i++){ if(maximum &lt; index[i]){ maximum = index[i]; mode = i; } } // to here. sum = num[0] + num[1] + num[2] + num[3] + num[4]; avg = sum/5; System.out.println(" "); System.out.println("Sum:" + sum); System.out.println("Avg:" + avg); System.out.println("Max:" + num[4]); System.out.println("Min:" + num[0]); System.out.println("Med…
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21621896
possible better answer: http://stackoverflow.com/a/21621902
has answer: http://stackoverflow.com/a/21621902
type: Question
tagged with: java
has title: Need aid with the code I wrote (need to understand)
answer count: 2
has answer: http://stackoverflow.com/a/21621896

http://stackoverflow.com/comment/32678427
has text: @Boann True. I fixed that. But at first i had no idea that the app is closing and opening a new connection with the server hence that problem wasn't easy to find at the first look.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21601422

http://stackoverflow.com/q/21655351
has title: get userid on Controller classes when hit ExceptionMappingAuthenticationFailureHandler
tagged with: spring-security
favorite count: 0
has body: I've already setup my spring security, something like below. I would like to get the user id in those controller classes so that I can update the fail count if there is a bad credential or i would like to redirect it to a reset password page is password already expired. Thanks in advance. &lt;beans:bean id="exceptionTranslationFilter" class="org.springframework.security.web.authentication.ExceptionMappingAuthenticationFailureHandler"&gt; &lt;beans:property name="exceptionMappings"&gt; &lt;beans:props&gt; &lt;beans:prop key="org.springframework.security.authentication.BadCredentialsException"&gt;/login_error&lt;/beans:prop&gt; &lt;beans:prop key="org.springframework.security.authentication.CredentialsExpiredException"&gt;/password_expired&lt;/beans:prop&gt; &lt;beans:prop key="org.springframework.security.authentication.LockedException"&gt;/locked&lt;/beans:prop&gt; &lt;beans:prop key="org.springframework.secuirty.authentication.DisabledException"&gt;/disabled&lt;/beans:prop&gt; &lt;/beans:props&gt; &lt;/beans:property&gt; &lt;/beans:bean&gt; &lt;http use-expressions="true"&gt; &lt;form-login login-page="/login" default-target-url="/" authentication-failure-handler-ref="exceptionTranslationFilter" /&gt; &lt;/http&gt;
tagged with: spring-mvc
downvote count: 0
type: UnansweredQuestion
score: 1
has answer: http://stackoverflow.com/a/21679319
tagged with: java
type: Question
linked to: http://stackoverflow.com/q/8676206
upvote count: 1
answer count: 1

http://stackoverflow.com/q/21575253
score: 2
type: AnsweredQuestion
tagged with: java
has body: Hello my code is throwing ClassCastException. The StackTrace is showing : java.lang.ClassCastException: java.util.Date cannot be cast to java.sql.Date at com.affiliate.DAO.AffiliateDAO.insertAffiliate(AffiliateDAO.java:48) ie @ ps.setDate(6, (Date) affiliate.getDate()); in DAO Below is my servlet: protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Affiliate af= new Affiliate(); af.setFisrtName(request.getParameter("txtFname")); af.setLastName(request.getParameter("txtLname")); af.setGender(request.getParameter("txtGender")); af.setCategory(request.getParameter("txtCategory")); String dob=(request.getParameter("txtDob")); SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); Date date; try { date = (Date)formatter.parse(dob); af.setDate(date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } af.setAge(Integer.parseInt(request.getParameter("txtAge"))); af.setAddress(request.getParameter("txtAddr")); af.setCountry("India"); af.setState(request.getParameter("txtState")); af.setCity(request.getParameter("txtCity")); af.setPinCode(Integer.parseInt(request.getParameter("txtPin"))); af.setEmailId(request.getParameter("txtEmail")); af.setStd(Integer.parseInt(request.getParameter("txtStd"))); af.setContactNo(Integer.parseInt(request.getParameter("txtPhone"))); af.setMobileNo(Long.parseLong(request.getParameter("txtMobile"),10)); AffiliateService afs=new AffiliateService(); **afs.createAffiliate(af);** } Below is my DAO: public void insertAffiliate(Affiliate affiliate){ String sql="INSERT INTO REGISTER " +"(id,FisrtName,LastName,Gender,Category,DateOfBirth,Age,Address,Country,State,City,PinCode,EmailId,Std,ContactNo,MobileNo)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; Connection conn = null; try { **conn = dataSource.createConnection();** PreparedStatement ps = conn.prepareStatement(sql); ps.setInt(1, affiliate.getId()); ps.setString(2, affiliate.getFisrtName()); …
type: Question
downvote count: 0
has answer: http://stackoverflow.com/a/21575363
has title: ClassCastException: java.util.Date cannot be cast to java.sql.Date
tagged with: sql
has answer: http://stackoverflow.com/a/21575337
has comment: http://stackoverflow.com/comment/32589538
has answer: http://stackoverflow.com/a/21575390
has comment: http://stackoverflow.com/comment/32589601
answer count: 4
favorite count: 0
upvote count: 2
possible better answer: http://stackoverflow.com/a/21575390
accepted answer: http://stackoverflow.com/a/21575363
has answer: http://stackoverflow.com/a/21575314

http://stackoverflow.com/q/21640493
score: 1
tagged with: java
has title: Java -- KeyReleased called immediately after KeyPressed event
type: Question
tagged with: keypress
has comment: http://stackoverflow.com/comment/32705664
has comment: http://stackoverflow.com/comment/32704964
upvote count: 1
has body: I'm trying to make a character move around on a simple frame when the user presses the four arrow keys (or wasd). The character should continue to move as long as the arrow key is held down and should cease movement once the user has released the key. For the most part, this is moving. However, I am getting some strange delay when rapidly switching directions. It looks as though, when I press the keyboard button, java's keylistener interprets this as a key "click", AKA rapid pressing and releasing, before determining that the button is actually being held down. As such, the player model stutters in its motion a little bit. Am I interpreting this correctly? Here is my code, if anyone can make sense of this. Code to handle a key release @Override public void keyReleased(KeyEvent e) { switch(e.getKeyCode()) { case KeyEvent.VK_W: case KeyEvent.VK_UP: case KeyEvent.VK_A: case KeyEvent.VK_LEFT: case KeyEvent.VK_S: case KeyEvent.VK_DOWN: case KeyEvent.VK_D: case KeyEvent.VK_RIGHT: GameController.hero.stopMoving(); break; case KeyEvent.VK_SPACE: break; case KeyEvent.VK_ESCAPE: break; } keyPress = false; } My code to handle a key press @Override public void keyPressed(KeyEvent e) { keyPress = true; keyCode = e.getKeyCode(); switch(e.getKeyCode()) { case KeyEvent.VK_W: case KeyEvent.VK_UP: GameController.hero.setSpeedBase(new Point(0,-1)); break; case KeyEvent.VK_A: case KeyEvent.VK_LEFT: GameController.hero.setSpeedBase(new Point(-1,0)); break; case KeyEvent.VK_S: case KeyEvent.VK_DOWN: GameController.hero.setSpeedBase(new Point(0,1)); break; case KeyEvent.VK_D: case KeyEvent.VK_RIGHT: GameController.hero.setSpeedBase(new Point(1,0)); break; } } I hope this is enough information. Any help is appreciated! Let me know if there is any clarification I can make. Is there an easier way to do this?
answer count: 1
has comment: http://stackoverflow.com/comment/32705625
favorite count: 0
has comment: http://stackoverflow.com/comment/32705192
tagged with: input
has answer: http://stackoverflow.com/a/34719360
downvote count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32705205
tagged with: keyevent
tagged with: keyrelease

http://stackoverflow.com/a/21544167
downvote count: 0
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/21544103
has body: Guava has a few helper methods to help you achieve this. In particular, Maps.filterKeys(Map, Predicate) // populate a Map Map&lt;Integer, Integer&gt; map = new HashMap&lt;&gt;(); map.put(3, 0); map.put(15, 42); map.put(75, 1234); // filter it Map&lt;Integer, Integer&gt; filtered = Maps.filterKeys(map, new Predicate&lt;Integer&gt;() { @Override public boolean apply(Integer input) { return input % 5 == 0; // filter logic } }); // get the values System.out.println(filtered.values()); prints [1234, 42] As Louis notes, "this isn't actually more efficient -- or even shorter -- than the "traditional" for-each approach."
has comment: http://stackoverflow.com/comment/32534268

http://stackoverflow.com/q/21562408
tagged with: java
has comment: http://stackoverflow.com/comment/32568640
type: Question
has comment: http://stackoverflow.com/comment/32567742
has body: While loading log4j from within Eclipse plugin (in forced programmatic mode) it says it can't find root logger information, while it presents. The SSCCE code is below. It is based on simplest available headless RCP application sample: package try_eclipsepluginlog4j_01; import java.io.IOException; import java.net.URL; import org.apache.log4j.PropertyConfigurator; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Platform; import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplicationContext; import org.osgi.framework.Bundle; /** * This class controls all aspects of the application's execution */ public class Application implements IApplication { static { try { Bundle bundle = Platform.getBundle("Try_EclipsePluginLog4j_01"); URL config1 = bundle.getEntry("/conf/log4j.sample.xml"); URL config2 = FileLocator.resolve(config1); PropertyConfigurator.configure(config2); org.apache.log4j.Logger log4j = org.apache.log4j.Logger.getLogger(Application.class); log4j.info("log4j is here"); } catch(IOException e) { } } // private static final Logger log = Logger.getLogger(Application.class); /* (non-Javadoc) * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) */ public Object start(IApplicationContext context) throws Exception { System.out.println("Hello RCP World!"); return IApplication.EXIT_OK; } /* (non-Javadoc) * @see org.eclipse.equinox.app.IApplication#stop() */ public void stop() { // nothing to do } } Configuration file is follows: &lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"&gt; &lt;log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"&gt; &lt;appender name="console" class="org.apache.log4j.ConsoleAppender"&gt; &lt;param name="Target" value="System.out"/&gt; &lt;layout class="org.apache.log4j.PatternLayout"&gt; &lt;param name="ConversionPattern" value="%-5p %c{1} - %m%n"/&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;…
has title: log4j: Could not find root logger information. Is this OK?
accepted answer: http://stackoverflow.com/a/21563784
tagged with: eclipse
score: 0
answer count: 1
tagged with: eclipse-plugin
tagged with: log4j
tagged with: eclipse-rcp
has answer: http://stackoverflow.com/a/21563784
type: AnsweredQuestion

http://stackoverflow.com/comment/32825389
type: QuestionComment
has text: Can you show the full pom file your plugin?
comment on: http://stackoverflow.com/q/21612945
score: 0
type: Comment

http://stackoverflow.com/comment/50527203
type: AnswerComment
comment on: http://stackoverflow.com/a/21628859
score: 4
type: Comment
has text: @Tim Not quite; `containsInAnyOrder` requires that *all* elements are present, so that first assertion will fail. See `hasItems` if you want to check that *at least* those elements are present.

http://stackoverflow.com/q/21654734
has answer: http://stackoverflow.com/a/21740223
tagged with: java
has answer: http://stackoverflow.com/a/21654784
type: Question
tagged with: asp-classic
has title: Modifying java/php
score: 0
answer count: 2
tagged with: http://stackoverflow.com/tag/html
has body: I want to modify this, because it only worked in .asp files, and now my document is in .php But this script,, it's annoying me. What i want to do is, calculating how many days has gone since year 1858 month 3 and day 21 Until now, and ofc it needs to say "Today the union has existed for "year" & "month" & days" Hope u can help! I dag har foreningen eksisteret i <%=DateDiff("yyyy",#1858-03-21#,#2014-01-01#)%> år og <% 'Noter at der er fratrukket 20 dage fra dage. Detta må korrigeres vid skudår!' %> <%=DateDiff("d",#2014-01-22#,now)%> dage
type: UnansweredQuestion
tagged with: php
tagged with: css

http://stackoverflow.com/comment/32489018
type: Comment
has text: This is now answerable and im sure rogiel will do a good job of it. For future reference always post at least a complete method. Usually a complete **short** program leads to immediate answers
comment on: http://stackoverflow.com/q/21518203
score: 0
type: QuestionComment

http://stackoverflow.com/a/21525740
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21525372
answers question: http://stackoverflow.com/q/21525372
type: Answer
has comment: http://stackoverflow.com/comment/32504515
score: 3
has body: Following code: counter.decrement(); counter.print("main thread"); is dangerous. While it in 99% prints the correct value of Counter.i, sometimes another thread can wedge in the gap between the first and second method calls. Better print the value inside decrement and increment methods. If you want just to print without changing the value, just the same use synchronized method or block, to avoid printing stale value. The outputs correspond to your program - if you think they are wrong, you program is wrong also. Please explain what you want.
upvote count: 3
has comment: http://stackoverflow.com/comment/32513857

http://stackoverflow.com/a/21642477
has body: boolean correctPosition=false; for (int i = 0; !correctPosition; ++i){ myArray.get(i).position = random Position if(myArray.get(i).position == 100){ correctPosition=true; //Success! }else{ //re-attempt to change position until it meets criteria } }
type: Answer
answers question: http://stackoverflow.com/q/21642448
score: 0

http://stackoverflow.com/a/21579583
score: 0
has body: The way the console reads passwords is by not displaying them in the console. If you test this and type where it says to, the console will read it, but not display it while you're typing.
answers question: http://stackoverflow.com/q/21579553
type: Answer

akka
type: Tag
tags question: http://stackoverflow.com/q/21551459
tag name: akka
tags question: http://stackoverflow.com/q/21675323
tags question: http://stackoverflow.com/q/21537476

http://stackoverflow.com/comment/32558121
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/21557794
has text: Try getting the response code from your `HttpURLConnection` object.

http://stackoverflow.com/a/21576145
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 1
upvote count: 1
accepted answer of: http://stackoverflow.com/q/21575919
answers question: http://stackoverflow.com/q/21575919
has body: try this: Runtime.getRuntime().exec("chmod 777 /Applications/XAMPP/xamppfiles/htdocs/project/images/directoryName");

http://stackoverflow.com/comment/32484311
comment on: http://stackoverflow.com/q/21515693
has text: Make `FooClass` implement `BarInterface`? I'm not sure what you mean.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21618676
score: -4
answers question: http://stackoverflow.com/q/21618041
has comment: http://stackoverflow.com/comment/39835717
downvote count: 4
upvote count: 0
has body: need to empty constructor public DataEntryObserver() { this.dLoader = null; }
type: Answer

http://stackoverflow.com/q/21576233
has body: I am currently working on an web app which has web services allowing user to upload xml files to server. I am using JAX-WS to create web services. All examples I've seen describe uploading image files. Hence web service would contain a method like: @WebMethod String uploadImage(Image data); However, in case if I am uploading XML file what would be the type of arguments for that method? @WebMethod String uploadXML(????? data);
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/21618979
tagged with: http://stackoverflow.com/tag/xml
type: UnansweredQuestion
tagged with: web-services
has title: JAX-WS XML file attachment
tagged with: java
tagged with: mtom
tagged with: jax-ws
type: Question

http://stackoverflow.com/a/21618115
answers question: http://stackoverflow.com/q/21617573
type: Answer
has body: I believe you're looking for a goto statement, but Java has no such thing--although it is a reserved word. But, if I understand you correctly, what you want to do can be accomplished by using a loop and a break. For example: while (true) { //ask the menu questions System.out.println("Did you mess up? Y/N"); // get input if (answer=='Y')//they did mess up, so run loop again { continue; //goes back to loop's header } else //they didn't mess up { //break out of the loop break; } }
score: 0

http://stackoverflow.com/q/21633246
upvote count: 3
has answer: http://stackoverflow.com/a/21633319
tagged with: java
has title: Is wait(1) in a non-blocking while(true)-loop more efficient than using wait() and notify()?
downvote count: 2
tagged with: loops
has comment: http://stackoverflow.com/comment/32696235
has comment: http://stackoverflow.com/comment/32695233
has body: Does a while(true) Java loop together with wait(1) use more or less resources than a blocking loop with wait() and notify()? And do the CPU cores have some special (hardware) implementations to allow wait(1)? If yes, are there any limitations while working with such non-blocking loops? An example: while(true){ wait(1); //do the job here... } (Just a note: Without the wait(1) a core would go radical 100% in a while(true) loop...)
tagged with: nonblocking
answer count: 4
has comment: http://stackoverflow.com/comment/32694512
has comment: http://stackoverflow.com/comment/32694241
has answer: http://stackoverflow.com/a/21633353
tagged with: wait
has comment: http://stackoverflow.com/comment/32691223
tagged with: notify
accepted answer: http://stackoverflow.com/a/21633319
type: AnsweredQuestion
score: 1
has answer: http://stackoverflow.com/a/21634840
favorite count: 0
type: Question
possible better answer: http://stackoverflow.com/a/21633906
has comment: http://stackoverflow.com/comment/32695483
has answer: http://stackoverflow.com/a/21633906
has comment: http://stackoverflow.com/comment/32694422

http://stackoverflow.com/a/21625473
downvote count: 0
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/32677415
has body: You could try this: View myView = View.inflate(this, R.layout.customize_dialog, null); AlertDialog.Builder builder=new AlertDialog.Builder(this); builder.setView(myView); builder.setTitle("Customize dialog"); builder.setCancelable(false); AlertDialog alert=builder.create(); alert.show(); You have to create a layout in res/layout/ called customize_dialog.xml, you can also add to "myView" other view object. To add tipical Alert button: builder.setPositiveButton("Ok",new OnClickListener(){ public void onClick(DialogInterface dialog, int id){ //action to do dialog.dismiss(); } }); builder.setNegativeButton("Close",new OnClickListener(){ public void onClick(DialogInterface dialog, int id){ //action to do dialog.dismiss(); } }); I hope it helps you.
answers question: http://stackoverflow.com/q/21623795
type: Answer

http://stackoverflow.com/a/21671198
has comment: http://stackoverflow.com/comment/32758093
has comment: http://stackoverflow.com/comment/32758124
has comment: http://stackoverflow.com/comment/32758436
answers question: http://stackoverflow.com/q/21670907
has body: From our discussions I understand that you are accessing the form fields as Struts1.x in struts2 its very easy if it is your JSP &lt;s:form action="Mssqltest"&gt; &lt;tr&gt; &lt;td&gt; &lt;s:textfield name="docKey" label="docKey"&gt;&lt;/s:textfield&gt; &lt;/td&gt; &lt;s:submit value="Get Records"&gt;&lt;/s:submit&gt; &lt;/tr&gt; &lt;/s:form&gt; when you want that docKey value in your Action class create a getters and setters in your Action class as the same name of the field in JSP page. like below private String docKey; public String execute(){ try { //HttpServletRequest request = ServletActionContext.getRequest(); Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); Connection connection = (Connection) DriverManager .getConnection( "jdbc:sqlserver://myipaddress:51433;databaseName=dbname;selectMethod=cursor", "user", "passwd"); System.out.println("DATABASE NAME IS:" + connection.getMetaData().getDatabaseProductName()); System.out.println(""); Statement statement = connection.createStatement(); ResultSet rs = statement .executeQuery("select createdOn,ReceivedOn,docKey from table where docKey=?"); rs.setString(1, Mssql.bean.getdocKey()); // I want to get that docKey value from jsp///// while (rs.next()) { //System.out.println("createdOn:" + rs.getString("createdOn")); bean bean = new bean(); bean.setdocKey(rs.getString("docKey")); bean.setcdate(rs.getString("createdOn")); bean.settstamp(rs.getString("ReceivedOn")); } } catch (Exception e) { e.printStackTrace(); } return "check"; } public String getDocKey() { return docKey; } public void setDocKey(String docKey) { this.docKey = docKey; } here in your class you are accessing docKey from some bean class that is the mistake you are doing wherever you are using the docKey you just use that with getDockey() it will return the value that has entered in JSP . Your getter and setter for docKey Change them to public String getDocKey() { return docKey; } public void setDocKey(String docKey) { this.docKey = docKey; } …
has comment: http://stackoverflow.com/comment/32757805
score: 0
has comment: http://stackoverflow.com/comment/32758031
type: Answer
has comment: http://stackoverflow.com/comment/32758445
has comment: http://stackoverflow.com/comment/32757878
has comment: http://stackoverflow.com/comment/32763199
has comment: http://stackoverflow.com/comment/32793963
has comment: http://stackoverflow.com/comment/32758338

http://stackoverflow.com/q/21516020
has body: I am writing my first Android application. I need to initialize a File in a non-static method with the path that is returned by getExternalCacheDirectory(). Here's the first part of the relevant code: public static void deleteNote(Integer id) { List&lt;Note&gt; savedNotes = Util.getSavedNotes(); savedNotes.remove(id); NoteRemover myRemover = new NoteRemover(); myRemover.write(savedNotes, id); } Here's my NoteRemover class: public class NoteRemover extends Activity{ public void write(List&lt;Note&gt; editedNotesList, Integer rnID) { //NullPointerExeption is thrown here: File notesDB = new File(getExternalCacheDir(), "notesDB.txt"); String Data; //unimportant code Util.setFtpTaskFlag(2); Util.setFtpDirectory(Util.FTP_NOTE_DIR); Util.writeFile(data, notesDB); Util.setFtpTaskFlag(3); File note = new File(getExternalCacheDir(), rnID.toString() + ".txt"); Util.deleteFile(note); Util.setFtpTaskFlag(-1); Util.setFtpDirectory(null);' } } } Here's the Errormessage: 02-02 21:41:24.354: E/AndroidRuntime(6552): FATAL EXCEPTION: main 02-02 21:41:24.354: E/AndroidRuntime(6552): java.lang.NullPointerException 02-02 21:41:24.354: E/AndroidRuntime(6552): at android.content.ContextWrapper.getExternalCacheDir(ContextWrapper.java:219) 02-02 21:41:24.354: E/AndroidRuntime(6552): at com.stracke.bandmanager.NoteRemover.write(NoteRemover.java:11) 02-02 21:41:24.354: E/AndroidRuntime(6552): at com.stracke.bandmanager.Notes.deleteNote(Notes.java:131) 02-02 21:41:24.354: E/AndroidRuntime(6552): at com.stracke.bandmanager.OptionsDialogFragment.doSelectedDialogAction(OptionsDialogFragment.java:52) 02-02 21:41:24.354: E/AndroidRuntime(6552): at com.stracke.bandmanager.OptionsDialogFragment.access$0(OptionsDialogFragment.java:25) 02-02 21:41:24.354: E/AndroidRuntime(6552): at com.stracke.bandmanager.OptionsDialogFragment$1.onClick(OptionsDialogFragment.java:18) 02-02 21:41:24.354: E/AndroidRuntime(6552): at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:941…
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32484850
tagged with: java
accepted answer: http://stackoverflow.com/a/21516088
has title: Android - getExternalCacheDirectory throws NullPointerException after being called from a static method
type: Question
answer count: 1
has comment: http://stackoverflow.com/comment/32484815
tagged with: static
score: 0
tagged with: nullpointerexception
tagged with: android
tagged with: android-activity
has answer: http://stackoverflow.com/a/21516088

http://stackoverflow.com/comment/32724350
score: 0
has text: That make so much more sense. It's running smoothly now. Thanks a lot!
type: Comment
comment on: http://stackoverflow.com/a/21651944
type: AnswerComment

http://stackoverflow.com/comment/32750649
type: AnswerComment
score: 0
type: Comment
has text: "could be a huge UTF-8 byte array that is read into memory in one swoop (or even accessed via a memory-mapped file)" - how can I use it?
comment on: http://stackoverflow.com/a/21665869

http://stackoverflow.com/a/21630410
has body: Im not sure if I understood your question correctly, but what about using switch for the checks this for the checks? public enum MyEnum { FIRST(0L), SECOND(1L), THIRD(2L); private Long number; private static Map&lt;Long, MyEnum&gt; byIds = new HashMap&lt;Long, PlaceServiceV2.MyEnum&gt;(); static{ for(MyEnum myEnum :MyEnum.values()){ byIds.put(myEnum.number, myEnum); } } private MyEnum(Long number){ this.number = number; } public static MyEnum getById(Long id) { return byIds.get(id); } public Long getId() { return number; } } public void test(){ switch (MyEnum.getById(1L)) { case FIRST: break; case SECOND: break; default: break; } }
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/32762753
answers question: http://stackoverflow.com/q/21630131
downvote count: 0
type: Answer

http://stackoverflow.com/a/21801927
accepted answer of: http://stackoverflow.com/q/21664968
answers question: http://stackoverflow.com/q/21664968
type: AcceptedAnswer
has body: DB people love to say that all your "business logic"* should be in the database. In practice, I haven't seen this work, but even if you don't subscribe to this principle there can be cases where you need to do intensive data manipulation; say, transforming text-based records in such a way that requires data from multiple tables per document transformation. Doing these kinds of things in the database (i.e. with stored procedures) saves you the serialization-network-deserialization-possible-ORM-etc hit, so it can occasionally be sensible. If you've already decided to do this, then doing it in Java if you have the option is 10000x better than doing it in PL/SQL which invokes cthulhu. *business logic meaning e.g. expiring/renewing customer subscriptions. data-intensive business logic might be some kind of data warehousing/statistics, I suppose.
upvote count: 1
type: Answer
downvote count: 0
score: 1

http://stackoverflow.com/a/21677667
type: Answer
has comment: http://stackoverflow.com/comment/32797172
upvote count: 4
answers question: http://stackoverflow.com/q/21676212
downvote count: 0
has comment: http://stackoverflow.com/comment/32777110
score: 4
has body: You can get it from two ways. 1) Either you get it from request or session In JSP Page write following code to get value. String value = session.getAttribute("libelle"); OR String value = request.getAttribute("libelle"); 2) you Can pass value in Ajax Response. on Servlet write following code. out.println(libelle); and in Ajax you will get data in response. $.ajax({ type: "post", url: "gerer_caf_adherente", data: "name=test", success: function(data){ alert(data); // your response will print here. } });

http://stackoverflow.com/comment/32683635
has text: Notice the ConcurrentModificationException from ListIterator. Your list was modified when your iterator was iterating.
type: Comment
comment on: http://stackoverflow.com/q/21628867
type: QuestionComment
score: 1

http://stackoverflow.com/a/21527060
score: 1
has comment: http://stackoverflow.com/comment/32531682
downvote count: 0
answers question: http://stackoverflow.com/q/21526799
has body: You can use your native language characters as JAVA identifiers if that characters are letters or digits (first character may by a letter only). To make sure if a character is a letter or digit, use Character.isLetter and Character.isDigit. Be careful to use encodings which support your characters. Best choice is UTF-8. In Strings, you can use any characters.
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/32503875
has comment: http://stackoverflow.com/comment/32570881

http://stackoverflow.com/q/21676958
tagged with: java
downvote count: 3
has comment: http://stackoverflow.com/comment/32767416
type: Question
has comment: http://stackoverflow.com/comment/32767328
has answer: http://stackoverflow.com/a/21677019
upvote count: 0
answer count: 1
favorite count: 0
type: UnansweredQuestion
score: -3
has body: how to get highest and lowest index position in Collections.binarysearch() through key value int curIndex = Collections.binarysearch(myList,"String"); int highIndex = ?
has title: Binary search index position

bukkit
tag name: bukkit
tags question: http://stackoverflow.com/q/21514927
tags question: http://stackoverflow.com/q/21551998
tags question: http://stackoverflow.com/q/21520673
type: Tag
tags question: http://stackoverflow.com/q/21521907

http://stackoverflow.com/comment/106508458
type: Comment
score: 8
comment on: http://stackoverflow.com/a/54012496
type: AnswerComment
has text: CF...cloud foundry? canadian forces?

http://stackoverflow.com/a/21659909
answers question: http://stackoverflow.com/q/21659695
has body: This is a simple sorting algorithm. We store the subscript value of the lowest age so we can swap it. for (int i = 0; i &lt; empList.size(); i++) { int smallest = i; for (int j = i; j &lt; numbers.length; j++) { if (empList.get(j).getAge() &lt; emplist.get(smallest).getAge()) smallest = j; } int temp = empList.get(i).getAge(); empList.set(i, empList.get(smallest)) empList.set(smallest, temp); }
score: 0
type: Answer

http://stackoverflow.com/q/21522875
has answer: http://stackoverflow.com/a/79020728
has answer: http://stackoverflow.com/a/21523073
favorite count: 0
has answer: http://stackoverflow.com/a/21523068
has answer: http://stackoverflow.com/a/34416853
answer count: 5
score: 54
tagged with: jdbc
upvote count: 54
has comment: http://stackoverflow.com/comment/134124091
possible better answer: http://stackoverflow.com/a/21523068
type: AnsweredQuestion
has title: Data truncation: Data too long for column 'logo' at row 1
has body: I am trying to insert a photo into a BLOB column of a MySQL table, and I get an exception: Data too long for column 'logo' at row 1. Here is the JDBC: int idRestaurant = 42; String restoname= "test"; String restostatus= "test"; InputStream fileContent = getUploadedFile(); int fileSize = getUploadedFileSize(); Class.forName("com.mysql.jdbc.Driver"); try (Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/resto" , "root" , "" )) { PreparedStatement ps = conn.prepareStatement("insert into restaurants (idRestaurant, restaurantName, status, logo) values(?,?,?,?)"); ps.setInt(1, idRestaurant); ps.setString(2, restoname); ps.setString(3, restostatus); ps.setBinaryStream(4, fileContent, fileSize); ps.executeUpdate(); conn.commit(); } How do I solve this problem?
tagged with: java
accepted answer: http://stackoverflow.com/a/21523073
tagged with: mysql
type: Question
has comment: http://stackoverflow.com/comment/39266703
downvote count: 0
has answer: http://stackoverflow.com/a/68459614

http://stackoverflow.com/a/21607297
score: 3
answers question: http://stackoverflow.com/q/21607152
upvote count: 3
type: Answer
downvote count: 0
has body: Assuming that each ; you want to split on is at the end of line you can try to split on each ; + line separator after it like text.split(";"+System.lineSeparator()) If your file has other line separators then default ones you can try with text.split(";\n") text.split(";\r\n") text.split(";\r") BTW if you want to include ; in split result (if you don't want to get rid of it) you can use look-behind mechanism like text.split("(?&lt;=;)"+System.lineSeparator()) In case you are dynamically reading file line-by-line just check if line.endsWith(";").

binary-tree
tag name: binary-tree
type: Tag
tags question: http://stackoverflow.com/q/21568501
tags question: http://stackoverflow.com/q/21642771

http://stackoverflow.com/q/21657118
tagged with: network-programming
has comment: http://stackoverflow.com/comment/32752440
type: UnansweredQuestion
downvote count: 0
score: 1
favorite count: 0
type: Question
tagged with: multithreading
has comment: http://stackoverflow.com/comment/33343465
tagged with: java
upvote count: 1
has body: Basic I have an app that is sending packets using DatagramChannel.send in multiple threads each to its own IP address/port and each of them keeping constant bit-rate/bandwidth. Every now and then I get this error: java.net.SocketException: Invalid argument: no further information at sun.nio.ch.DatagramChannelImpl.send0(Native Method) at sun.nio.ch.DatagramChannelImpl.sendFromNativeBuffer(Unknown Source) at sun.nio.ch.DatagramChannelImpl.send(Unknown Source) at sun.nio.ch.DatagramChannelImpl.send(Unknown Source) ... It happens on random - sometimes 5 minutes after start sometimes after a day - so I really have problems reproducing it for testing. And on my home machine I can't reproduce it at all. Environments Windows 7, 8 and Server 2012 (all 64bit) 64bit Java 7 update 45 More information The app is sending SI/EIT data to DVB-C network. I'm creating a list of 188-byte arrays for each of 80-120 threads and giving it to use. The thread takes the list and is looping over the list until new list is provided. The error usually happens on multiple channels at once. But it can happen on just one also. The error never happened until we had 40+ threads. The error happens while looping over the list, not when I'm binding new list to thread. The app it not running out of memory. Its usually running up to 70% of memory given to JVM. Strange part: If I run multiple instance of app each handling ~10 threads problems are the same. Simplified code sample for(int i = 0; i &lt; 100; ++i) { final int id = i; new Thread(new Runnable() { @Override public void run() { final Random r = new Random(); final List&lt;byte[]&gt; buffer = Lists.newArrayList(); for(int i = 0; i &lt; 200; ++i) { final byte[] temp = new byte[188]; r.nextBytes(temp); buffer.add(temp); } final SocketAddress target = new InetSocketAddress("230.0.0.18", 1000 + id); try (final DatagramChannel channel = DatagramChannel.open(StandardProtocolFamily.INET)) { channel.configureBlocking(false); channel.setOption(StandardSocke…
answer count: 1
has answer: http://stackoverflow.com/a/37746549
has title: native errors on DatagramChannel send

http://stackoverflow.com/comment/32550494
type: QuestionComment
comment on: http://stackoverflow.com/q/21553635
score: 0
has text: The question here is why the application container doesn't do that transparently.
type: Comment

http://stackoverflow.com/q/21628933
accepted answer: http://stackoverflow.com/a/21629117
answer count: 2
tagged with: android-layout
possible better answer: http://stackoverflow.com/a/22377337
has answer: http://stackoverflow.com/a/22377337
has body: I am trying to run the sample code downloaded from http://developer.android.com/training/displaying-bitmaps/index.html. All I did was download the code and import it like any other sample codes I tried. But when I run, 'Unfortunately, BitmapFun has stopped' shows and application exits. My logcat shows : 02-07 13:11:55.647: D/AndroidRuntime(5554): Shutting down VM 02-07 13:11:55.647: W/dalvikvm(5554): threadid=1: thread exiting with uncaught exception (group=0x41550ba8) 02-07 13:11:55.647: E/AndroidRuntime(5554): FATAL EXCEPTION: main 02-07 13:11:55.647: E/AndroidRuntime(5554): Process: com.example.android.bitmapfun, PID: 5554 02-07 13:11:55.647: E/AndroidRuntime(5554): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.android.bitmapfun/com.example.android.bitmapfun.ui.ImageGridActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.android.bitmapfun.ui.ImageGridActivity" on path: DexPathList[[zip file "/data/app/com.example.android.bitmapfun-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.android.bitmapfun-2, /vendor/lib, /system/lib]] 02-07 13:11:55.647: E/AndroidRuntime(5554): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121) 02-07 13:11:55.647: E/AndroidRuntime(5554): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 02-07 13:11:55.647: E/AndroidRuntime(5554): at android.app.ActivityThread.access$800(ActivityThread.java:135) 02-07 13:11:55.647: E/AndroidRuntime(5554): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 02-07 13:11:55.647: E/AndroidRuntime(5554): at android.os.Handler.dispatchMessage(Handler.java:102) 02-07 13:11:55.647: E/AndroidRuntime(5554): at android.os.Looper.loop(Looper.java:136) 02-07 13:11:55.647: E/AndroidRuntime(5554): at android.app.ActivityThread.main(ActivityThread.java:5017) 02-07 13:11:55.647: E/AndroidRuntime(5554): at java.lang.reflect.Method.invokeNative(Native Method) 02-07 13:11:55.647: …
tagged with: android
has answer: http://stackoverflow.com/a/21629117
tagged with: android-intent
type: AnsweredQuestion
score: 0
tagged with: java
tagged with: eclipse
has title: Unable to run the android sample code 'bitmapfun'
type: Question

http://stackoverflow.com/a/21674296
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21674152
has body: You are getting this exception because you call a Java FX GUI element not from the FX application thread. You can access GUI elements just from the GUI Thread. You could use runLater(Runnable) to make sure that your code is executed within the right thread.

http://stackoverflow.com/a/26851779
has comment: http://stackoverflow.com/comment/42265992
score: 0
has comment: http://stackoverflow.com/comment/42266175
has comment: http://stackoverflow.com/comment/42266761
answers question: http://stackoverflow.com/q/21578818
type: Answer
has comment: http://stackoverflow.com/comment/42266110
has body: In the android code don't append ?WSDL. Just write address up to Service.svc or you can copy the address from &lt;soap:address location="..."/&gt; tag of WSDL file. I hope it might work for you. Refer the following link for further details: http://techzusiastic.blogspot.in/2014/11/solved-xmlpullparse-error-problem-while.html

http://stackoverflow.com/comment/32655111
comment on: http://stackoverflow.com/a/21586727
type: AnswerComment
score: 0
type: Comment
has text: My main request is that how to send email only once not every time log the message

http://stackoverflow.com/q/21653184
tagged with: java
tagged with: swing
tagged with: console-output
has body: I have a program with 5 JTextArea components that are added to a container at runtime. The following code is an example of what I am doing (in my code everything is actually imported, and this code is run from within a JFrame subclass). JFrame frame = new JFrame("test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel container = new JPanel(); getContentPane().add(container); JTextArea example = new JTextArea("//There is some text here"); container.add(example); frame.setVisible(true); Upon running this the following is output to the console. 17:16.43 1[dbg] In DllGetClassObject 17:16.43 2[dbg] CShellExtClassFactory::CShellExtClassFactory() 17:16.43 3[dbg] CShellExtClassFactory::QueryInterface() 17:16.43 4[dbg] CShellExtClassFactory::CreateInstance() 17:16.43 5[dbg] CShellExt::CShellExt() 17:16.43 6[dbg] Looping before Zumo is running 17:16.43 7[dbg] Drive not mounted 17:16.43 8[dbg] CShellExt::QueryInterface()==&gt;IID_IShellIconOverlayIdentifier 17:16.43 9[dbg] CShellExt::AddRef() 17:16.43 10[dbg] CShellExt::AddRef() 17:16.43 11[dbg] CShellExt::Release() 17:16.43 12[dbg] CShellExt::QueryInterface()==&gt;IID_IShellIconOverlayIdentifier 17:16.43 13[dbg] CShellExt::AddRef() 17:16.43 14[dbg] CShellExt::Release() 17:16.43 15[dbg] Entering CShellExt::GetOverlayInfo 17:16.43 16[dbg] Icon path: C:\Program Files (x86)\Hewlett-Packard\HP CloudDrive\icons\deflated.ico 17:16.43 17[dbg] Exiting CShellExt::GetOverlayInfo successfully. 17:16.43 18[dbg] Time to execute: 0ms 17:16.43 19[dbg] Entering CShellExt::GetPriority 17:16.43 20[dbg] Exiting CShellExt::GetPriority 17:16.43 21[dbg] In DllGetClassObject 17:16.43 22[dbg] CShellExtClassFactory::CShellExtClassFactory() 17:16.43 23[dbg] CShellExtClassFactory::QueryInterface() 17:16.43 24[dbg] CShellExtClassFactory::CreateInstance() 17:16.43 25[dbg] CShellExt::CShellExt() 17:16.43 26[dbg] CShellExt::QueryInterface()==&gt;IID_IShellIconOverlayIdentifier 17:16.43 27[dbg] CShellExt::AddRef() 17:16.43 28[dbg] CShellExt::Ad…
type: Question
tagged with: debugging
has comment: http://stackoverflow.com/comment/32726402
tagged with: jtextarea
score: 0
has comment: http://stackoverflow.com/comment/32736556
has comment: http://stackoverflow.com/comment/32726658
has title: How do you disable debug text shown when adding a JTextArea to a container?
type: UnansweredQuestion
answer count: 0

http://stackoverflow.com/q/21641106
answer count: 0
type: UnansweredQuestion
has body: I am unable to draw anything onto the screen on Mac OSX Mavericks using LWJGL 2.9.1. I made a window that uses OpenGL version 3.3 and I am trying to use #version 330 for my shaders. All I get is a black screen. I am using a vbo and ibo to draw something: public void draw() { glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); glBindBuffer(GL_ARRAY_BUFFER, vbo); glVertexAttribPointer(0, 3, GL_FLOAT, false, 8 * 4, 0); glVertexAttribPointer(1, 2, GL_FLOAT, false, 8 * 4, 12); glVertexAttribPointer(2, 3, GL_FLOAT, false, 8 * 4, 20); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo); glDrawElements(GL_TRIANGLES, indices.length, GL_UNSIGNED_INT, 0); glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); glDisableVertexAttribArray(2); } This method is called every render cycle where vbo contains an array of vertices, ibo contains an array of indices and vertex attributes 0, 1, and 2 are position, texCoord and normal respectively. However, I don't know how helpful this will be since this just a small portion of my code. The main problem is that I am getting a black screen and don't know why. I get no errors and I did set up the context to use OpenGL version 3.3. The thing that confuses me the most is that the exact same code works perfectly fine on Windows 7, on the same computer and the mesh that I am drawing shows up on the screen just fine as expected. It must be a Mac problem or I'm not setting up something correctly. If you need me to post my vertex and fragment shader or any other pieces of code I will gladly put them up.
upvote count: 1
tagged with: opengl
tagged with: glsl
has comment: http://stackoverflow.com/comment/32705963
tagged with: java
tagged with: lwjgl
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/32705883
has comment: http://stackoverflow.com/comment/32706843
has title: LWJGL Black Screen on Mac
score: 0
tagged with: macos
favorite count: 0

http://stackoverflow.com/comment/32703111
score: 0
comment on: http://stackoverflow.com/q/21639577
type: QuestionComment
type: Comment
has text: What is the exact output you would want to have? 200? 200, 0.0054, 5, 10? 200/0.0054?

http://stackoverflow.com/comment/32659919
score: 1
has text: Or even better, pass it directly a `Resources` object (obtained through `getResources()` by the caller for example). It avoids unnecessarily leaking a `Context`.
type: AnswerComment
comment on: http://stackoverflow.com/a/21614971
type: Comment

http://stackoverflow.com/a/21639034
downvote count: 0
upvote count: 2
type: Answer
has body: If all you need is a small amount of numbers, just use a linear search to simulate a set. Then keep generating random numbers until you've generated enough unique ones to suffice. Obviously this isn't the most efficient, but it is simple. private static Random rand = new Random(); public static boolean contains(int [] data, int value) { for (int i = 0; i &lt; data.length; i++) { if (data[i] == value) { return true; } } return false; } public static int[] getRandom(int size, int lowerBound, int upperBound) { if (upperBound - lowerBound &lt;= size) { throw new IllegalArgumentException("Range is too small!"); } int totalRandoms = 0; int[] randoms = new int[size]; while (totalRandoms != size) { int randNumber = rand.nextInt(upperBound - lowerBound) + lowerBound; if (! contains(randoms, randNumber)) { randoms[totalRandoms] = randNumber; } } return randoms; } P.S. I've left some of the details up to you, I've just included a couple non-OO functions to give you a feel for a possible algorithm.
score: 2
answers question: http://stackoverflow.com/q/21637879

http://stackoverflow.com/q/21523736
upvote count: 1
has answer: http://stackoverflow.com/a/21524222
answer count: 1
favorite count: 0
tagged with: cdi
tagged with: maven
tagged with: weld
type: AnsweredQuestion
downvote count: 0
has title: Weld and test-jar
score: 1
tagged with: java
type: Question
tagged with: dependency-injection
accepted answer: http://stackoverflow.com/a/21524222
has body: We have a maven multi-module project with the following modules: prj-srv prj-client The srv project contains EJBs. In prj-srv/src/test, we have @Alternative implementations of the EJBs, specified in the alternatives section of beans.xml. This works. The project prj-client has prj-srv as a dependency. In addition, it has a dependency on prj-srv of type test-jar, scope test, so that it can use the alternative EJB implementations for tests. This works, too. Now then: in prj-client/src/main/java, we have local implementations of the EJB interfaces (so that we can cache the data) annotated with our qualifier @Cacheable. What I would like to do, is setup the tests in prj-client/src/test/java so that they use my test implementations from prj-srv (the ones that aren't cacheable, but who cares since it's for testing). I have tried: Creating a class with producer methods (@Produces @Alternative @Cacheable) in prj-client/src/test/java, but I don't know how to configure beans.xml to set this up as the alternative Creating classes in prj-srv/src/test/java that extend the test EJBs, annotated @Alternative @Cacheable, and put them in src/test/resources/META-INF/beans.xml in the alternatives section, but weld still injects the "real" @Cacheable beans from src/main/java. Is there some problem mixing @Alternative with qualifiers? How can I get my tests to use alternate implementations of a qualified class?

http://stackoverflow.com/q/21527343
has comment: http://stackoverflow.com/comment/32505748
has title: Log4j2 and maven - Picking wrong config file
tagged with: log4j2
tagged with: logging
score: 3
has comment: http://stackoverflow.com/comment/32504319
tagged with: configuration
tagged with: java
has comment: http://stackoverflow.com/comment/32505285
type: Question
has body: I have two projects (P1 &amp; P2) which are using Log4j2 logging. Each of the projects have their separate log4j2.xml placed in src/main/resources directory (according to maven structure). The issue is, when I run any program in a project (say P1) through my IDE (Eclipse) it picks out the correct log4j2.xml. (May be because Eclipse resolves the classpath properly). But when I run the same program from command line, it picks out the log4j2.xml of project P2. I have tried multiple time to "clean and install" the maven projects but to no help. Any ideas?
has answer: http://stackoverflow.com/a/21692801
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/32504258
favorite count: 0
has comment: http://stackoverflow.com/comment/32504602
has comment: http://stackoverflow.com/comment/32505912
has comment: http://stackoverflow.com/comment/32504527
upvote count: 3
type: UnansweredQuestion
tagged with: maven

http://stackoverflow.com/comment/32536846
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21545787
type: Comment
has text: Why both the return statements are returning empty string in your reverse1 method?

http://stackoverflow.com/comment/32627556
comment on: http://stackoverflow.com/q/21596566
has text: Particia, that function won't do the job here... it is not about formatting decimals...
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/q/21545009
type: UnansweredQuestion
score: 2
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32535663
tagged with: liferay
has comment: http://stackoverflow.com/comment/32535535
has body: When i am trying to add a Language.properties file with thousands of keys with longtext values. Unable to retrieve the value in my jsp file using &lt;liferay-ui:message key="xyz" /&gt;. It is not displaying any value and shoing the key in its output. may i know the maximum number of keys or max file size it supports. I am using liferay 6.0.6 with Tomcat bundle. In my properties file it contains 7600 lines with large values of keys. InputStream stream = application.getResourceAsStream("/abc.properties"); Properties prop=new Properties(); prop.load(stream); It is giving the following error if i am using the above code to retrieve the data from another properties file. 08:14:08,936 ERROR [jsp:154] java.lang.IllegalArgumentException: Malformed \uxxxx encoding. at java.util.Properties.loadConvert(Properties.java:569) at java.util.Properties.load0(Properties.java:392) at java.util.Properties.load(Properties.java:342) at org.apache.jsp.html.ahadith.sb_005fview11_jsp._jspService(sb_005fview11_jsp.java:158) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488) at com.liferay.portlet.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatcherImpl.java:…
has title: Maximum language.properties file size in liferay custom portlets
has answer: http://stackoverflow.com/a/21546825
tagged with: portlet
downvote count: 0
answer count: 1
tagged with: tomcat
favorite count: 0
upvote count: 2

http://stackoverflow.com/a/21663775
type: Answer
has body: Have a look at this picture (from Border layout Tutorial) As you are only adding panels to the Center and South(PAGE_END) regions of the layout manager there is no other components to stop the center panel from stretching out as far as it can. Note this relevant sentence of the tutorial If the window is enlarged, the center area gets as much of the available space as possible. The other areas expand only as much as necessary to fill all available space. Often a container uses only one or two of the areas of the BorderLayout object — just the center, or the center and the bottom. You either need to add blank panels on the other sides or make use of an empty border within your Center panel. See here about how to use borders.
downvote count: 0
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/32745108
answers question: http://stackoverflow.com/q/21663590

liferay-6
tags question: http://stackoverflow.com/q/21544319
tags question: http://stackoverflow.com/q/21653222
tags question: http://stackoverflow.com/q/21628036
tag name: liferay-6
tags question: http://stackoverflow.com/q/21521307
type: Tag

http://stackoverflow.com/comment/32676690
score: 0
has text: Nope. I cannot get a handle to it from within my test. Refreshing on Server shutdown is not enough. But I do not understand why? The server gets shutdown after each test. I verified that fact.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21584942

http://stackoverflow.com/q/21580598
tagged with: c3p0
has comment: http://stackoverflow.com/comment/45802604
has comment: http://stackoverflow.com/comment/45796123
has comment: http://stackoverflow.com/comment/45756500
has comment: http://stackoverflow.com/comment/45818902
type: UnansweredQuestion
has body: Our server is running on client site from last one year, but last night suddenly the server stopped responding because of some SQL/Hibernate exception, but after restarting server everything started working again. Here is our hibernate configurations(.hbm.xml): org.gjt.mm.mysql.Driver jdbc:mysql://127.0.0.1:3306/emessenger org.hibernate.context.ThreadLocalSessionContext root root false org.hibernate.connection.C3P0ConnectionProvider 1 100 5 0 Here is the exception trace, (similar three exceptions has been thrown on that time, if you want i can show you those exceptions also): 2014-02-05 02:18:47,116 ERROR [services.alert.AlertDB] [577]: Exception occured while fetching <alert_details> table for quikc message org.hibernate.exception.GenericJDBCException: could not execute query at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.doList(Loader.java:2223) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104) at org.hibernate.loader.Loader.list(Loader.java:2099) at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569) at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283) at services.alert.AlertDB.retrieveMessageDetails(AlertDB.java:568) at services.alert.Alert.getMessages(Alert.java:925) 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.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212) at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessag…
has comment: http://stackoverflow.com/comment/41701116
has title: Can anyone tell me why this is happening "org.hibernate.exception.GenericJDBCException: could not execute query"?
tagged with: java
tagged with: hibernate
has answer: http://stackoverflow.com/a/21580675
tagged with: mysql
has answer: http://stackoverflow.com/a/21581280
type: Question
score: 0
answer count: 2

http://stackoverflow.com/q/21638552
has answer: http://stackoverflow.com/a/21640892
downvote count: 0
favorite count: 0
tagged with: google-app-engine
answer count: 4
has answer: http://stackoverflow.com/a/21640143
has body: I have 400,000 entities of a certain type, and I'd like to perform a simple operation on each of them (adding a property). I can't process them serially because it would take forever. I don't want to use the MapReduce library because it is complicated and overwhelming. Basically I'd like to create 100 tasks on the taskqueue, each task taking a segment of ~4,000 entities and performing this operation on each one. Hopefully this wouldn't take more than a few minutes to process all 400k entities, when all tasks are executing in parallel. However, I'm not sure how to use GAE queries to do this. My entities have string ID's of the form "230498234-com.example" which were generated by my application. I want each task to basically ask the datastore something like, "Please give me entities #200,000-#204,000" and then operate on them one by one. Is this possible? How can I divide up the datastore in this way?
score: 2
upvote count: 2
type: UnansweredQuestion
type: Question
tagged with: parallel-processing
has answer: http://stackoverflow.com/a/21641035
tagged with: java
has answer: http://stackoverflow.com/a/21655441
has title: How to update 400,000 GAE datastore entities in parallel?
tagged with: google-cloud-datastore

http://stackoverflow.com/comment/32631926
has text: OK, this would work, I guess though it is overkill. But then he would still ask "So I'm basically looking for conversion on c++ someName to UTF-8 format" He would just need it now for writing to the file.
comment on: http://stackoverflow.com/a/21599229
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32611323
type: AnswerComment
has text: @JonathanSaich Start by taking a closer look at [Creating a GUI with Swing](http://docs.oracle.com/javase/tutorial/uiswing/)
type: Comment
comment on: http://stackoverflow.com/a/21586945
score: 1

http://stackoverflow.com/q/21566396
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/32575444
score: 0
has comment: http://stackoverflow.com/comment/32575162
tagged with: repaint
has body: I'm using some sample code from the Java website, and the file selector seems to get the file I want, but when I try to update the jframe and other components in the gui I used to call the file selector, nothing changes. I've tried quite a few of the suggested fixes to get things to update, but nothing seems to work. Most of my components are static by the way... import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import javax.swing.*; import java.awt.*; import java.io.File; import java.awt.event.*; public class GuiTester extends JFrame { private static String fileName = "Input File: Please select a file"; //Create a file chooser private static final JFileChooser fc = new JFileChooser(); private static JButton inputSelectorButton; private static JButton outputSelectorButton; private static JFrame frame = new JFrame( "Gui Tester" ); private static JPanel panel = new JPanel(); private static JLabel inputFile = new JLabel( fileName ); public static void main(String[] args) { go(); } private static void go() { inputSelectorButton = new JButton ( "Select Input File" ); outputSelectorButton = new JButton ( "Select Output File" ); Font bigFont = new Font( "sans", Font.BOLD, 22 ); Font smallFont = new Font( "sans", Font.PLAIN, 9 ); panel.setLayout(new BoxLayout( panel, BoxLayout.Y_AXIS ) ); JLabel description0 = new JLabel(" "); JLabel description6 = new JLabel(" "); JLabel inputFile = new JLabel( fileName ); inputFile.setFont( smallFont ); inputSelectorButton.addActionListener( new inputSelectorListener() ); JButton startButton = new JButton ( "GO!" ); panel.add(description0); panel.add(description6); panel.add( inputFile ); panel.add( inputSelectorButton ); panel.add( outputSelectorButton ); panel.add( startButton ); frame.getContentPane().add( BorderLayout.CENTER, panel ); inputFile.setAlignmentX(JComponent.CENTER_ALIGNMENT); inputSelectorButton.setAlignmentX(JComponent.CENTER_…
tagged with: swing
has title: Java: Swing component(s) not repainting
has comment: http://stackoverflow.com/comment/32574453
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21567098
has answer: http://stackoverflow.com/a/21567033
has comment: http://stackoverflow.com/comment/32574831
has answer: http://stackoverflow.com/a/21567098
tagged with: java
accepted answer: http://stackoverflow.com/a/21567033

http://stackoverflow.com/comment/32548287
comment on: http://stackoverflow.com/q/21552692
has text: Any effort yourself? If so, show it.
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/32574888
score: 0
comment on: http://stackoverflow.com/q/21566561
type: QuestionComment
has text: I tried using a for loop however i dont have a good understanding of for loops and i was wondering how not just go through array in its entirety but small bits like rows and columns.
type: Comment

http://stackoverflow.com/q/21585909
has title: Modify JAXB xs:any attribute processContents using a binding file
type: Question
score: 4
linked to: http://stackoverflow.com/q/9293634
tagged with: wsdl
favorite count: 0
type: UnansweredQuestion
upvote count: 4
answer count: 0
downvote count: 0
tagged with: cxf
tagged with: java
has body: In a WSDL file, there is an xs:any element that I want to override from: &lt;xs:element minOccurs="0" maxOccurs="1" name="GetPermissionCollectionResult"&gt; &lt;xs:complexType mixed="true"&gt; &lt;xs:sequence&gt; &lt;xs:any/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; To: &lt;xs:element minOccurs="0" maxOccurs="1" name="GetPermissionCollectionResult"&gt; &lt;xs:complexType mixed="true"&gt; &lt;xs:sequence&gt; &lt;xs:any processContents="skip"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; Ultimately what I'm doing is using JAXB to generate annotated Java code from the WSDL. And for the xs:any element, this is generated: @XmlAnyElement(lax = true) Instead I want this: @XmlAnyElement(lax = false) The WSDL file is not generated by me so I can't just make the modification to the file. Is there a way of using a JAXB binding file to get the same effect? I looked at using jaxb:property and jaxb:class elements but neither seems to fit want I want done.
tagged with: jaxb

http://stackoverflow.com/comment/32654090
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21611950
has text: int is like A...normal instance variable

http://stackoverflow.com/a/21644401
type: Answer
downvote count: 0
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/32715201
has body: If you always need to validate the list, you could do it beforehand and only expose the getValid and getInvalid methods: public class Validator { private final List&lt;A&gt; all; private final List&lt;A&gt; invalid = new ArrayList&lt;&gt;(); private final List&lt;A&gt; valid = new ArrayList&lt;&gt;(); public Validator(List&lt;A&gt; all) { this.all = new ArrayList&lt;&gt; (all); validate(all); } private void validate(List&lt;A&gt; all) { //populate invalid and valid } public List&lt;A&gt; getInvalid() { return invalid; } public List&lt;A&gt; getValid() { return valid; } }
answers question: http://stackoverflow.com/q/21644368

http://stackoverflow.com/comment/32634245
comment on: http://stackoverflow.com/q/21600344
has text: @ArnaudDenoyelle the methods are generated by Eclipse. I only slightly changed it to use StringUtils class.
score: 1
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32717366
has text: Ok changed it to Integer .. still not working. When testing I don't really care about the argument type of `MyType<?>`. let's say MyType is List, then I wan't to know wether the field is a List, and then instanciate it correctly using it's argument type
type: Comment
comment on: http://stackoverflow.com/q/21647501
type: QuestionComment
score: 0

http://stackoverflow.com/comment/32618649
score: 0
has text: Yea, it's true that it's not that bad and seems the best solution for now. It would break if a particular Collection implementation doesn't have a no args constructor, but I guess that's pretty rare.
type: AnswerComment
comment on: http://stackoverflow.com/a/21590651
type: Comment

http://stackoverflow.com/q/21583396
type: Question
has comment: http://stackoverflow.com/comment/32604686
score: 0
has body: I'm building an application and I want a user to be able set a WSDL in the configuration and for my application to use that as it is running, i.e. I don't know what it is at compilation time. The WSDL will have a single schema and I only want to call one service in it (to return a response from an earlier request made to my application). I want to dynamically call the single service using Java. I want to do this without making use of wsimport, Apache CXF or Axis 2.0. How can I do this just using JAX-WS ?
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32605192
has comment: http://stackoverflow.com/comment/32607767
answer count: 0
tagged with: java
tagged with: jax-ws
has title: How do I dynamically call a Web Service using just JAX-WS?

http://stackoverflow.com/comment/32748586
has text: Hi Saposhiente, I have added the asynchronous version of the interface. Regards, Glyn
comment on: http://stackoverflow.com/q/21641208
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32758403
has text: @pL4Gu33 thank you. I go through that one but I didn't find the answer. They given Set this attribute to the cache coordination mode. Then here what is coordination mode.
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21671457
type: Comment

http://stackoverflow.com/a/21595360
downvote count: 0
has body: Key Bindings are generally the preferred method and tend to be less trouble some InputMap im = getInputMap(); ActionMap am = getActionMap(); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.CTRL_DOWN_MASK), "left"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.CTRL_DOWN_MASK), "right"); am.put("left", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { // Code to go left } }); am.put("right", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { // Code to right } }); What's really cool is if you create the Actions as separate classes, you could use the same Actions on JButtons!
has comment: http://stackoverflow.com/comment/32628666
type: Answer
upvote count: 4
has comment: http://stackoverflow.com/comment/32626235
score: 4
answers question: http://stackoverflow.com/q/21595237
has comment: http://stackoverflow.com/comment/32655725
has comment: http://stackoverflow.com/comment/32645400

http://stackoverflow.com/comment/32488351
comment on: http://stackoverflow.com/q/21516731
has text: Crap, yes. You're completely right! I renamed my app and forgot to change all the references....
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21554272
has comment: http://stackoverflow.com/comment/32551565
has comment: http://stackoverflow.com/comment/32552771
has answer: http://stackoverflow.com/a/21558136
accepted answer: http://stackoverflow.com/a/21558136
tagged with: selenium-webdriver
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32558327
downvote count: 0
has answer: http://stackoverflow.com/a/21554782
has title: I have to find out the id of a table cell (non clickable) and based on it verify another row
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32552746
type: Question
has comment: http://stackoverflow.com/comment/32591144
has comment: http://stackoverflow.com/comment/32552944
has comment: http://stackoverflow.com/comment/32552207
answer count: 2
possible better answer: http://stackoverflow.com/a/21554782
upvote count: 1
has comment: http://stackoverflow.com/comment/32551498
favorite count: 0
has body: I have written below code to get the id of a table cell (non clickable) and want to verify another cell of the same row based on it. But below code return empty id. List&lt;WebElement&gt; text=driver.findElements(By.xpath("//*[contains(text(),'Google')]")); System.out.println(text.size()); for(WebElement id:text) { System.out.println(id.getAttribute("id")); } Can someone pls share views?

http://stackoverflow.com/q/21554848
has body: Please help me to find it out how to increase the JAVA heap space, I am running GATE based application where I need to run large collection of datasets, and it's really eating the memory. My computer configuration is RAM 32GB window 7. Whenever I run the dataset it when it reaches the memory size(1.5g) stops and says no memory (PermGem space available) and it kills the program. Is it true that maximum memory we can allocate to JAVA as -Xmx as 1.5g by default, we tried to increase the memory but no success still it crashes the program at 1.5g. How we could increase the memory size upto 8GB or more? Because I read that we could allocate 1/3 of physical memory to JAVA to run the program is it true? Please help me? Thanks
tagged with: java
downvote count: 2
tagged with: gate
linked to: http://stackoverflow.com/q/8356416
type: Question
has answer: http://stackoverflow.com/a/21554957
score: -2
has comment: http://stackoverflow.com/comment/32552656
has comment: http://stackoverflow.com/comment/32552508
tagged with: memory
linked to: http://stackoverflow.com/q/1565388
has title: JAVA PermGem memory
upvote count: 0
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/32552359
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32553654
tagged with: memory-management
has comment: http://stackoverflow.com/comment/32552538

http://stackoverflow.com/a/21570869
has body: You need to use connection pool that manages these things for you, refer c3po, basic idea is you make a dummy query to keep connection alive periodically
has comment: http://stackoverflow.com/comment/32677745
has comment: http://stackoverflow.com/comment/32692133
upvote count: 2
has comment: http://stackoverflow.com/comment/33027342
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/32649651
has comment: http://stackoverflow.com/comment/32633268
answers question: http://stackoverflow.com/q/21570810
type: Answer

http://stackoverflow.com/q/21531853
tagged with: java
tagged with: draw
type: Question
tagged with: canvas
has body: I've been asked to debug a problem in a large Android app. I was hoping someone here may know more about the Android rendering pipeline than I do. Question: What are the possible reasons why the Canvas supplied by Android might not actually paint anything? For example, are there any modes you can put it in to temporarily suspend paints? Symptoms: The app is responding correctly, but the first Activity that opens shows up blank. The entire application area is white, and the application's custom ActionBar is now showing up. The Views are laying out correctly (verified by using Dump View Hierarchy for UI Automator) The main thread is responsive (verified by logging a heartbeat) The onDraw methods are being invoked (verified by putting breakpoints in various onDraw methods) The Views themselves seem to be painting correctly (verified by asking the root view to draw itself to a Bitmap and then serializing it to disk). The difference here is that this is drawing to a Canvas I instantiated myself rather than the one supplied by Android. None of the views are outside the screen bounds or have layers attached. Other Activities paint correctly. The misbehaving Activity makes use of Fragments. The problem was observed on both Android 4.3 and 4.4, and on several different devices. All of the relevant views are visible (verified by traversing the View hierarchy and checking getVisibility()). I'm at a loss as to other things to check for. It looks as though everything is functioning correctly, except that anything that gets written to the Canvas is discarded. I would be delighted if anyone could offer any additional ideas for things to check for. Also, the problem is not reproducible in the debugger - I only know about it from beta bug reports, none of which have supplied working steps to reproduce. I will need to fix this using code inspection and occasional customer bug reports.
has comment: http://stackoverflow.com/comment/32513755
score: 0
tagged with: android
has comment: http://stackoverflow.com/comment/32512707
tagged with: paint
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32513209
has title: Why might an Android Canvas fail to paint?
has comment: http://stackoverflow.com/comment/32513560

http://stackoverflow.com/comment/32654394
type: Comment
type: QuestionComment
score: 2
comment on: http://stackoverflow.com/q/21611950
has text: @Omoro: an Integer is an Integer. It can't be an int. A variable of type Integer references an Object, or doesn't reference anything (null).

http://stackoverflow.com/comment/32609766
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21586244
has text: Make sure you also have the junit.jar in Java Build Path-> Order and exports

http://stackoverflow.com/a/21522256
has comment: http://stackoverflow.com/comment/32495422
type: Answer
has comment: http://stackoverflow.com/comment/32495606
has comment: http://stackoverflow.com/comment/32495466
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/32495314
answers question: http://stackoverflow.com/q/21522017
accepted answer of: http://stackoverflow.com/q/21522017
upvote count: 1
type: AcceptedAnswer
has body: Use below code. File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), IMAGE_DIRECTORY_NAME); if (!mediaStorageDir .exists()) { mediaStorageDir.mkdirs(); } Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); You are using this below code if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { Log.d(IMAGE_DIRECTORY_NAME, "Oops! Failed create " + IMAGE_DIRECTORY_NAME + " directory"); } } But in this you are not creating directory if it does not exist, you are just printing log that's why it is happening like this.

http://stackoverflow.com/a/21515759
type: Answer
upvote count: 9
accepted answer of: http://stackoverflow.com/q/21515693
downvote count: 0
has body: Let's go to the JLS: An anonymous class declaration is automatically derived from a class instance creation expression by the Java compiler. where a class instance creation expression is ClassInstanceCreationExpression: new TypeArgumentsopt TypeDeclSpecifier TypeArgumentsOrDiamondopt ( ArgumentListopt ) ClassBodyopt Primary . new TypeArgumentsopt Identifier TypeArgumentsOrDiamondopt ( ArgumentListopt ) ClassBodyopt TypeArgumentsOrDiamond: TypeArguments &lt;&gt; ArgumentList: Expression ArgumentList , Expression So, no, the Java language specification does not allow any shortcuts for making your anonymous class implement more interfaces than the type you're sub-typing. So, to determine the type of the anonymous class If the class instance creation expression ends in a class body, then the class being instantiated is an anonymous class. Then: If T denotes an interface, then an anonymous direct subclass of Object that implements the interface named by T is declared. [...] Let T be the type named by the Identifier and any type arguments. An anonymous direct subclass of the class named by T is declared. The body of the subclass is the ClassBody given in the class instance creation expression. Your alternative is the way to do it. You can also use local classes.
answers question: http://stackoverflow.com/q/21515693
score: 9
type: AcceptedAnswer

http://stackoverflow.com/a/21565602
upvote count: 1
downvote count: 0
score: 1
has body: One way of getting the currently displayed activity is to use the command device.shell('dumpsys window displays') and find the line Application tokens in Z order: The next line after that will look something like: App #6 AppWindowToken{42d89c20 token=Token{428ffac0 ActivityRecord{419ec3e8 u0 com.andrew.apollo/.ui.activities.HomeActivity t106}}}: which you could parse using python to extract the current activity which was com.andrew.apollo/.ui.activities.HomeActivity in this case. Another way would be to use the command device.shell('dumpsys activity activities') and find the line Running activities (most recent first): The next couple lines will look something like this: TaskRecord{428f0e90 #106 A=com.andrew.apollo.task U=0 sz=1} Run #3: ActivityRecord{419ec3e8 u0 com.andrew.apollo/.ui.activities.HomeActivity t106} which again, you could parse using python to get com.andrew.apollo/.ui.activities.HomeActivity
type: Answer
answers question: http://stackoverflow.com/q/21515914

http://stackoverflow.com/comment/32567955
score: 1
has text: Often you'll need to know the index of the value, so you could return the index if you find the number, or -1 if not.
type: Comment
comment on: http://stackoverflow.com/q/21563040
type: QuestionComment

http://stackoverflow.com/q/21659150
has answer: http://stackoverflow.com/a/21875872
tagged with: apache-storm
type: Question
tagged with: zeromq
score: 1
has body: My Nimbus host and supervisor run properly. When I submit a wordcount topology to the Nimbus host it successfully upload. After uploading topology supervisor giving error kill: No such process When I check the worker-6001.log and 6002.log I found a following error: 2014-02-09 17:20:05 b.s.m.TransportFactory [INFO] Storm peer transport plugin:backtype.storm.messaging.zmq 2014-02-09 17:20:05 b.s.d.worker [ERROR] Error on initialization of server mk-worker java.lang.UnsatisfiedLinkError: no jzmq in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886) ~[na:1.7.0_51] at java.lang.Runtime.loadLibrary0(Runtime.java:849) ~[na:1.7.0_51] at java.lang.System.loadLibrary(System.java:1088) ~[na:1.7.0_51] at org.zeromq.ZMQ.&lt;clinit&gt;(ZMQ.java:34) ~[jzmq-2.1.0.jar:na] at java.lang.Class.forName0(Native Method) ~[na:1.7.0_51] at java.lang.Class.forName(Class.java:190) ~[na:1.7.0_51] at backtype.storm.messaging.zmq$loading__4784__auto__.invoke(zmq.clj:1) ~[storm-core-0.9.0.1.jar:na] at backtype.storm.messaging.zmq__init.load(Unknown Source) ~[storm-core-0.9.0.1.jar:na] at backtype.storm.messaging.zmq__init.&lt;clinit&gt;(Unknown Source) ~[storm-core-0.9.0.1.jar:na] at java.lang.Class.forName0(Native Method) ~[na:1.7.0_51] at java.lang.Class.forName(Class.java:270) ~[na:1.7.0_51] at clojure.lang.RT.loadClassForName(RT.java:2056) ~[clojure-1.4.0.jar:na] at clojure.lang.RT.load(RT.java:419) ~[clojure-1.4.0.jar:na] at clojure.lang.RT.load(RT.java:400) ~[clojure-1.4.0.jar:na] at clojure.core$load$fn__4890.invoke(core.clj:5415) ~[clojure-1.4.0.jar:na] at clojure.core$load.doInvoke(core.clj:5414) ~[clojure-1.4.0.jar:na] at clojure.lang.RestFn.invoke(RestFn.java:408) [clojure-1.4.0.jar:na] at clojure.lang.Var.invoke(Var.java:415) ~[clojure-1.4.0.jar:na] at backtype.storm.messaging.zmq.&lt;clinit&gt;(Unknown Source) ~[storm-core-0.9.0.1.jar:na] at java.lang.Class.forName0(Native Method) ~[na:1.7.0_51] at java.lang.Class.forName(Class.java:190) ~[na:1.7.0_51] at b…
tagged with: java
answer count: 2
accepted answer: http://stackoverflow.com/a/21875872
downvote count: 0
possible better answer: http://stackoverflow.com/a/21659273
has answer: http://stackoverflow.com/a/21659273
favorite count: 0
linked to: http://stackoverflow.com/q/12115160
tagged with: jzmq
has title: Storm workers not starting
linked to: http://stackoverflow.com/q/32612810
tagged with: ubuntu-12.04
type: AnsweredQuestion
upvote count: 1

http://stackoverflow.com/comment/32580066
type: QuestionComment
has text: do you see the options for the other templates? ... for your Question, you can simply create a new Class which is a subclass of activity; overwrite constructor an onCreate() but DONT FORGET to make an entry in the AndroidManifest
comment on: http://stackoverflow.com/q/21569325
score: 0
type: Comment

http://stackoverflow.com/q/21632693
has comment: http://stackoverflow.com/comment/32787886
has body: RESUME Good day StackOverflow community. I've been trying for some time to develop a program that enables users to put objects in an area, allowing this area to be moved by the mouse. For this type of program, I decided to use a ScrollPane, because the user can add various contents in the area which I call the canvas. For some reason, something strange is happening in my program. EXPLANATION OF PROGRAM What I basically did was create a group of objects, and define this group as the ScrollPane content. Within the group, there is a Rectangle object that was added to serve as canvas boundaries. This object has larger dimensions (such as 1500 x 1000, for example), and is used in calculations that prevent nodes from moving beyond its limits. This is just the logical behind the existing large rectangle in my program, but in reality, there is no Node object with the mouse movement. What exists is the random distribution of Shape objects by the rectangle area. For ScrollPane has its scrollbars moved, I use the setHvalue setVvalue methods. Unfortunately for my purposes, this method does not change the position of the ScrollPane's viewport with pixel values​​, but values ​​that are in a range between 0f and 1f. So I can move the viewport with the mouse, I used a equation known as Rule of 3 (here in my Country, as I know), which we equate values ​​and cross multiply. For example, say I want to move the viewport of the ScrollPane with the mouse horizontally, and that my canvas area has a width of 2000 pixels. Finding how far (in pixels) the mouse was dragged from one point to another, I need to know how this value represents in a range 0f to 1f. Suppose I have dragged the mouse in 3 pixels, I could find the representation of the 0f to 1f with the following comparison: 2000 px ---- 1f 3 px ---- xf Multiplying crossed, I'll get the following result: xf = 3 / 2000 xf = 0.0015 Note: I believe you all know that. I'm not teaching math to anyone, just want to explain the logic of my p…
score: 1
linked to: http://stackoverflow.com/q/20610950
tagged with: java
tagged with: javafx
accepted answer: http://stackoverflow.com/a/21690185
type: Question
has comment: http://stackoverflow.com/comment/32784629
tagged with: viewport
has title: ScrollPane is not refreshing its contents
downvote count: 0
has answer: http://stackoverflow.com/a/21690185
favorite count: 0
has comment: http://stackoverflow.com/comment/32714823
answer count: 1
has comment: http://stackoverflow.com/comment/32792105
has comment: http://stackoverflow.com/comment/32788059
has comment: http://stackoverflow.com/comment/32713365
tagged with: scrollpane
upvote count: 1
tagged with: mouse
type: AnsweredQuestion

http://stackoverflow.com/comment/32704507
comment on: http://stackoverflow.com/a/21640335
type: AnswerComment
has text: Yea, I got ride of that when I saw the reason why it was failing is OP didn't but his string in ""
score: 0
type: Comment

http://stackoverflow.com/comment/32750919
has text: EJP, I am way from work for last two days! so did not remember what was the error
comment on: http://stackoverflow.com/q/21638322
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21663110
has comment: http://stackoverflow.com/comment/32744409
favorite count: 0
has comment: http://stackoverflow.com/comment/32743795
linked to: http://stackoverflow.com/q/18581002
has title: cast array of object
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21663550
upvote count: 0
has body: I am new to java and I have this cast for some public class MergeSort&lt;Item&gt; Integer N = Integer.valueOf(StdIn.readString()); MergeSort&lt;Integer&gt;[] input = (MergeSort&lt;Integer&gt;[]) new Object[N]; and I get this : Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [LMergeSort;
tagged with: java
has comment: http://stackoverflow.com/comment/32743674
type: Question
tagged with: object
tagged with: casting
tagged with: arrays
score: -1
has comment: http://stackoverflow.com/comment/32743711
has comment: http://stackoverflow.com/comment/32743813
answer count: 1
downvote count: 1

http://stackoverflow.com/comment/32764653
type: Comment
has text: I'm sorry, I've checked that tutorial and cannot make it work... The boolean attribute from model is correctly printed on page, but form:checkbox is always unchecked.
score: 0
comment on: http://stackoverflow.com/a/21674622
type: AnswerComment

access-specifier
tags question: http://stackoverflow.com/q/21536223
type: Tag
tag name: access-specifier

http://stackoverflow.com/q/21628129
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/32683025
favorite count: 0
has comment: http://stackoverflow.com/comment/32682192
type: UnansweredQuestion
tagged with: maven
upvote count: 12
has answer: http://stackoverflow.com/a/27070050
tagged with: java
has comment: http://stackoverflow.com/comment/32682102
linked to: http://stackoverflow.com/q/10676796
type: Question
has title: How to add Nexus repository index in IntelliJ IDEA?
has body: We managed our maven repository using Sonatype Nexus, and in the ~.m2\setting.xml, set * to our Nexus repository. In IntelliJ IDEA "Settings-->Maven-->Repositories-->Indexed Maven repositories", there are one local repository and one remote central repository "http://repo1.maven.org/maven2". However, there seems to be no way to index Nexus repository. Without the index, I can't use the "Maven Artifact Search" inside IntelliJ IDEA, instead I have to search it in Nexus website, and then copy the dependency to the pom.xml, which is not quite convenient. Can anybody tell me how to add Nexus repository index in IntelliJ IDEA, so that I can search artifacts inside IDEA? below is my settings.xml: <?xml version="1.0" encoding="UTF-8"?> nexus * My repository http://1.2.3.4:8081/nexus/content/groups/public nexus central My repository http://repo1.maven.org/maven2 default true always warn true never fail central http://repo1.maven.org/maven2 true always warn true never fail nexus
score: 12
has comment: http://stackoverflow.com/comment/32682040
tagged with: intellij-idea

http://stackoverflow.com/q/21529798
has body: Okay, so I'm trying to set up a Canoo WebTest using Groovy in Intellij. As a simple start I used the example the give on their website, namely import com.canoo.webtest.WebtestCase class SimpleTest extends WebtestCase { void testWebtestOnGoogle() { webtest("check that WebTest is Google's top 'WebTest' result") { invoke "http://www.google.com", description: "Go to Google (in English)" verifyTitle "Google" setInputField name: "q", value: "WebTest" clickButton "I'm Feeling Lucky" verifyTitle "Canoo WebTest" } } } Whilst executing this code however, I get the following which containts a Linkage error which says something about different class objects. However, I'm not sure what the problem is or how I can resolve this. Any ideas? Regards wt.defineTasks: Trying to override old definition of task retry wt.webtestMonitor: [echo] C:\Users\lputtema\Dropbox\GameMe999\out\production\GameMe999\webtest-resources/tools/WebTestMonitor.groovy wt.htmlReports.init: [mkdir] Created dir: C:\Users\lputtema\Dropbox\GameMe999\out\production\GameMe999\webtest-results\resources [copy] Copying 22 files to C:\Users\lputtema\Dropbox\GameMe999\out\production\GameMe999\webtest-results\resources [copy] Copying 1 file to C:\Users\lputtema\Dropbox\GameMe999\out\production\GameMe999\webtest-results Caught: : java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "org.apache.xerces.dom.NodeImpl.getChildNodes()Lorg/w3c/dom/NodeList;" the class loader (instance of org/codehaus/groovy/tools/RootLoader) of the current class, org/apache/xerces/dom/NodeImpl, and the class loader (instance of &lt;bootloader&gt;) for interface org/w3c/dom/Node have different Class objects for the type getChildNodes used in the signature : java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "org.apache.xerces.dom.NodeImpl.getChildNodes()Lorg/w3c/dom/NodeList;" the class loader (instance of org/codehaus/groovy/tools/…
tagged with: webtest
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32549530
has comment: http://stackoverflow.com/comment/32549615
type: Question
upvote count: 1
has comment: http://stackoverflow.com/comment/32549787
has comment: http://stackoverflow.com/comment/32508773
has comment: http://stackoverflow.com/comment/32551071
tagged with: groovy
tagged with: web-testing
tagged with: linkage
favorite count: 0
has title: java.lang.LinkageError trying to set up Canoo WebTest using Groovy in IntelliJ
answer count: 0
downvote count: 0
type: UnansweredQuestion

http://stackoverflow.com/a/21517949
type: Answer
score: 2
accepted answer of: http://stackoverflow.com/q/21517825
has body: Actually -1 means that all bits are set to 1. So, you will have plain white instead of black. That seems valid, to me. Since you told you were using Mac OS X, this could be right, because, look at the top left corner, it looks like this: There might be some plain white there in the corner. The second picture contains perfectly plain white. This can be achieved by setting a white background (at least, white in the corner) and translucent top menu bar enabled.
answers question: http://stackoverflow.com/q/21517825
has comment: http://stackoverflow.com/comment/32488524
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32488473
upvote count: 2

http://stackoverflow.com/q/21536223
has answer: http://stackoverflow.com/a/21536295
accepted answer: http://stackoverflow.com/a/21536295
tagged with: java
has body: I am getting main.java: error: someId in someStruct is defined in an inaccessible class or interface but how can I solve this? my main class: import subdir.Subclass; public class main{ ... Subclass.someArrayList.get(i).someString ... } my subdir.Subclass class: package subdir; public class Subclass{ public static java.util.ArrayList&lt;someStruct&gt; someArrayList = new java.util.ArrayList&lt;someStruct&gt;(java.util.Arrays.asList( new someStruct(3, "string", "string"), new someStruct(4, "string", "string") )); } class someStruct { public int someId; public String someString; public String someString2; public someStruct(int someId, String someString, String someString2) { this.someId = someId; this.someString = someString; this.someString2 = someString2; } }
type: Question
tagged with: access-specifier
downvote count: 0
has answer: http://stackoverflow.com/a/21536327
has title: x in y is defined in an inaccessible class or interface, ID in structure
answer count: 3
tagged with: java-7
tagged with: public
favorite count: 0
has answer: http://stackoverflow.com/a/51856568
score: 6
possible better answer: http://stackoverflow.com/a/21536327
upvote count: 6
type: AnsweredQuestion

http://stackoverflow.com/q/21629304
has comment: http://stackoverflow.com/comment/32684670
upvote count: 0
has answer: http://stackoverflow.com/a/21629403
has answer: http://stackoverflow.com/a/21629376
favorite count: 0
has answer: http://stackoverflow.com/a/21629389
has body: I am a starter in java and getting error on compiling this java code whats the error please help me! class sum { public static void main(String[] args) { int x,y,z; sum = x + y + z; System.out.println ("Sum is " + sum); } }
has title: Getting error in his simple java code
type: Question
score: -1
answer count: 6
has answer: http://stackoverflow.com/a/21629355
has comment: http://stackoverflow.com/comment/32684006
has answer: http://stackoverflow.com/a/21630892
downvote count: 1
tagged with: java
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21629381
has comment: http://stackoverflow.com/comment/32891634

http://stackoverflow.com/a/21629572
upvote count: 4
downvote count: 0
answers question: http://stackoverflow.com/q/21629323
score: 4
has body: If you insist on avoiding static blocks/methods to no real benefit: private static final int[] foo = new Callable&lt;int[]&gt;() { public int[] call() { int[] arr = { 3, 2, 1 }; Arrays.sort(arr); return arr; } }.call(); On the off-chance you're on Java 8: private static final int[] foo = IntStream.of(3, 2, 1) .sorted() .toArray();
type: Answer

http://stackoverflow.com/q/21628265
has body: I have made the same Test as it was done in this post: new String() vs literal string performance Meaning I wanted to test which one has the better in performance. As I expected the result was that the assignment by literals is faster. I don't know why, but I did the test with some more assignments and I noticed something strange: when I let the program do the loops more than 10.000 times the assignment by literals is relatively not as much faster than at less than 10.000 assignments. And at 1.000.000 repetitions it is even slower than creating new objects. Here is my code: double tx = System.nanoTime(); for (int i = 0; i&lt;1; i++){ String s = "test"; } double ty = System.nanoTime(); double ta = System.nanoTime(); for (int i = 0; i&lt;1; i++){ String s = new String("test"); } double tb = System.nanoTime(); System.out.println((ty-tx)); System.out.println((tb-ta)); I let this run like it is written above. I'm just learning Java and my boss asked me to do the test and after I presented the outcome of the test he asked me do find an answer, why this happens. I cannot find anything on google or in stackoverflow and so I hope someone can help me out here. factor at 1 repetition 3,811565221 factor at 10 repetitions 4,393570401 factor at 100 repetitions 5,234779103 factor at 1,000 repetitions 7,909884116 factor at 10,000 repetitions 9,395538811 factor at 100,000 repetitions 2,355514697 factor at 1,000,000 repetitions 0,734826755 Thank you!
has answer: http://stackoverflow.com/a/21628403
type: AnsweredQuestion
tagged with: microbenchmark
upvote count: 3
score: 1
tagged with: java
downvote count: 2
type: Question
tagged with: performance
has title: Java String = "" vs. new String("") performance change
has comment: http://stackoverflow.com/comment/32682156
accepted answer: http://stackoverflow.com/a/21628403
has comment: http://stackoverflow.com/comment/32682106
answer count: 1
tagged with: string
favorite count: 0
linked to: http://stackoverflow.com/q/14757978

http://stackoverflow.com/q/21677151
type: UnansweredQuestion
has body: If we create a String like below and print the value: String s=new String("demo"); System.out.println(s); ...the output is: demo Good. This is the expected output. But here String is a class. Remember that. Below is another example. For example, take a class like this: class A { public static void main (String args[]) { A a =new A(); A a1=new A("hi"); //we should create a Constructor like A(String name) System.out.println(a1); //here O/P is address } } My doubt is that I created the A instance in the same way I created the new String object, and I printed that object. So why does it not print the given String for the instance of A?
downvote count: 1
has comment: http://stackoverflow.com/comment/32767720
has comment: http://stackoverflow.com/comment/32768160
has comment: http://stackoverflow.com/comment/32767709
tagged with: java
score: -1
has answer: http://stackoverflow.com/a/21677189
type: Question
has comment: http://stackoverflow.com/comment/32767679
upvote count: 0
has comment: http://stackoverflow.com/comment/32767849
has comment: http://stackoverflow.com/comment/32767865
has answer: http://stackoverflow.com/a/21680127
tagged with: string
tagged with: class
has comment: http://stackoverflow.com/comment/32767662
has answer: http://stackoverflow.com/a/21677278
has answer: http://stackoverflow.com/a/21677299
answer count: 4
favorite count: 0
has title: String s1=new String("demo"); While printing why does it give output as the given string?
tagged with: constructor

http://stackoverflow.com/comment/32650837
has text: this is slovenian but the letters are also used in serbian,bosnian,czech,...
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21610164

http://stackoverflow.com/q/21567823
tagged with: android
has comment: http://stackoverflow.com/comment/32577417
has body: For example, if I have a java class that has setContentView(R.layout.page), I can only access the buttons and textboxes from within the page xml, in that java class. But how do you access buttons from other xml layouts from the same java class without doing setContentView()? When I attempt to do this, I get a nullPointerException. Thanks in advance for any replies. (I would happily provide any required information)
has comment: http://stackoverflow.com/comment/32577246
has title: How to access a button from another xml that is not set in setContentView?
tagged with: java
has comment: http://stackoverflow.com/comment/32577306
has comment: http://stackoverflow.com/comment/32577324
type: Question
has answer: http://stackoverflow.com/a/21569148
has comment: http://stackoverflow.com/comment/32577943
score: 0
answer count: 1
has comment: http://stackoverflow.com/comment/32577334
has comment: http://stackoverflow.com/comment/32578103
type: UnansweredQuestion

http://stackoverflow.com/comment/122079175
type: Comment
has text: @user3265048 Yes, Eclipse works just fine with proper Unicode characters in the source code and everything. But there are some simple command line tools that can't deal with non-ASCII shit.
comment on: http://stackoverflow.com/a/21522953
score: 0
type: AnswerComment

http://stackoverflow.com/a/21621253
upvote count: 1
has comment: http://stackoverflow.com/comment/32671320
score: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21621096
has comment: http://stackoverflow.com/comment/32671215
downvote count: 0
answers question: http://stackoverflow.com/q/21621096
has body: The code: StudentForm studentform = new StudentForm(); constructs a new StudentForm instance and assign the reference to that instance to a variable studentform. So that you can call methods of the StudentForm instance later, such as studentform.addContainerListener(xxx). But code new StudentForm() just calls the constructor to create a new object instance, but don't hold the reference to that instance.
type: Answer

http://stackoverflow.com/q/21518474
has body: So I have two case/switch statements, and for some reason the print statement that is being activated by the two variables is being activated twice. I read the code over and over again and couldn't find anything that would create a repeat of the print statements. The output is: The Dark Knight uses his cunning and strength of will to beat down the enemy once again. Unfortunately, somebody brought Kryptonite :( The Dark Knight uses his cunning and strength of will to beat down the enemy once again. Unfortunately, somebody brought Kryptonite :( Does anybody see the error? If so, thanks in advance for any answers; code below and faulty code is in quadruple quotes: class Hero{ String name; int intelligence; boolean parents; double strength; public static String fight(Hero hero1, Hero hero2){ if(hero1.intelligence+hero1.strength&gt;hero2.intelligence+hero2.strength) return(hero1.name+" is the winner"); else{ //If hero2 wins, initiate this code """"switch (hero2.name){ //If the hero's name is ___ then print ____ case "Batman": System.out.println("The Dark Knight uses his cunning and strength of will to beat down the enemy once again."); break; case "Superman": System.out.println("Superman is literally invincible. The Son of Krypton wins again!"); break; default: break; } switch (hero1.name){ case "Batman": System.out.println("The Dark Knight trudges back to his cave"); break; case "Superman": System.out.println("Unfortunately, somebody brought Kryptonite :("); default: break; }"""" return(hero2.name+" is the winner"); } } class HeroMain{ public void main(String[] args){ Hero Superman = new Hero(); Superman.name = "Superman"; Superman.intelligence = 7; Superman.parents = false; Hero Batman = new Hero(); Batman.name = "Batman"; Batman.intelligence = 8; Batman.parents = false; Hero.fight(Superman, Batman); System.out.println(Hero.fight(Superman, Batman)); } } }
has comment: http://stackoverflow.com/comment/32489220
has comment: http://stackoverflow.com/comment/32489214
favorite count: 0
has comment: http://stackoverflow.com/comment/32489282
has answer: http://stackoverflow.com/a/21518541
score: -4
has comment: http://stackoverflow.com/comment/32489294
type: AnsweredQuestion
tagged with: java
has title: Case/switch statement yields repeated results
tagged with: switch-statement
type: Question
accepted answer: http://stackoverflow.com/a/21518541
upvote count: 0
has comment: http://stackoverflow.com/comment/32489260
answer count: 1
has comment: http://stackoverflow.com/comment/32489283
has comment: http://stackoverflow.com/comment/32489224
downvote count: 4

jackson
tags question: http://stackoverflow.com/q/21550546
tags question: http://stackoverflow.com/q/21576475
tags question: http://stackoverflow.com/q/21633677
tags question: http://stackoverflow.com/q/21537699
tags question: http://stackoverflow.com/q/21599465
tags question: http://stackoverflow.com/q/21535165
tags question: http://stackoverflow.com/q/21610734
tags question: http://stackoverflow.com/q/21525248
type: Tag
tags question: http://stackoverflow.com/q/21528963
tags question: http://stackoverflow.com/q/21628361
tags question: http://stackoverflow.com/q/21605594
tag name: jackson
tags question: http://stackoverflow.com/q/21608881
tags question: http://stackoverflow.com/q/21538160
tags question: http://stackoverflow.com/q/21576931
tags question: http://stackoverflow.com/q/21672721
tags question: http://stackoverflow.com/q/21595745
tags question: http://stackoverflow.com/q/21515195
tags question: http://stackoverflow.com/q/21524841
tags question: http://stackoverflow.com/q/21640318

http://stackoverflow.com/a/21632678
score: 1
type: Answer
answers question: http://stackoverflow.com/q/21548506
has body: JRebel is a good option. It isn't cheap but there are open source licences available. The installation instructions for Maven are here: http://zeroturnaround.com/software/jrebel/learn/maven/ We get this working through a specific run profile and embedded Tomcat. This is a specific sub-module that depends on the other projects that build the web application wars. So if you configure something like the following in the runner submodule: run org.apache.tomcat.maven tomcat7-maven-plugin run-wars run-war-only integration-test theWar /relativepath <systemProperties> ${project.groupId} myArtifact ${project.version} war true myContext You can run this with mvn package -Prun which you should be able to shut down with Ctrl+C. Then, whilst this is running in one terminal, make your code changes, open a new terminal and run mvn compile. With JRebel going the changes should be reflected virtually instantly in your web app. There should be nothing preventing you from running these same goals through Eclipse's m2e plugin.
upvote count: 2
downvote count: 1

http://stackoverflow.com/a/21559100
has comment: http://stackoverflow.com/comment/32597074
has body: Your selector is incorrect, also you are not printing the correct data as per your requirement. Use ID to search ul, as it is the fastest way. Moreover, you need to get two separate text value, for that you have to try following: WebElement ul = driver.findElement(By.id("price_range")); List&lt;WebElement&gt; lis = ul.findElements(By.tagName("li")); for (WebElement li : lis) { System.out.println("1st part: "+li.getAttribute("title")); //To get "Rs. 2001 - Rs. 5000" System.out.println("2nd part: "+li.findElement(By.xpath(".//span[@class='count']")).getText()); //To get the count "(6)", if you want just "6" you can manipulate the string fetched. } Hope it helps you :)
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/32599850
has comment: http://stackoverflow.com/comment/32598144
downvote count: 0
answers question: http://stackoverflow.com/q/21558254
has comment: http://stackoverflow.com/comment/32597204
score: 1
has comment: http://stackoverflow.com/comment/32577236

http://stackoverflow.com/a/21638791
has body: no matter if it's string or long, it will always be a problem when it's null, because primary key can't be null, right? plus, a string as primary key is not efficient from database point of view, because it's much worse to compare them and search on strings, even with indexes applied
type: Answer
has comment: http://stackoverflow.com/comment/32702748
answers question: http://stackoverflow.com/q/21638734
has comment: http://stackoverflow.com/comment/32702814
score: 0
has comment: http://stackoverflow.com/comment/32702775

http://stackoverflow.com/a/21614882
has comment: http://stackoverflow.com/comment/75164709
upvote count: 4
accepted answer of: http://stackoverflow.com/q/21592347
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21592347
score: 4
has body: To make jarsigner work with JRE instead of JDK. Need to bundle these files in JRE from JDK From \bin\jarsigner.exe to \bin\jarsigner.exe From \bin\msvcr100.dll to \bin\msvcr100.dll From \bin\jli.dll to \bin\jli.dll From \lib\tool.jar to \lib\tool.jar I tested with this and found it working for me.
type: Answer

http://stackoverflow.com/comment/32509787
comment on: http://stackoverflow.com/a/21530121
has text: DJClayworth, it has only 3 setters and one public method. I just want to expose only 2 settters to SomeOtherClass.java
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32624109
score: 0
type: Comment
has text: I updated the answer... but I can't actually imagine that doing this is what you actually need to do... if you want it take up the same percentage of the screen on all devices, you need to use dp.
type: AnswerComment
comment on: http://stackoverflow.com/a/21594430

http://stackoverflow.com/q/21587658
has title: How to check if a string at a certain position contains character a-h?
tagged with: char
has comment: http://stackoverflow.com/comment/32612272
has body: I know there must be a simpler way to check, but this is what I'm doing right now. if (g.charAt(0) == 'a' || g.charAt(0) =='b' || g.charAt(0) =='c' || g.charAt(0) == 'd' || g.charAt(0) =='e' || g.charAt(0) =='f' || g.charAt(0) == 'g' || g.charAt(0) =='h')
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/21587828
has answer: http://stackoverflow.com/a/21604689
possible better answer: http://stackoverflow.com/a/21587684
score: 19
has answer: http://stackoverflow.com/a/21587684
type: AnsweredQuestion
upvote count: 19
tagged with: if-statement
has answer: http://stackoverflow.com/a/21587754
tagged with: java
has comment: http://stackoverflow.com/comment/32632628
type: Question
accepted answer: http://stackoverflow.com/a/21587754
downvote count: 0

http://stackoverflow.com/comment/38121296
comment on: http://stackoverflow.com/a/24211110
type: AnswerComment
score: 0
has text: Hello, i have a little problem while implementing your library. Please kindly help me : http://stackoverflow.com/questions/24603282/custom-pinch-to-zoom-edittext-cant-be-edited
type: Comment

http://stackoverflow.com/comment/32749989
type: Comment
has text: 3 down vote may be an explanation please? Thanks. I'm a newbie here.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21666320

http://stackoverflow.com/a/21557857
has body: No, an anonymous class is a sub type of the type whose name you use to instantiate it. An anonymous class declaration is automatically derived from a class instance creation expression by the Java compiler. MyCallback is the name of the super type. Your anonymous sub class class has no name that is useful to the developer at compile time. The actual class will have a name, something like MyCallback$1, but you won't be able to use it in the source code. For example, you can't do MyCallback$1 anonymousClassInstance = ...;
has comment: http://stackoverflow.com/comment/32559238
score: 10
has comment: http://stackoverflow.com/comment/32559146
has comment: http://stackoverflow.com/comment/32558859
has comment: http://stackoverflow.com/comment/32558429
upvote count: 10
type: Answer
answers question: http://stackoverflow.com/q/21557823
has comment: http://stackoverflow.com/comment/32558467
downvote count: 0

http://stackoverflow.com/a/21624736
type: Answer
has body: It is not possible to do it in one step, you would have to create that string yourself. I think there are better generic representations than a single string per row, like a list/array of objects or strings, one per column, or as a map. NOT TESTED CODE: ResultSet rs = stmt.executeQuery("SELECT * FROM posts LIMIT 1;"); ResultSetMetaData rsmd = rs.getMetaData(); int numberOfColumns = rsmd.getColumnCount(); /* Choose your representation */ String asString = ""; List&lt;String&gt; asStringList = new ArrayList&lt;String&gt;(); Map&lt;String, String&gt; asMap = new LinkedHashMap&lt;String, String&gt;(); for (int i = 0; i &lt; numberOfColumns; i++) { Object c = rs.getObject(i+1); asStringColumn = c == null ? null : c.toString(); asString += ";" + asStringColumn; asStringList.add(asStringColumn); asMap.put(rsmd.getColumnLabel(i+1), asStringColumn); }
score: 0
answers question: http://stackoverflow.com/q/21624257

http://stackoverflow.com/comment/32611420
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21574040
has text: If the session is expired you have to recreate the session object.
score: 0

http://stackoverflow.com/comment/32664300
comment on: http://stackoverflow.com/q/21617286
has text: The only class with an architected intern mechanism is String. The others are more like "caching instances", and, to my knowledge, are not required to exhibit interning behavior.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21631399
tagged with: jsp
has comment: http://stackoverflow.com/comment/32692595
has comment: http://stackoverflow.com/comment/32709728
favorite count: 0
possible better answer: http://stackoverflow.com/a/21633046
has comment: http://stackoverflow.com/comment/32699064
accepted answer: http://stackoverflow.com/a/21649349
tagged with: http-redirect
has title: Strut2 having multiple packages cause problems
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32709867
downvote count: 0
has comment: http://stackoverflow.com/comment/32698852
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/21649349
type: Question
has answer: http://stackoverflow.com/a/21633046
has body: This is my package structure in Struts.xml file <!-- Default action name <default-action-ref name="Index" /> --> /WEB-INF/html/index.jsp My Index.jsp is access through this url http://localhost:8888/Index In Index page there is hyper link that redirect that user to Setting Page. Setting action is in the 'Admin' namespace so it is access as: <a href="<s:url action='Admin/Setting'/>">Setting In setting page there is a hyper link to redirect the user to index.jsp page. action is called like this: <a href="<s:url action='Index'/>">go back As you can seen 'Index' action is in the default package having namespace '/'. So to handle this action namespace is changed and user is redirected to the index.jsp page. My problem is that although user is redirected to index.jsp page but the web url looks like http://localhost:8888/Admin/Index I want this url to http://localhost:8888/Index I don't know how to solve this problem. can anyone suggest me ?
tagged with: struts2
answer count: 2
has comment: http://stackoverflow.com/comment/32709880
upvote count: 1

http://stackoverflow.com/a/21530121
has comment: http://stackoverflow.com/comment/32509787
type: AcceptedAnswer
type: Answer
has body: Your question seems confused, but I think this is the answer you are looking for, Your approach to letting the client get the information should be exactly the same as letting them set it. You should not provide access to the inner SomeClass - that defeats the whole point. So if you want to provide both read and write access to only the name property, your outer class should look like: public class SomeOtherClass { private SomeClass someClass = new SomeClass(); public void setName(String name) { someClass.setName(name); } public String getName() { return someClass.getName(); } } You don't have to make the properties they can get the same as the properties they can set. You could also allow them to 'get' the ID, for example, but not set it. If you want them to have access to all the properties, provide getters for all properties in SomeOtherClass. If that is the case you might want to consider creating an interface which specifies all the getter methods and is implemented by both SomeClass and SomeOtherClass, with both classes also implementing the setter methods they require. There are other architectural approaches if you always want to provide full 'read' access but restricted 'write' access, which we can go into if you ask.
has comment: http://stackoverflow.com/comment/32510096
score: 0
has comment: http://stackoverflow.com/comment/32509507
accepted answer of: http://stackoverflow.com/q/21529665
has comment: http://stackoverflow.com/comment/32509452
has comment: http://stackoverflow.com/comment/32509707
answers question: http://stackoverflow.com/q/21529665
has comment: http://stackoverflow.com/comment/32509370

http://stackoverflow.com/q/21549379
answer count: 4
has answer: http://stackoverflow.com/a/21549462
score: 2
type: AnsweredQuestion
upvote count: 2
accepted answer: http://stackoverflow.com/a/21549509
has answer: http://stackoverflow.com/a/21549507
type: Question
has answer: http://stackoverflow.com/a/21549464
has body: public String getText() { ApplicationContext appContext = new ClassPathXmlApplicationContext(new String[]{"spring-config-server.xml"}); Resource resource = appContext.getResource("file:D:\\text\\test.txt"); StringBuilder builder = new StringBuilder(); try{ InputStream is = resource.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line; PrintWriter out=null; while ((line = br.readLine()) != null) { //System.out.println(line); out = new PrintWriter(new FileWriter("D:\\outputfile.txt")); out.println(line); //br.close(); } out.close(); br.close(); }catch(IOException e){ e.printStackTrace(); } return builder.toString(); }
tagged with: java
has title: PrintWriter object doesn't print all the lines in text document to out put file
downvote count: 0
has answer: http://stackoverflow.com/a/21549509
favorite count: 0
tagged with: spring
possible better answer: http://stackoverflow.com/a/21549462

http://stackoverflow.com/q/21556993
has answer: http://stackoverflow.com/a/21557076
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21557076
tagged with: algorithm
has answer: http://stackoverflow.com/a/21557120
tagged with: java
has answer: http://stackoverflow.com/a/21557598
has comment: http://stackoverflow.com/comment/32556608
has comment: http://stackoverflow.com/comment/32556510
downvote count: 0
answer count: 7
has comment: http://stackoverflow.com/comment/32556593
favorite count: 0
possible better answer: http://stackoverflow.com/a/21557098
has answer: http://stackoverflow.com/a/21557228
has answer: http://stackoverflow.com/a/21557161
has comment: http://stackoverflow.com/comment/32556724
upvote count: 11
tagged with: return
tagged with: syntax
has body: I'm looking at some Java algorithm examples and I come across this snippet code within a recursive method: boolean subTree(TreeNode t1, TreeNode t2) { if (t1 == null) { return false; } if (t1.value == t2.value) { if (treeMatch(t1, t2)) return true;; } return (subTree(t1.left, t2) || subTree(t1.right, t2)); } Not knowing (and never seeing) || being used within a return statement before, let alone a recursive one, really made me confused. I copied the code into Eclipse to see if it was valid and it was. I then replaced the || with &amp;&amp; and Eclipse didn't seem bothered by it. Logically, I understand that this recursive code is supposed to continue down the left and right subtrees of TreeNode t1, but I'm looking for a more theoretical explanation behind how this Java syntax works. Can someone explain the meaning behind || and &amp;&amp; within Java's return statement? What does it mean in terms of recursion? Is it only meaningful when used in conjunction with recursion?
score: 11
has answer: http://stackoverflow.com/a/21557119
has title: Java && || in RETURN statements?
has answer: http://stackoverflow.com/a/21557098
type: Question
tagged with: recursion

hql
tag name: hql
tags question: http://stackoverflow.com/q/21575011
type: Tag

http://stackoverflow.com/q/21610021
tagged with: delimiter
has answer: http://stackoverflow.com/a/21610163
type: AnsweredQuestion
score: 0
type: Question
tagged with: java
accepted answer: http://stackoverflow.com/a/21610163
has title: Having problems reading data from a file - java
answer count: 2
possible better answer: http://stackoverflow.com/a/21610212
has body: I'm pretty sure it has something to do with delimiters and I'm relatively new with Java and can't seem to find an answer. I have to read from a file called Simulation.Configuration which has this data in it: dimensionX: 100 dimensionY: 100 numberOfMobileObjects: 5 durationOfSimulationTime: 10 WarningGeotask: 1, 3 WarningGeotask: 2, 3 CounterGeotask: 1, 3 PopuplationMonitoringGeotask: 2, 3, 3 I have a scanner reading through to find the data and do certain things with them. I can easily get past the labels (dimensionX, dimensionY, and so forth)but can't seem to get to the numbers. I've tried a lot of ways using delimiters to reach those numbers, but cannot seem to get to them.The most recent one I've tried is using scanner.useDelimiter("[ ,:]"); to get through to the data. When I do this, it gives me an InputMismatchException. Here's how I am reading the file: Scanner scanConfig = new Scanner(new File("Simulation.Configuration")); scanConfig.useDelimiter("[ ,:]"); int dimensionX = 0; int dimensionY = 0; int numberOfMobileObjects = 0; while(scanConfig.hasNextLine()){ String nextLabel = scanConfig.next(); if(nextLabel.equals("dimensionX")){ dimensionX = scanConfig.nextInt(); } if(nextLabel.equals("dimensionY")){ dimensionY = scanConfig.nextInt(); } if(nextLabel.equals("numberOfMobileObjects")){ numberOfMobileObjects = scanConfig.nextInt(); } I've looked all over and couldn't find anything that helped my situation. Any tips on this would be lovely.
has answer: http://stackoverflow.com/a/21610212
tagged with: file-io

http://stackoverflow.com/q/21570898
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32582199
has body: I am getting 404 error while trying to deploy a servlet project. I took the war file from Netbeans and copied it in the webapps folder inside the tomcat folder. Code : web.xml <?xml version="1.0" encoding="UTF-8"?> UploadServlet com.example.Upload UploadServlet /UploadFile/UploadServlet index.html index.html : File Uploading Form File Upload: Select a file to upload: If I comment the servlet mapping and servlet part in web.xml, I can see the index.html. After undoing, I see just 404 error page. Please let me know what could be the error? Also what Actually I am suppose to write in action part and url-pattern in the web.xml Thanks in advance.
tagged with: java
has comment: http://stackoverflow.com/comment/32582389
has answer: http://stackoverflow.com/a/21570970
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/32582219
has title: Servlet 404 issue while deploying on tomcat
tagged with: servlets
score: 0
has comment: http://stackoverflow.com/comment/32582269
tagged with: jsp
has answer: http://stackoverflow.com/a/21571340
tagged with: web.xml

http://stackoverflow.com/a/21603765
answers question: http://stackoverflow.com/q/21603742
score: 0
type: Answer
has body: Always compare strings using equals()method!!!

http://stackoverflow.com/comment/32522066
comment on: http://stackoverflow.com/q/21535476
type: QuestionComment
score: 2
has text: "How do I just check if it has more elements without advancing the enumerator?" You don't. With most iterators it's not possible to determine if there are any more items without actually knowing what the next item is.
type: Comment

http://stackoverflow.com/a/21640605
upvote count: 1
answers question: http://stackoverflow.com/q/21640332
has comment: http://stackoverflow.com/comment/32725034
downvote count: 0
has body: You code is...frankly, scary. The over use of static means you have absolutle no idea what is pointing to where and which instance is control. When I (was finally able to) run your Tetris class, it failed with ... Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10 at tetris.Tetris$Board.&lt;init&gt;(Tetris.java:146) at tetris.Tetris.&lt;init&gt;(Tetris.java:35) at tetris.Tetris.main(Tetris.java:127) Which was here... public Board(Tetris tempTetris) { grid[10][18] = 8; ^---- Index out of bounds... When you take a look at the declration, you can see why... public static int[][] grid = new int[10][218]; grid only has ten elements in the first dimension. Remember, arrays are 0 indexed in Java. Drop the over use of static, it will simply explode in you face and makes the program impossibly ridget, not to mention difficult to know what's actually point to what... Rely on models (vitrual views) to maintain the game state and allow the UI components to render those models. Use observer pattern and maybe even producer/consumer pattern to notify distinct elements that the models have changed Have a clear boundary of responsibility for each section of the game. For example, the game loop should not be modifying the model directly, but should be providing it with information it can use to make decisions about how best to update itself. Use Key bindings over KeyListener
type: Answer
has comment: http://stackoverflow.com/comment/32724834
score: 1

http://stackoverflow.com/q/21638786
accepted answer: http://stackoverflow.com/a/21792490
score: 0
answer count: 1
has title: how to perform Lucene Highlighting when you have the document text, Term list and TermPositionVectors
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21792490
tagged with: java
has body: I am in a position some time after I've executed a Lucene query where I need to go back and selectively obtain highlighted fragments for some of the results. I have ready access to these things: the document text to produce fragments from A collection of Lucene Term objects from the original query The TermPositionVector for each Term in #2 It seems like this should be enough to hand off to one of the Lucene highlighters but I've not been able to cook up the special sauce to do it. The various highlighters and relevant examples seem to expect object types that I'm much more likely to have right when I execute the query. It seems like I'd be going backwards to recreate a Query, QueryScorer, etc. but maybe that is the only reasonable way? Thanks for any pointers.
type: Question
tagged with: lucene

http://stackoverflow.com/q/21598338
tagged with: spring
has answer: http://stackoverflow.com/a/21598705
type: AnsweredQuestion
score: 1
tagged with: java
has title: java temporary files created but contents write issue
type: Question
answer count: 1
downvote count: 0
accepted answer: http://stackoverflow.com/a/21598705
has body: package com.studytrails.tutorials.springremotingrmiserver; import java.lang.Object; import java.awt.Desktop; import java.io.*; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.core.io.Resource; public class GreetingServiceImpl implements GreetingService { @Override public String getGreeting(String name) { return "Hello " + name + "!"; } public String getText() { ApplicationContext appContext = new ClassPathXmlApplicationContext(new String[]{"spring-config-server.xml"}); Resource resource = appContext.getResource("file:D:\\text\\test.txt"); StringBuilder builder = new StringBuilder(); try{ InputStream is = resource.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); File temp=File.createTempFile("output", ".tmp"); String filePath=temp.getAbsolutePath(); System.out.println(""+filePath); String line; PrintWriter out = new PrintWriter(new FileWriter(temp)); //System.out.println(""+filePath); while ((line = br.readLine()) != null) { out.println(line); } String tem=temp.getName(); //temp.setReadOnly(); String[] cmd = {"notepad",tem}; Runtime runtime = Runtime.getRuntime(); Process proc = runtime.exec(cmd); out.close(); br.close(); temp.deleteOnExit(); }catch(IOException e){ e.printStackTrace(); } return builder.toString(); } } In the above code creates the temporary file but i am trying to write contents in that file but when the program executed notepad is open with the temporary name but it gives message file not exists do you want to create. i need that temporary file with the text present in the D:\text\test.txt location. kindly suggest me
has comment: http://stackoverflow.com/comment/32630914
favorite count: 0
upvote count: 1

http://stackoverflow.com/a/21570588
answers question: http://stackoverflow.com/q/21569970
has body: In short: Get an open entitymanager Begin a transaction Remove the necessary references (i.e perform the operations you want to do, but ensure that afterwards all constraints are satisfied) Commit the transaction Close the entitymanager
score: 0
type: Answer

http://stackoverflow.com/q/21610901
has title: JOGL: javax.media.opengl.GLException: AWT-EventQueue-0: Context not current on thread
answer count: 1
tagged with: glcanvas
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21614979
linked to: http://stackoverflow.com/q/7420027
has body: I'm creating a game with JOGL and I've come across an error which I can't for the life of me figure out. In the game I'm using two GLCanvases (GLJpanels actually), one for the menu and one for the actual game. The idea being that when a game is started from the menu, the menu GLCanvas is removed from the gamewindow and swapped for the game GLCanvas. So far I've gotten the menu to work pretty much perfectly, but whenever I attempt to switch over to the game canvas, I get this error: Catched Exception on thread AWT-EventQueue-0 javax.media.opengl.GLException: AWT-EventQueue-0: Context not current on thread, obj 0x2ab44e2d, ctx 0x0, surf 0x0, inDestruction: false, &lt;53f7c06e, 2e7aa0d3&gt;[count 0, qsz 0, owner &lt;NULL&gt;] The code I'm using to switch between canvases is: public void start() { canvas.addGLEventListener(this); animator.start(); window.add(canvas); canvas.requestFocus(); } public void stop() { window.remove(canvas); animator.stop(); canvas.removeGLEventListener(this); } and the switch function: public void switchToCanvas(String canvasName) { currentCanvas = canvasName; if(canvasName.equals("GameCanvas")) { menu.stop(); game.start(); } else { game.stop(); menu.start(); } } I've done some googling and I came around this question: How can I create my own openGL context and bind it to a GLCanvas? But none of the solution posted there worked for me.
tagged with: jogl
score: 0
type: Question
tagged with: opengl
tagged with: java

http://stackoverflow.com/q/21550637
has body: I have called webservice which have proxy setup, so I did following code for http based webservices: System.setProperty("http.proxyHost","10.0.0.1"); System.setProperty("http.proxyPort","222"); System.setProperty("http.proxyUser","xyz"); System.setProperty("http.proxyPassword","pqr");// base64 password. But when I used same code for https based webservices: System.setProperty("https.proxyHost","10.0.0.1"); System.setProperty("https.proxyPort","222"); System.setProperty("https.proxyUser","xyz"); System.setProperty("https.proxyPassword","pqr");// base64 password. It gives me following exception: Caused by: java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.0 407 Proxy Authentication Required" Or is there any other way to call Https webservice? Thank you..
tagged with: web-services
has answer: http://stackoverflow.com/a/21550716
tagged with: java
type: Question
tagged with: proxy
score: 0
has title: How to configure proxy setting?
answer count: 1
type: UnansweredQuestion

http://stackoverflow.com/comment/32593204
score: 0
type: Comment
type: QuestionComment
has text: You said _efficient_? Using greedy `.*` certainly doesn't qualify. Think what happens when the second required word immediately follows the first word... This should all be very easy with minimal googling, the only minor trick will be on the negation - this requires a negative lookahead.
comment on: http://stackoverflow.com/q/21577308

http://stackoverflow.com/comment/32518740
score: 0
type: Comment
has text: it looks like it's this line of code: mResult.setText(contents); causing the nullpointecxeption
comment on: http://stackoverflow.com/a/21533444
type: AnswerComment

http://stackoverflow.com/a/21538088
accepted answer of: http://stackoverflow.com/q/21536771
type: AcceptedAnswer
has body: Update the log4j configuration file to set the log level for Struts2 and iBatis packages to WARN. Following is the settings for Struts2 packages. Similarly add iBatis packages to the list. log4j.logger.com.opensymphony.xwork2=WARN log4j.logger.ognl=WARN log4j.logger.org.apache=WARN log4j.logger.org.apache.struts2=WARN log4j.logger.org.apache.struts2.util.StrutsTypeConverter=WARN If your log4j configuration is a xml file, you will need to add the struts2 and iBatis packages as below. &lt;logger name="com.opensymphony.xwork2" additivity="false"&gt; &lt;level value="WARN" /&gt; &lt;appender-ref ref="fileappender" /&gt; &lt;/logger&gt;
type: Answer
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/21536771
downvote count: 0

http://stackoverflow.com/a/21564851
has body: You need to make sure that the JAR dependency containing org.glassfish.jersey.client.JerseyClientBuilder class is available on your application's classpath during the run time. There's really no other explanation to NoClassDefFound error. From what I can google on this class, it should be available in org.glassfish.jersey.core jersey-client 2.0-m04 In other words your com.sun.jersey dependency may be missing it. EDIT This is the actual answer which the OP added to the Question afterwards: <jersey.version>2.5.1</jersey.version> org.glassfish.jersey.media jersey-media-json-processing ${jersey.version} javax.ws.rs javax.ws.rs-api 2.0 He already had org.glassfish.jersey.core and org.glassfish.jersey.connectors. He removed com.sun.jersey dependency. I am going to try this myself shortly.
has comment: http://stackoverflow.com/comment/56061917
accepted answer of: http://stackoverflow.com/q/21564394
score: 5
answers question: http://stackoverflow.com/q/21564394
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32574650
has comment: http://stackoverflow.com/comment/56037560
upvote count: 5
has comment: http://stackoverflow.com/comment/56052095
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/32573720

http://stackoverflow.com/comment/32527206
score: 0
has text: You have a version mismatch between your cluster and your local application.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21538162

http://stackoverflow.com/comment/32531843
type: Comment
score: 2
has text: I prefer your `sealed trait Status` approach, but I'd use `case object` instead of `case class` to declare the three "enum" values.
type: AnswerComment
comment on: http://stackoverflow.com/a/21537270

http://stackoverflow.com/a/21539620
has comment: http://stackoverflow.com/comment/32772227
accepted answer of: http://stackoverflow.com/q/21526132
has comment: http://stackoverflow.com/comment/32658287
has comment: http://stackoverflow.com/comment/32527035
has comment: http://stackoverflow.com/comment/32595775
has comment: http://stackoverflow.com/comment/32904358
has body: Update (after providing complete example) It seems you have multiple issues. web.xml vs AbstractAnnotationConfigDispatcherServletInitializer The application you created had a web.xml that configures a DispatcherServlet named mvc-dispatcher. The mvc-dispatcher had a configuration of mvc-dispatcher-servlet.xml which loaded all beans within the package com.springapp.sectest. This means that mvc-dispatcher can find your UserDetailsService. The application also had a AbstractAnnotationConfigDispatcherServletInitializer which created a DispatcherServlet that loaded your WebConfig java configuration. This DispatcherServlet could not see any Beans created by mvc-dispatcher. In short, you should either configure a DispatcherServlet using web.xml or AbstractAnnotationConfigDispatcherServletInitializer and NOT both. getRootConfigClasses vs getServletConfigClasses Any configuration within getRootConfigClasses is typically called the root or parent configuration and cannot view beans defined in getServletConfigClasses. Spring Security protects your application defined in the getRootConfigClasses with a Filter named springSecurityFilterChain that is created by the @EnableWebSecurity annotation. This means it is generally best to place Spring Security's configuration in the getRootConfigClasses. There are some exceptions to this, like if you want to do method security on your Spring MVC Controllers. Any configuration within getServletConfigClasses is typically called the child configuration and can view beans defined in the getRootConfigClasses. The getServletConfigClasses configures the DispatcherServlet and must contain beans for Spring MVC (i.e. Controllers, ViewResovlers, etc). Any Spring MVC beans defined in getRootConfigClasses are visible but not used. This setup, while a bit confusing, allows you to have multiple DispatcherServlet instances with isolated configurations. In practice, it is VERY rare to have multiple DispatcherServlet instances though. Given the information …
upvote count: 15
has comment: http://stackoverflow.com/comment/32857793
has comment: http://stackoverflow.com/comment/32861172
downvote count: 0
has comment: http://stackoverflow.com/comment/32764612
score: 15
has comment: http://stackoverflow.com/comment/32531425
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32973904
has comment: http://stackoverflow.com/comment/32551303
has comment: http://stackoverflow.com/comment/32531598
has comment: http://stackoverflow.com/comment/32764542
answers question: http://stackoverflow.com/q/21526132
has comment: http://stackoverflow.com/comment/32592862
type: Answer

http://stackoverflow.com/q/21607570
accepted answer: http://stackoverflow.com/a/21607791
has comment: http://stackoverflow.com/comment/32646747
has comment: http://stackoverflow.com/comment/32646190
has answer: http://stackoverflow.com/a/21607865
favorite count: 0
tagged with: logic
has answer: http://stackoverflow.com/a/21607789
has answer: http://stackoverflow.com/a/21607791
has comment: http://stackoverflow.com/comment/32646390
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32646132
downvote count: 0
possible better answer: http://stackoverflow.com/a/21607853
has comment: http://stackoverflow.com/comment/32646180
score: 1
has comment: http://stackoverflow.com/comment/32646255
has comment: http://stackoverflow.com/comment/32646074
has comment: http://stackoverflow.com/comment/32646603
type: Question
has comment: http://stackoverflow.com/comment/32646878
has title: What approach/method to use instead of multiple if statements
tagged with: hashmap
has comment: http://stackoverflow.com/comment/32646851
tagged with: if-statement
has answer: http://stackoverflow.com/a/21607825
tagged with: java
answer count: 6
has answer: http://stackoverflow.com/a/21607853
has body: I have a java web app that asks the user to select between 4 options. They can choose 1, all, or any combination of the 5 options. Their choices are read into a Hashmap with true/false values. If the option is selected it's true, unselected is false. Depending on what the user chooses, a different file is selected from the resources folder to be processed. My problem is that the code is just a complete mess of logic and I'm sure that there's an easier way to implement it. The following is dummy code for my problem. public class offerSelector { public void selectOffer(Map params) { /* Map params = Map&lt;String, String&gt; params = new HashMap &lt;&gt;(); It contains values ("internet","true),("phone","true"),("tv","true"),("cell","true") */ boolean option_1 = params.get("internet"); boolean option_2 = params.get("phone"); boolean option_3 = params.get("tv"); boolean option_4 = params.get("cell"); File offer = null; if (option_1 == true &amp;&amp; option_2 == false &amp;&amp; option_3 == false &amp;&amp; option_4 == false) { offer = new File("internet_order"); } else if(option_1 == false &amp;&amp; option_2 == true &amp;&amp; option_3 == false &amp;&amp; option_4 == false) { offer = new File("phone_order"); } //continues like so with all possible combinations else if(option_1 == true &amp;&amp; option_2 == true &amp;&amp; option_3 == true &amp;&amp; option_4 == true) { offer = new File("all_elements_order"); } processOrder(offer); } }
upvote count: 1
has answer: http://stackoverflow.com/a/21608342

http://stackoverflow.com/comment/32579129
has text: @DarkMatter, do you resolve your problem?
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21568095

http://stackoverflow.com/q/21628355
type: Question
score: 0
has answer: http://stackoverflow.com/a/21628455
tagged with: layout
answer count: 1
tagged with: swing
type: AnsweredQuestion
has body: I have a Java Swing application that has a bar of JButtons. The number of them is not known beforehand. I'd like to size the buttons equally to fit in the frame. Also, I need to be able to add new buttons and have them resized automatically. For example in Android you can use the layout weight attribute to do this. Now, is there any Layout etc. in Swing that can do it for you?
has title: Dividing space equally between unknown number of components in Swing?
accepted answer: http://stackoverflow.com/a/21628455
tagged with: java

http://stackoverflow.com/comment/32638607
comment on: http://stackoverflow.com/a/21603311
type: Comment
score: 0
has text: Aren't there any instances where a double with decimal would print as a number without any decimals? (I suppose not actually)...
type: AnswerComment

http://stackoverflow.com/comment/32731146
has text: you named your XML file as "Frag_MainList.xml" and Eclipse still compiled without any error?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21655053
score: 0

http://stackoverflow.com/a/21562493
has body: You can make global variable and set the result of calculation to this variable and add all the variable. or Change the return type of the function from void to double and do the sum.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21562306

http://stackoverflow.com/comment/32754304
score: 0
comment on: http://stackoverflow.com/a/21668966
type: AnswerComment
type: Comment
has text: @ZendNoob yep, both alternatives (Quartz, Timer) work as long as there's a running process dispatching the tasks, be it Quartz itself or an application server. Notice that you'll also have to configure an external data source for storing the tasks, for example a data base. As I said before: it's not that simple.

http://stackoverflow.com/comment/32668133
score: 1
comment on: http://stackoverflow.com/a/21619459
has text: The beauty of the problem is "No java built in functions should be used. Shouldn't use String reverse, converting to string etc. Only bitwise operations allowed."
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32717618
type: Comment
type: QuestionComment
score: 1
has text: You haven't told us enough about what's calling the method or what calls *that*, or even what platform you're using. (Is this Android? Java desktop?) More context please.
comment on: http://stackoverflow.com/q/21648262

http://stackoverflow.com/comment/32761073
has text: @ Arvind I have checked it with that also still getting the same error
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21673034

http://stackoverflow.com/q/21611726
possible better answer: http://stackoverflow.com/a/21611806
has answer: http://stackoverflow.com/a/21611801
tagged with: io
has comment: http://stackoverflow.com/comment/32653732
downvote count: 0
has answer: http://stackoverflow.com/a/21611806
favorite count: 0
has body: I'm still learning Java and I need some help understanding why this code is wrong: BufferedReader infile = new BufferedReader(new FileReader(file)); String regel = infile.readLine(); while (regel != null) { // Do something with regel. regel = infile.readLine(); } infile.close(); I really don't see the problem but Eclipse keeps telling there is a resource leak and that infile isn't closed. (one more detail, this code stands in a try block but I left it away to keep it simple)
has comment: http://stackoverflow.com/comment/32653729
has answer: http://stackoverflow.com/a/21611920
has comment: http://stackoverflow.com/comment/32653514
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21611801
score: 3
upvote count: 3
tagged with: java
has title: Still resource leak after closing BufferedReader
has comment: http://stackoverflow.com/comment/32653767
type: Question
tagged with: bufferedreader
answer count: 3

http://stackoverflow.com/comment/52069547
comment on: http://stackoverflow.com/q/21655286
score: 0
has text: @justin.m.chase it's https://www.npmjs.com/package/concat-stream, used in this case for debug logging.
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21653883
has comment: http://stackoverflow.com/comment/32795373
tagged with: java-7
downvote count: 0
score: 4
has answer: http://stackoverflow.com/a/21653977
favorite count: 0
has comment: http://stackoverflow.com/comment/32727543
possible better answer: http://stackoverflow.com/a/21653937
answer count: 3
has comment: http://stackoverflow.com/comment/32727614
linked to: http://stackoverflow.com/q/2725533
accepted answer: http://stackoverflow.com/a/21653977
type: AnsweredQuestion
has body: Recently we learned two dimensional arrays and solved task of calculating average of all elements in it. My code was like: int a[][] = { {1, 2, 3, 4, 5}, {6, 4, 2, 7}, {3, 6}, {2, 6, 8}, }; int sum=0, amount=0; for (int[] row : a) for (int val : row) { sum += val; amount += 1; } return sum / (double) amount; The thing is that I don't like the way I calculated the amount of elements in array. I tried to use size(), it not worked, tried to use Array and Arrays classes but both can retrieve neither amount of rows nor amount of elements in some row, just as a .length property. Question: is there any way of retrieving the amount of elements from two or more dimensional matrices without using loops?
tagged with: java
type: Question
upvote count: 4
has answer: http://stackoverflow.com/a/59311206
has answer: http://stackoverflow.com/a/21653937
has title: Total amount of elements in two dimensional array

http://stackoverflow.com/comment/32570871
type: AnswerComment
type: Comment
has text: Also when you skip set methods and directly go from private variable straight to assigning value to it via constructor such as: this.var = var - Is this considered as a setter too?
comment on: http://stackoverflow.com/a/21564503
score: 0

http://stackoverflow.com/comment/32578067
type: Comment
comment on: http://stackoverflow.com/q/21568363
has text: @ccjmne _I can't have any doubles, only int._
score: 0
type: QuestionComment

http://stackoverflow.com/q/21647707
tagged with: multithreading
has answer: http://stackoverflow.com/a/21647761
type: Question
duplicate of: http://stackoverflow.com/q/2542306
has comment: http://stackoverflow.com/comment/32716682
score: 0
answer count: 1
linked to: http://stackoverflow.com/q/2542306
has title: concept of multithreading in java
type: UnansweredQuestion
has body: While doing multi-threading programming in C we can assign threads to different cores of a processor and it gives us surety that the threads will be executed in different cores (i.e hyper-threading).But how exactly java does the above task-- Does it assign the threads to a single core and execute it in time-stamp basis or assign to different cores..? If it assign the above to different cores then how..?
tagged with: java

http://stackoverflow.com/a/21591418
answers question: http://stackoverflow.com/q/21591328
type: Answer
upvote count: 2
has body: You need to use the ResultSetMetaData to get the names of the columns in the result set returned after executing the query. ResultSet rs = stmt.executeQuery(...); ResultSetMetaData rsmd = rs.getMetaData(); int columnCount = rsmd.getColumnCount() for (int i = 1; i &lt;= columnCount; i++) { System.out.println(rsmd.getColumnName(i)); } Note: The index starts from 1 and not from 0
score: 2
downvote count: 0

http://stackoverflow.com/comment/32747691
score: 0
comment on: http://stackoverflow.com/a/21665094
type: AnswerComment
type: Comment
has text: question does this work on any number of digits. for example if I input a 5 would I get the largest palindrome product for 5 digit numbers?

http://stackoverflow.com/comment/32683934
has text: You can use HorizontalScrollView to add large number of views horizontally.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21625910

http://stackoverflow.com/comment/32760269
type: Comment
type: QuestionComment
has text: @LutzHorn I don't have any other code. I just create a sample application.
score: 0
comment on: http://stackoverflow.com/q/21672553

http://stackoverflow.com/q/21651032
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32726084
has comment: http://stackoverflow.com/comment/32723155
has comment: http://stackoverflow.com/comment/32722364
has title: generics in java with interface
tagged with: java
has comment: http://stackoverflow.com/comment/32722414
tagged with: java1.4
has comment: http://stackoverflow.com/comment/32722345
has comment: http://stackoverflow.com/comment/32722341
has comment: http://stackoverflow.com/comment/32722591
type: Question
has comment: http://stackoverflow.com/comment/32722342
has comment: http://stackoverflow.com/comment/32722504
has comment: http://stackoverflow.com/comment/32722340
score: 0
has comment: http://stackoverflow.com/comment/32722607
has body: I am having an interface with following definition : public interface genericInterface&lt;E implements Comparable &lt;E&gt;&gt;{ } and I want to write a class which implements this interface and will provide provide an arraylist implementation. public class MyClass&lt;E&gt; implements ***genericInterface&lt;List&gt;{*** but list and comparable are obviously not compatible... i don't have any option for comparable. What should i write in place of ?
tagged with: generics
answer count: 0

http://stackoverflow.com/comment/32627466
type: QuestionComment
score: 0
has text: And use DecimalFormat to get the result formatted just the way you want it.
comment on: http://stackoverflow.com/q/21596566
type: Comment

http://stackoverflow.com/comment/32652580
comment on: http://stackoverflow.com/q/21609224
has text: Thats good - can you check my previous comment and let me know the results
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21621958
has comment: http://stackoverflow.com/comment/32671581
upvote count: 2
has answer: http://stackoverflow.com/a/21622012
has title: what happens with new String("") in String Constant pool
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/21622124
has answer: http://stackoverflow.com/a/21622064
has comment: http://stackoverflow.com/comment/32671802
score: 2
downvote count: 0
tagged with: string
has answer: http://stackoverflow.com/a/21621984
favorite count: 0
has comment: http://stackoverflow.com/comment/32671661
answer count: 5
has comment: http://stackoverflow.com/comment/32672261
accepted answer: http://stackoverflow.com/a/21622124
linked to: http://stackoverflow.com/q/14150628
possible better answer: http://stackoverflow.com/a/21621990
has body: if i create a string object as String s=new String("Stackoverflow"); will String object created only in heap, or it also makes a copy in String constant pool. Thanks in advance.
has answer: http://stackoverflow.com/a/21621990
has comment: http://stackoverflow.com/comment/32671691
type: AnsweredQuestion

http://stackoverflow.com/a/21539044
has comment: http://stackoverflow.com/comment/32526845
type: Answer
has comment: http://stackoverflow.com/comment/32526650
score: 2
upvote count: 2
has body: JPanel, by default, uses a FlowLayout. FlowLayout also uses the component's preferred size to determine how to layout each component within the Container. Failing to call super.paint is going to cause you serious issues. In fact, you should use paintComponent instead of paint and make sure you are calling super.paintComponent. Take a look at Performing Custom Painting and Painting in AWT and Swing for more details Components already have a sense of location and size, which you are ignoring. The use of static variables in this context isn't going to help, because basically, each instance of your fish will be painted in the exact same location, as they will share the same value of the each of the static variables... A better solution would be to generate a class that is capable of begin painted, which then paints the "fish". These would be included inside a component capable of painting them, which you could then just add to a Container which is using a BorderLayout. For example... import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.geom.Ellipse2D; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; public class Fishies { public static void main(String[] args) { new Fishies(); } public Fishies() { EventQueue.invokeLater(new Runnable() { @Override public void run() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { } JFrame frame = new JFrame("Testing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new FishBowel()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); } public class FishBowel exte…
has comment: http://stackoverflow.com/comment/32526328
answers question: http://stackoverflow.com/q/21538789
downvote count: 0

http://stackoverflow.com/q/21531089
tagged with: multidimensional-array
accepted answer: http://stackoverflow.com/a/21531114
type: AnsweredQuestion
tagged with: binary
has title: I'm trying to use the specific key ' in my binary converter program, but it creates a syntax error
has comment: http://stackoverflow.com/comment/32511241
type: Question
tagged with: java
tagged with: comparison
has answer: http://stackoverflow.com/a/21531114
score: 0
answer count: 2
possible better answer: http://stackoverflow.com/a/21531115
tagged with: string
has body: Here's a part of the working code. I give you a few examples of the working comparisons, but the comparison with the apostrophe (') key just doesn't work. Any ideas on how to fix this? else if(line.charAt(index) == ('%')) { binaryList[rows][col] = "00100101"; } else if(line.charAt(index) == ('&amp;')) { binaryList[rows][col] = "00100110"; } else if(line.charAt(index).equals(''')) // this is the problem, its not working correctly like the others. { binaryList[rows][col] = 00100110; } else if(line.charAt(index) == ('(')) { binaryList[rows][col] = "00101000"; } else if(line.charAt(index) == (')')) { binaryList[rows][col] = "00101001"; }
has answer: http://stackoverflow.com/a/21531115

http://stackoverflow.com/comment/32608308
comment on: http://stackoverflow.com/q/21583911
type: Comment
type: QuestionComment
has text: @MxyL I think DavidWallace is right. The problem with a static member is that you have poor (no?) control over its creation time. The static members might be initialized before you can create the connection. Better use normal members and make sure you only create one object of that class.
score: 0

http://stackoverflow.com/comment/99749933
comment on: http://stackoverflow.com/q/21576564
type: Comment
has text: Another dup: https://stackoverflow.com/questions/4943612/java-how-to-get-arguments-passed-to-method-that-called-this-method
type: QuestionComment
score: 0

http://stackoverflow.com/q/21558157
score: 0
answer count: 3
has comment: http://stackoverflow.com/comment/32559161
has comment: http://stackoverflow.com/comment/32558954
has body: I have a basic question for which I can't find an answer on the net: Assuming I have an application where multiple threads share a single instance of a utility method from which potentially long lasting calculations are triggered. Is it possible that massively concurent method calls would influence the performence of the methods execution? EDIT: By "influence the performence" I mean: Significantly decreasing execution speed, or even blocking method execution.
has comment: http://stackoverflow.com/comment/32558804
has answer: http://stackoverflow.com/a/21559030
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21561323
tagged with: java
type: Question
possible better answer: http://stackoverflow.com/a/21558210
has comment: http://stackoverflow.com/comment/32559492
has answer: http://stackoverflow.com/a/21558210
has title: Java: Performance impact of massively concurrent method calls
tagged with: concurrency
accepted answer: http://stackoverflow.com/a/21561323

http://stackoverflow.com/comment/32674987
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21623369
has text: Oh, I'm sorry, I am just not good enough at JEE terminology. Consider, we have our client, which issues its request in terms of DTOs. Server receives client's request and calls several business methods, each acts in a separate transaction. But why don't we have a single transactions per request? I suggest, there are cases when we have an additional long-running processing that is not related to a database.

jvm
tags question: http://stackoverflow.com/q/21633521
tags question: http://stackoverflow.com/q/21661899
tags question: http://stackoverflow.com/q/21644197
tags question: http://stackoverflow.com/q/21603619
tags question: http://stackoverflow.com/q/21669363
tags question: http://stackoverflow.com/q/21597155
type: Tag
tags question: http://stackoverflow.com/q/21625205
tags question: http://stackoverflow.com/q/21621893
tags question: http://stackoverflow.com/q/21658011
tags question: http://stackoverflow.com/q/21675825
tags question: http://stackoverflow.com/q/21652280
tags question: http://stackoverflow.com/q/21632281
tags question: http://stackoverflow.com/q/21604595
tag name: jvm
tags question: http://stackoverflow.com/q/21594071
tags question: http://stackoverflow.com/q/21672452
tags question: http://stackoverflow.com/q/21533774
tags question: http://stackoverflow.com/q/21556576
tags question: http://stackoverflow.com/q/21535189
tags question: http://stackoverflow.com/q/21583745
tags question: http://stackoverflow.com/q/21521149
tags question: http://stackoverflow.com/q/21536892
tags question: http://stackoverflow.com/q/21631167
tags question: http://stackoverflow.com/q/21554988

http://stackoverflow.com/a/21625572
has comment: http://stackoverflow.com/comment/32743664
has comment: http://stackoverflow.com/comment/32772301
has comment: http://stackoverflow.com/comment/32774150
has comment: http://stackoverflow.com/comment/32702441
has comment: http://stackoverflow.com/comment/32685184
answers question: http://stackoverflow.com/q/21625214
has comment: http://stackoverflow.com/comment/32749020
has comment: http://stackoverflow.com/comment/32743337
has comment: http://stackoverflow.com/comment/32679380
has comment: http://stackoverflow.com/comment/32739015
has comment: http://stackoverflow.com/comment/32769868
has comment: http://stackoverflow.com/comment/32767344
has comment: http://stackoverflow.com/comment/32687556
has body: Consider using @Nullable and @NonNull annotations in your code. Partially it can solve your problem. UPDATE: An example of use copied from http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-using_null_annotations.htm @NonNull String getString(String maybeString) { if (maybeString != null) return maybeString; // the above null check is required else return "&lt;n/a&gt;"; } void caller(String s) { System.out.println(getString(s).toUpperCase()); // no null check required } UPDATE: case with @Nullable public @Nullable String getMessage() { return System.currentTimeMillis() % 2 != 0 ? "That's odd..." : null; } public void showCase() { String msg = getMessage(); if (msg.isEmpty()) { //- Here it yields about possible null access //... } } UPDATE: Settings for Null Analysis in my environment: Actual error message from Eclipse: UPDATE: You need to include JAR with Eclipse annotation in build path. Move your mouse pointer over @NonNull or @Nullable annotation that can not be compiled (as shown on the image) and choose Copy library with default null annotations to build path &mdash; New JAR should appear in Package Explorer and compiler should be able to see it. Then move your cursor to the annotation and press Ctrl+Space &mdash; Eclipse should find correct import (note, that you might see two different packages on the list &mdash; choose the one from JDT) &mdash; and select it. It should work.
upvote count: 4
has comment: http://stackoverflow.com/comment/32684679
has comment: http://stackoverflow.com/comment/32756228
has comment: http://stackoverflow.com/comment/32738451
has comment: http://stackoverflow.com/comment/32767504
downvote count: 0
has comment: http://stackoverflow.com/comment/32685537
has comment: http://stackoverflow.com/comment/32745201
score: 4
has comment: http://stackoverflow.com/comment/32742079
has comment: http://stackoverflow.com/comment/32686756
has comment: http://stackoverflow.com/comment/32686268
has comment: http://stackoverflow.com/comment/32766722
has comment: http://stackoverflow.com/comment/32770438
has comment: http://stackoverflow.com/comment/32740554
has comment: http://stackoverflow.com/comment/32698544
has comment: http://stackoverflow.com/comment/32677491
has comment: http://stackoverflow.com/comment/32678958
type: Answer
has comment: http://stackoverflow.com/comment/32698341
has comment: http://stackoverflow.com/comment/32678553
has comment: http://stackoverflow.com/comment/32774029
has comment: http://stackoverflow.com/comment/32769386
has comment: http://stackoverflow.com/comment/32742526
has comment: http://stackoverflow.com/comment/32744876
has comment: http://stackoverflow.com/comment/32678292

http://stackoverflow.com/comment/32697360
comment on: http://stackoverflow.com/q/21636477
score: 0
type: Comment
type: QuestionComment
has text: Yes it possible, but you'd have to load the image to start with and access the raster data, this will also give you the width and height.

http://stackoverflow.com/a/21681230
score: -1
downvote count: 1
has body: i solved it with the help of : ctrl + shift + T so powerfull
answers question: http://stackoverflow.com/q/21677614
type: Answer
upvote count: 0

http://stackoverflow.com/comment/32796687
comment on: http://stackoverflow.com/a/21669242
score: 0
has text: Does it give NullPointerException?
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/32667714
comment on: http://stackoverflow.com/a/21610012
has text: its available for normal a\c? if we pass the link will it play ?
type: AnswerComment
type: Comment
score: 0

http://stackoverflow.com/a/21526391
type: Answer
upvote count: 2
has comment: http://stackoverflow.com/comment/32502853
has comment: http://stackoverflow.com/comment/32505073
answers question: http://stackoverflow.com/q/21526153
has comment: http://stackoverflow.com/comment/32504831
score: 2
has body: If you want unixtime out of it, use strftime('%s', ...): SELECT strftime('%s', time) FROM graphTable; // now access the column as long If you want to convert to Java milliseconds value, just multiply by 1000. Further reading: http://www.sqlite.org/lang_datefunc.html
has comment: http://stackoverflow.com/comment/32502950
downvote count: 0
has comment: http://stackoverflow.com/comment/32504914

http://stackoverflow.com/a/21519636
has body: As your basic requirement is to show data into two ComboBoxes, you can do it as: You can use a loadcombo() to load your cb_ward2 combobox with database values. void loadcombo() { try { Connection conn=null; PreparedStatement pst=null; ResultSet rs=null; // Your database connections String charitysql = "SELECT wardName FROM tbl_charityward"; pst = conn.prepareStatement(charitysql); rs = pst.executeQuery(); while(rs.next()){ cb_ward2.addItem(rs.getString(1)); } con.close(); } catch(Exception e) { System.out.println("Error"+e); } } Now you can use ActionListener on cb_ward2 as: cb_ward2.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ try { Connection con=null; PreparedStatement pst=null,pst1=null; ResultSet rs=null,rs1=null; //your database connection Object name=cb_ward2.getSelectedItem(); pst=con.preparedStatement("select charityWardID from tbl_charityward where wardName=?"); pst.setObject(1,name); rs= pst.executeQuery(); if(rs.next()) { pst1=con.preparedStatement("select charityRoomID from tbl_charityroom2 where charityWardID=?"); pst1.setInt(1,rs.getInt(1)); rs1=pst1.executeQuery(); while(rs1.next()){ cb_room2.addItem(rs1.getInt(1)); } } con.close(); } catch(Exception e) { System.out.println("GG"+e); } } });
has comment: http://stackoverflow.com/comment/32494144
answers question: http://stackoverflow.com/q/21519541
type: Answer
has comment: http://stackoverflow.com/comment/32491918
has comment: http://stackoverflow.com/comment/32491797
has comment: http://stackoverflow.com/comment/32499213
has comment: http://stackoverflow.com/comment/32492694
has comment: http://stackoverflow.com/comment/32492292
has comment: http://stackoverflow.com/comment/32492130
has comment: http://stackoverflow.com/comment/32492995
has comment: http://stackoverflow.com/comment/32492020
score: 0
has comment: http://stackoverflow.com/comment/32491890

http://stackoverflow.com/a/21526500
upvote count: 3
score: 3
has body: Yes, You don't need to close it separately. If you close your oos, it will internally close fos as well. Closing the outer most stream will delegate it all the way down
downvote count: 0
answers question: http://stackoverflow.com/q/21526461
type: Answer

http://stackoverflow.com/comment/32582833
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21571227
has text: are you pressing other buttons before rec?

http://stackoverflow.com/comment/32639329
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21603742
score: 0
has text: @Puce The problem is that the right side of the comparison hasn't been interned - therefore it will never equal to the interned form on the left side.

http://stackoverflow.com/q/21548552
tagged with: java
tagged with: itext
type: Question
answer count: 1
score: 4
tagged with: http://stackoverflow.com/tag/pdf
has title: Create Index File(TOC) for merged pdf using itext library in java
favorite count: 0
downvote count: 0
linked to: http://stackoverflow.com/q/21600040
upvote count: 4
tagged with: itextpdf
has answer: http://stackoverflow.com/a/21577170
accepted answer: http://stackoverflow.com/a/21577170
type: AnsweredQuestion
has body: I am using iText to create a single PDF by merging a number of PDFs using PDFCopy. I need to create a TOC (not bookmarks) at the beginning of this document with clickable links to the first pages of each of the source PDFs. Code to merge pdf Document PDFJoinInJava = new Document(); PdfCopy PDFCombiner = new PdfCopy(PDFJoinInJava, outputStream); PdfCopy.PageStamp stamp; PDFJoinInJava.open(); PdfReader ReadInputPDF; List&lt;InputStream&gt; pdfs = streamOfPDFFiles; List&lt;PdfReader&gt; readers = new ArrayList&lt;PdfReader&gt;(); int totalPages = 0; Iterator&lt;InputStream&gt; iteratorPDFs = pdfs.iterator(); for (; iteratorPDFs.hasNext(); pdfCounter++) { InputStream pdf = iteratorPDFs.next(); PdfReader pdfReader = new PdfReader(pdf); readers.add(pdfReader); totalPages += pdfReader.getNumberOfPages(); pdf.close(); } int number_of_pages; int currentPageNumber = 0; int pageOfCurrentReaderPDF = 0; Iterator&lt;PdfReader&gt; iteratorPDFReader = readers.iterator(); PdfImportedPage page; // Loop through the PDF files and add to the output. int count = 1; while (iteratorPDFReader.hasNext()) { PdfReader pdfReader = iteratorPDFReader.next(); count++; number_of_pages = pdfReader.getNumberOfPages(); // Create a new page in the target for each source page. for (int pageNum = 0; pageNum &lt; number_of_pages;) { currentPageNumber++; pageOfCurrentReaderPDF++; page = PDFCombiner.getImportedPage(pdfReader, ++pageNum); ColumnText.showTextAligned(stamp.getUnderContent(), Element.ALIGN_RIGHT, new Phrase(String .format("%d", currentPageNumber),new Font(FontFamily.TIMES_ROMAN,3)), 50, 50, 0); stamp.alterContents(); PDFCombiner.addPage(page); } } PDFJoinInJava.close();

http://stackoverflow.com/comment/32668657
type: Comment
score: 0
comment on: http://stackoverflow.com/a/21605384
has text: Well what do you mean by _'segment of student name'_? If it is not the exact text in tr, it will not be found. In that case we will have to use contains. Look at the modified code above. And no, what you guessed is not a problem because we are using **//** before td, which allows the td tag to be searched anywhere in table, irrespective of where it is (inside tr in our case).
type: AnswerComment

http://stackoverflow.com/comment/32673609
comment on: http://stackoverflow.com/q/21622885
score: 0
type: Comment
type: QuestionComment
has text: Possibly a dependency issue, see http://stackoverflow.com/questions/5106520/hibernate-nosuchfielderror-instance-but-only-with-struts-1

http://stackoverflow.com/a/21596003
answers question: http://stackoverflow.com/q/21548859
downvote count: 0
type: Answer
has body: I a similar question with the answer being to use a Cantor pairing function. Here: Mapping two integers to one, in a unique and deterministic way. The Cantor pairing function can be used for negative integers as well, using bijection.
upvote count: 1
score: 1

http://stackoverflow.com/a/21569903
has comment: http://stackoverflow.com/comment/32584523
score: 0
type: Answer
has body: Use a repository manager like Nexus. http://nexus.sonatype.org/
has comment: http://stackoverflow.com/comment/32580811
answers question: http://stackoverflow.com/q/21569855

google-app-engine
tags question: http://stackoverflow.com/q/21588107
tag name: google-app-engine
tags question: http://stackoverflow.com/q/21632981
type: Tag
tags question: http://stackoverflow.com/q/21523195
tags question: http://stackoverflow.com/q/21638552
tags question: http://stackoverflow.com/q/21670510
tags question: http://stackoverflow.com/q/21615748
tags question: http://stackoverflow.com/q/21628560
tags question: http://stackoverflow.com/q/21666765
tags question: http://stackoverflow.com/q/21555646
tags question: http://stackoverflow.com/q/21520225
tags question: http://stackoverflow.com/q/21539053
tags question: http://stackoverflow.com/q/21567181
tags question: http://stackoverflow.com/q/21589897
tags question: http://stackoverflow.com/q/21665738
tags question: http://stackoverflow.com/q/21600101
tags question: http://stackoverflow.com/q/21533321
tags question: http://stackoverflow.com/q/21629153
tags question: http://stackoverflow.com/q/21561814
tags question: http://stackoverflow.com/q/21668522
tags question: http://stackoverflow.com/q/21617712
tags question: http://stackoverflow.com/q/21666872
tags question: http://stackoverflow.com/q/21563263

http://stackoverflow.com/comment/32715284
comment on: http://stackoverflow.com/q/21646960
score: 2
type: Comment
type: QuestionComment
has text: "Please do my homework for me." Perhaps you might learn more by doing it yourself.

http://stackoverflow.com/comment/32606008
type: Comment
comment on: http://stackoverflow.com/a/21582720
score: 0
type: AnswerComment
has text: Thanks for your effort! I also looked at safelyCastParamsToArray but came to no conclusion. Maybe I create a ticket :-)

http://stackoverflow.com/q/21569359
answer count: 6
has answer: http://stackoverflow.com/a/21569461
has comment: http://stackoverflow.com/comment/32579744
score: 0
has answer: http://stackoverflow.com/a/21569607
accepted answer: http://stackoverflow.com/a/21569607
has comment: http://stackoverflow.com/comment/32579727
has comment: http://stackoverflow.com/comment/32579812
possible better answer: http://stackoverflow.com/a/21569452
has answer: http://stackoverflow.com/a/21569465
has comment: http://stackoverflow.com/comment/32579791
has answer: http://stackoverflow.com/a/21569427
has comment: http://stackoverflow.com/comment/32579715
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32579797
has comment: http://stackoverflow.com/comment/32579790
type: Question
has body: I am trying to write a program to search for double character appearing side to side . how ever my logic doesnt work. How can i fix this. Example word like 'apple' 'hello' expected output This +word+ will contain double letter System.out.println("Enter word: "); Scanner scanner = new Scanner(System.in); String word = scanner.nextLine(); int i = 0; for (i = 1; i &lt; word.length(); i++) { if (word[i] == word[i + 1]) { System.out.println("word contain double letter"); } else { System.out.println("normal word found"); } }
has answer: http://stackoverflow.com/a/21569432
has answer: http://stackoverflow.com/a/21569452
tagged with: java
has title: Java Search for word that contain double letter

http://stackoverflow.com/a/21534158
type: Answer
has comment: http://stackoverflow.com/comment/32525192
score: 3
accepted answer of: http://stackoverflow.com/q/21534002
has comment: http://stackoverflow.com/comment/32520166
upvote count: 3
answers question: http://stackoverflow.com/q/21534002
has body: You need to pass the configuration to the gwt-maven-plugin via mvn -Dgwt.extraJvmArgs=-Xmx1280m clean install see also http://mojo.codehaus.org/gwt-maven-plugin/compile-mojo.html You could also try to reduce the amount of memory: Could not reserve enough space for object heap This sounds like the JVM can't reserve the desired space. Try -Xmx1024m or -Xmx768m. If this also doesn't work, you could try to use a 64 bit JVM to compile the code.
has comment: http://stackoverflow.com/comment/32522075
has comment: http://stackoverflow.com/comment/32518250
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32520670

http://stackoverflow.com/comment/32708849
score: 0
type: Comment
type: QuestionComment
has text: It still shows an error. Red underline under the `org` part in `import org.everything.*`.
comment on: http://stackoverflow.com/q/21642905

http://stackoverflow.com/comment/32576172
comment on: http://stackoverflow.com/q/21567327
type: Comment
type: QuestionComment
score: 2
has text: Agree with everyone that it would be bad design, double-checked the API docs and found that there is indeed a no-args-constructor, but I still believe it is a useful trick to know for the future if I am dealing with such a poorly designed API.

http://stackoverflow.com/a/21585170
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/21585096
has body: This answer won't give you a definitive solution, not because I'm not willing, but because it's impossible (and even harder without not just viewing your code, but knowing very well your code). But from my experience I can tell you that those kind of memory leaks doesn't occur just due to directly referenced objects - objects you declare (and keep referencing another classes/objects) in turn depends on many other classes and so on, and probably you're seeing a memory leak due to an incorrect handling of any of your instances which at the same time reference to other instances. Debugging memory leaks is a often a very hard work, not just because as I said above it sometimes doesn't depend directly on what you've declared, but also because finding a solution might not be trivial. The best thing you can do is what you already seem to be doing: DDMS + HPROF. I don't know how much knowledge you have, but although it's not a universal method, this link helped me so much to find memory leaks in my code. Although it seems trivial, the best way to debug those kind of things is progresively remove portions of your code (overall, those which implies working with instances of other classes) and see how the HPROF report change. ---- EDIT ---- This question on SO is a good example to illustrate the GC roots.
upvote count: 1
has comment: http://stackoverflow.com/comment/32608358
type: Answer
has comment: http://stackoverflow.com/comment/32607749
has comment: http://stackoverflow.com/comment/32608455

http://stackoverflow.com/comment/32642555
has text: Sorry, I made a mistake in the doc, `-java.rmi.server.hostname=10.80.16.195` have to be specified in order to make it work...
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21605286

http://stackoverflow.com/comment/33141789
has text: [@DontvotemeDown](http://stackoverflow.com/users/1267304/dontvotemedown) your jsfidle link is not my ans but your link is useful for me lot.It is starting kick for me. The sol that i want is [here](http://jsfiddle.net/5Jyuy/)
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21626059

http://stackoverflow.com/a/21725144
answers question: http://stackoverflow.com/q/21677984
type: Answer
has body: Well problem solved. In case someone will run into it the future: The solution is to add to the web.xml: *.jsp true *.jsp true
score: 0

http://stackoverflow.com/comment/32512767
comment on: http://stackoverflow.com/a/21531638
score: 0
type: AnswerComment
has text: You're right: it is not a real english word. I meant creating an array with a given length.
type: Comment

http://stackoverflow.com/a/22880850
upvote count: 28
type: Answer
has comment: http://stackoverflow.com/comment/42459204
has comment: http://stackoverflow.com/comment/34968431
has comment: http://stackoverflow.com/comment/47912435
accepted answer of: http://stackoverflow.com/q/21598016
has comment: http://stackoverflow.com/comment/35003233
has comment: http://stackoverflow.com/comment/40131632
has comment: http://stackoverflow.com/comment/53849466
has comment: http://stackoverflow.com/comment/55386740
has body: I think that the problem is that in Spring 4, they use @Repeatable annotation, which has only been introduced in Java 8. Therefore, if you're not using Java 8 you'll continue to see this problem, at least until this issue will be fixed. BTW, this is also preventing the usage of @Scheduled annotation in older JDKs than Java 8. I hope it will be fixed soon.
type: AcceptedAnswer
downvote count: 0
score: 28
answers question: http://stackoverflow.com/q/21598016

http://stackoverflow.com/comment/32614408
type: Comment
type: AnswerComment
has text: @John it's not a memory location
comment on: http://stackoverflow.com/a/21588750
score: 0

http://stackoverflow.com/q/21653357
has body: Scanner sc = new Scanner(System.in); System.out.println("Enter title of the book: "); String title = sc.next(); System.out.println("Enter the author: "); String author = sc.next(); String bookID = bookID(); Book b = new Book(author,title,bookID,true); books.add(b); System.out.println( title + " by "+ author +" added to library."); System.out.println("Book ID: " + bookID); This produces the following output with the title being "Gone with the Wind" and the author Margaret Mitchell: Gone by with added to library Book ID:456423156 Is there a way I can get around this?
answer count: 1
score: 0
has answer: http://stackoverflow.com/a/21653399
has title: How do you use the Scanner class in java to store two words or more in a String variable, then the next input in another String variable?
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21653399
tagged with: java
type: Question

http://stackoverflow.com/q/21597991
tagged with: methods
type: Question
possible better answer: http://stackoverflow.com/a/21598027
has title: Recursive method return and print Int number of String
score: 0
accepted answer: http://stackoverflow.com/a/21598095
has comment: http://stackoverflow.com/comment/32629799
has body: I'm having trouble with my recursive method. Which will return and print in my main method the X number of W. X being a positive integer on the commandline (arg[0]) and W is a String on the commandline (arg[1]). So for what ever number it will print the string that much times. For example my 1st commandline argument is "4" and my 2nd commandline argument is Hello. Output should be printed as a string: "HelloHelloHelloHello" I'm getting problems with my parameters being a int and a string I believe :( ? My code atm: public static void main(String[] args){ int number = new Integer(0); String word = new String(""); number = Integer.parseInt(args[0]); word = args[1]; String method = recursive1.method1(word); System.out.println(method); } public static String method1(String word, int number) { if (number &lt; 0){ return 0; } else{ return word + method1(number-1); } } }
has comment: http://stackoverflow.com/comment/32629912
has answer: http://stackoverflow.com/a/21598138
has answer: http://stackoverflow.com/a/21598220
tagged with: return
answer count: 4
has comment: http://stackoverflow.com/comment/32629871
tagged with: recursion
tagged with: command-line
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21598095
tagged with: java
has answer: http://stackoverflow.com/a/21598027

http://stackoverflow.com/a/21617322
type: Answer
has comment: http://stackoverflow.com/comment/32664244
has body: I guess the problem is related to timezone. Date.getTime() returns value in UTC (Greenwich) time, if the string returned by getLastPlayed() is in local time, the difference can be many hours (depending on your timezone) even if you played 1 second ago.
has comment: http://stackoverflow.com/comment/32664536
score: 2
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21617248
answers question: http://stackoverflow.com/q/21617248
upvote count: 2
has comment: http://stackoverflow.com/comment/32664206
type: AcceptedAnswer

http://stackoverflow.com/q/21592056
has comment: http://stackoverflow.com/comment/32621863
has body: In 2012, Terence Parr wrote: "added fuzzy java "parser" to v4 examples page Hi, Check out the bottom of this page for a fuzzy Java parser that uses just lexical rules to grab items of interest: http://www.antlr.org/wiki/display/ANTLR4/Examples Ter" But the page is "404" and I cannot find this grammar. Anybody has a copy? Or a pointer to another fuzzy or error-recovery Java grammar?
tagged with: parsing
tagged with: antlr4
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/66617426
has title: Fuzzy java parser in Antlr 4
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32620125
score: 0
answer count: 1

http://stackoverflow.com/comment/32714916
has text: That seems to be very interesting link because each my lib for each platform has big size. I'll check the link!
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21645770
type: Comment

http://stackoverflow.com/comment/32676290
type: QuestionComment
has text: Yes. you are correct. The batch files runs fine, when i run it as standalone.But I am not able to run from java only.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/21624741

http://stackoverflow.com/a/21574724
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/21574468
has body: No, you can't figure out how much data will come from a stream in advance. That's simply not how streams are meant to work. What you could do, if you are writing both ends of the code, is to first calculate the file size on the sending end and send that before sending the file contents itself.
type: Answer
downvote count: 0

http://stackoverflow.com/comment/32665653
comment on: http://stackoverflow.com/q/21618009
type: QuestionComment
type: Comment
has text: Weird. I've installed it multiple times and the website keeps saying I have the latest version, and the installer is called chromeinstall-7u51.exe, but when I enter java -version I get 1.7.0_17.
score: 0

http://stackoverflow.com/comment/32687469
score: 0
type: Comment
type: QuestionComment
has text: http://docs.oracle.com/javase/6/docs/api/java/math/BigDecimal.html
comment on: http://stackoverflow.com/q/21630855

http://stackoverflow.com/comment/32632522
score: 0
comment on: http://stackoverflow.com/q/21599638
type: Comment
type: QuestionComment
has text: why dont g.drawString(Score, x ,y);?

http://stackoverflow.com/q/21541455
downvote count: 0
has body: I am writing a cross-platform application that creates temporary files and copies these to another location, where they need to be readable by everyone. (By default, only the owner has read access to temporary files.) I tried using the POSIX file permissions as follows: FileAttribute&lt;Set&lt;PosixFilePermission&gt;&gt; attrs = PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-r--r--")); Path temp = Files.createTempFile(null, ".tmp", attrs); But this results in an exception on non-POSIX platforms: java.lang.UnsupportedOperationException: 'posix:permissions' not supported as initial attribute I want to add a simple check so that I can use the file permissions where necessary, without breaking compatibility with other platforms.
upvote count: 28
has title: How to check if the OS is POSIX compliant
answer count: 1
favorite count: 0
tagged with: nio2
tagged with: posix
has answer: http://stackoverflow.com/a/21541615
accepted answer: http://stackoverflow.com/a/21541615
type: AnsweredQuestion
score: 28
tagged with: java
has comment: http://stackoverflow.com/comment/32530307
tagged with: nio
has comment: http://stackoverflow.com/comment/32530289
type: Question

http://stackoverflow.com/comment/33358832
comment on: http://stackoverflow.com/q/21631510
type: Comment
has text: Can you try calling WebSettings.setAllowFileAccessFromFileURLs(true) and if that doesn't work, WebSettings.setAllowUniversalAccessFromFileURLs(true) ? They both had a behavior change between ICS and JB, and relate to JS from file:// URLs.
score: 1
type: QuestionComment

http://stackoverflow.com/q/21656410
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/21656642
type: Question
tagged with: execute
answer count: 1
tagged with: jar
favorite count: 0
score: 0
has body: Assume that I have a .jar file A which has method "long calculateSomething(String args)". A.jar is stored in folder /service. Now, I want to develop a java application which can invoke method calculateSomething from A.jar file, execute and get the return value from this method. How can I achieve it? Oracle has a similar example in following link: http://docs.oracle.com/javase/tutorial/deployment/jar/apiindex.html However, It call and execute the main method in A.jar file with void return. Hence, I could not apply that technique. Could you please tell me the solution for my problem? Thank you
accepted answer: http://stackoverflow.com/a/21656642
has title: Invoke and pass parameters and get the return value of certain method defined in separate jar file
has comment: http://stackoverflow.com/comment/32732030
has comment: http://stackoverflow.com/comment/32733215
has comment: http://stackoverflow.com/comment/32732177
upvote count: 1
downvote count: 1

http://stackoverflow.com/comment/32603763
score: 2
comment on: http://stackoverflow.com/q/21583015
type: QuestionComment
has text: getlastknownlocation will return null if there is no last known location, you need to check if you have a lastknowlocation if not call an update. I never try location with the emulator because I really thing you need to do something that make it work as a normal phone with the location service enabled. So my guess is you are always getting null because you are using the emulator. Also GPS works really fine in the outside, inside in your home maybe could fail and will not provide you a location.
type: Comment

http://stackoverflow.com/q/21622169
favorite count: 0
has comment: http://stackoverflow.com/comment/32672173
has body: I have to listen 3 different ports for UDP in my Java project. I implemented my system as follows: I have a UDPMessageListener class which implements Runnable. I want to create 3 threads running as this object. I have an interface called "UDPPacketProcessor" which has a single onPacketReceived method. Every UDPMessageListener has a UDPPacketProcessor instance, and directs the UDP packet to the object registered as its UDPPacketProcessor. And I have a DatabaseProc Class which needs to serve to the messages coming from 3 different UDP ports. DatabaseProc implements UDPPacketProcessor to register itself to those 3 UDPMessageListener classes. In theory, according my Java knowledge there cannot be any problem, 3 Runnable threads listens to 3 ports, and on packet received, calls a method of my main singleton object's method. However, when I run the program, only one of the ports is listened. I can only the HBMessageListener works correctly, the others do not respond. When I bypass the HBMessageListener (comment out the line I run it) I can now see that only AlarmMessageListener works. Where am I wrong? UDPMessageListener.java public class UDPMessageListener implements Runnable { int port; byte[] receiveData; DatagramSocket udpListeningSocket; UDPPacketProcessor processor; public UDPMessageListener(UDPPacketProcessor listener,int localPort){ port = localPort; this.processor = listener; receiveData = new byte[SRPDefinitions.BYTE_BUFFER_MAX_LENGTH]; try { udpListeningSocket = new DatagramSocket(port); } catch (SocketException e) { System.out.println("Socket bind error in port: " + port); e.printStackTrace(); } } @Override public void run() { while(true){ DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); try { udpListeningSocket.receive(receivePacket); System.out.println("Received UDP Packet from Port:" + port); processor.onPacketReceived(receivePacket, port); } catch (IOException e) { System.out.println("UDP Listener end up with an exception…
has answer: http://stackoverflow.com/a/21622474
type: AnsweredQuestion
downvote count: 0
tagged with: multithreading
has comment: http://stackoverflow.com/comment/32672149
has comment: http://stackoverflow.com/comment/32671907
type: Question
score: 3
tagged with: java
has title: How can I listen to UDP ports in Java?
upvote count: 3
tagged with: udp
accepted answer: http://stackoverflow.com/a/21622474
answer count: 1

http://stackoverflow.com/q/21544348
upvote count: 2
tagged with: uml
type: AnsweredQuestion
has title: Is it necessary to include JButton variables in UML?
tagged with: java
type: Question
answer count: 1
downvote count: 0
has body: I am curious as to if programmers actually put all the variables that will be eventually required? Many GUIs will have a multitude of JButtons and it seems as though it would become tedious adding them all. However, as I am only in my second year of University maybe I am wrong? Thanks in advance for any help.
has answer: http://stackoverflow.com/a/21547541
favorite count: 0
accepted answer: http://stackoverflow.com/a/21547541
score: 2

http://stackoverflow.com/comment/32683098
score: 0
type: AnswerComment
type: Comment
has text: I have tried the debug statements you suggest and it didn't finish printing the debug file, at a certain points it freezes and didn't keep printing. I have updated the answer with the results. Thanks again
comment on: http://stackoverflow.com/a/21621093

http://stackoverflow.com/comment/32547352
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21551800
has text: I was using mac at the moment, I will try in windows, if it makes any difference.
score: 0

http://stackoverflow.com/comment/32657350
type: QuestionComment
comment on: http://stackoverflow.com/q/21613204
type: Comment
has text: I'd rather leave it as exercise for the reader, since knowing that it's possible you *should* be able to figure it out for yourself. Hint keywords: Incremental, and Split.
score: 0

http://stackoverflow.com/a/21676555
has body: You can simply use /root/table/concat(a, b), that will give you a sequence of strings. But you will need to use an API that can handle that return type, I think the JAXP API is restricted to XPath 1.0 types so make sure you use Saxon's http://www.saxonica.com/documentation/index.html#!xpath-api/s9api-xpath if you want to take full advantage of XPath 2.0.
upvote count: 3
score: 3
accepted answer of: http://stackoverflow.com/q/21672729
answers question: http://stackoverflow.com/q/21672729
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32767002
type: Answer

http://stackoverflow.com/q/21575759
type: Question
downvote count: 0
favorite count: 0
has body: I have two xlsx files at folder C:\DemoFilesExcel\demo1.xlsx and C:\DemoFilesExcel\demo2.xlsx. I want to create a new xlsx C:\DemoFilesExcel\merged.xlsx that will have these two files as two sheets in merged.xlsx workbook. This is to be done using apache POI in java. Any idea how to do
has answer: http://stackoverflow.com/a/29092463
has answer: http://stackoverflow.com/a/69659398
has answer: http://stackoverflow.com/a/53834875
upvote count: 11
has answer: http://stackoverflow.com/a/54686921
tagged with: apache-poi
answer count: 5
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32590427
has answer: http://stackoverflow.com/a/49188932
score: 11
has title: Merging Two excel files as two sheets in one workbook in java
linked to: http://stackoverflow.com/q/13090313
tagged with: java

http://stackoverflow.com/comment/40002669
type: AnswerComment
comment on: http://stackoverflow.com/a/21684563
score: 0
type: Comment
has text: I had the same problem, but couldn't do @Category.find.all(), it wouldn't compile on play 2.3. I passed the category list as a template parameter instead.

http://stackoverflow.com/comment/32583119
type: Comment
type: QuestionComment
has text: B is an interesting algorithm. Seems to work but I'm having a bit of trouble at this late hour explaining to myself why it should work.
comment on: http://stackoverflow.com/q/21570890
score: 0

web-services
tags question: http://stackoverflow.com/q/21636413
type: Tag
tags question: http://stackoverflow.com/q/21526647
tags question: http://stackoverflow.com/q/21576186
tags question: http://stackoverflow.com/q/21633819
tags question: http://stackoverflow.com/q/21609406
tags question: http://stackoverflow.com/q/21620620
tags question: http://stackoverflow.com/q/21646260
tags question: http://stackoverflow.com/q/21600212
tags question: http://stackoverflow.com/q/21627506
tags question: http://stackoverflow.com/q/21671969
tags question: http://stackoverflow.com/q/21550637
tags question: http://stackoverflow.com/q/21670451
tags question: http://stackoverflow.com/q/21608974
tags question: http://stackoverflow.com/q/21590757
tags question: http://stackoverflow.com/q/21641752
tags question: http://stackoverflow.com/q/21597364
tags question: http://stackoverflow.com/q/21597232
tags question: http://stackoverflow.com/q/21568532
tags question: http://stackoverflow.com/q/21652017
tags question: http://stackoverflow.com/q/21670903
tags question: http://stackoverflow.com/q/21538035
tags question: http://stackoverflow.com/q/21556961
tags question: http://stackoverflow.com/q/21621781
tags question: http://stackoverflow.com/q/21586347
tags question: http://stackoverflow.com/q/21575088
tags question: http://stackoverflow.com/q/21530826
tags question: http://stackoverflow.com/q/21576233
tags question: http://stackoverflow.com/q/21521411
tags question: http://stackoverflow.com/q/21635061
tags question: http://stackoverflow.com/q/21604829
tags question: http://stackoverflow.com/q/21571225
tags question: http://stackoverflow.com/q/21534965
tags question: http://stackoverflow.com/q/21523996
tags question: http://stackoverflow.com/q/21540051
tags question: http://stackoverflow.com/q/21608881
tags question: http://stackoverflow.com/q/21580201
tags question: http://stackoverflow.com/q/21659447
tags question: http://stackoverflow.com/q/21644973
tags question: http://stackoverflow.com/q/21526767
tags question: http://stackoverflow.com/q/21558893
tags question: http://stackoverflow.com/q/21593876
tags question: http://stackoverflow.com/q/21580808
tag name: web-services
tags question: http://stackoverflow.com/q/21526431
tags question: http://stackoverflow.com/q/21621901
tags question: http://stackoverflow.com/q/21601166
tags question: http://stackoverflow.com/q/21518851
tags question: http://stackoverflow.com/q/21602442
tags question: http://stackoverflow.com/q/21590210
tags question: http://stackoverflow.com/q/21670376
tags question: http://stackoverflow.com/q/21574840
tags question: http://stackoverflow.com/q/21537169
tags question: http://stackoverflow.com/q/21529429
tags question: http://stackoverflow.com/q/21587220

concurrency
tag name: concurrency
tags question: http://stackoverflow.com/q/21570013
tags question: http://stackoverflow.com/q/21558157
tags question: http://stackoverflow.com/q/21518730
tags question: http://stackoverflow.com/q/21677743
tags question: http://stackoverflow.com/q/21604243
tags question: http://stackoverflow.com/q/21668667
tags question: http://stackoverflow.com/q/21633443
tags question: http://stackoverflow.com/q/21582590
tags question: http://stackoverflow.com/q/21644895
tags question: http://stackoverflow.com/q/21546166
tags question: http://stackoverflow.com/q/21652931
tags question: http://stackoverflow.com/q/21677479
tags question: http://stackoverflow.com/q/21548276
tags question: http://stackoverflow.com/q/21655538
tags question: http://stackoverflow.com/q/21657626
tags question: http://stackoverflow.com/q/21618273
tags question: http://stackoverflow.com/q/21562131
tags question: http://stackoverflow.com/q/21533731
tags question: http://stackoverflow.com/q/21540974
type: Tag
tags question: http://stackoverflow.com/q/21586845
tags question: http://stackoverflow.com/q/21592912
tags question: http://stackoverflow.com/q/21541559
tags question: http://stackoverflow.com/q/21568501

http://stackoverflow.com/comment/32632253
type: AnswerComment
has text: @Sand. Check other methods in DataInputStream java API.. Did you tried read(Bytes b) method and then converting bytes to String ? or using readLine() method (though readLine method is depricated , once try whether it will work for you or not) 'DataInputStream dIn= new DataInputStream(SOCK.getInputStream()); String filename=dIn.readLine'
type: Comment
comment on: http://stackoverflow.com/a/21599229
score: 0

http://stackoverflow.com/q/21668944
tagged with: scheduled-tasks
favorite count: 0
has title: Solution to run a jar file at specific time each day
type: Question
answer count: 2
has body: I am want to distribute a jar script that needs to run periodically. I don't know which OS the end user will have. Is there a cross OS solution that I can use to run a jar file at a specific time each day. That is, in windows it adds a scheduled task and a cron task etc. Any help appreciated !
tagged with: java
upvote count: 1
has answer: http://stackoverflow.com/a/21669012
tagged with: jar
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21668966
downvote count: 0
score: 1

http://stackoverflow.com/q/21532776
tagged with: java
tagged with: file
upvote count: 1
accepted answer: http://stackoverflow.com/a/21534614
type: Question
has comment: http://stackoverflow.com/comment/32541776
tagged with: java-io
has comment: http://stackoverflow.com/comment/32514660
has comment: http://stackoverflow.com/comment/32515084
has comment: http://stackoverflow.com/comment/32515319
answer count: 1
downvote count: 0
tagged with: smartgwt
favorite count: 0
has answer: http://stackoverflow.com/a/21534614
has title: GWT java.io.File server package
has body: I was looking for hours now, but I can't find what I'm looking for. I know java.io.File is not supported in the GWT client package. I want to use it inside the server package. When I compile the app i get the following error: Compiling module com.xxx.yyy.GWTApp Validating units: [ERROR] Errors in 'file:/.../workspace/GWTApp/src/com/xxx/yyy/server/Class1.java' [ERROR] Line 26: No source code is available for type java.io.File; did you forget to inherit a required module? [ERROR] Errors in 'file:/.../workspace/GWTApp/src/com/xxx/yyy/server/Class2.java' [ERROR] Line 104: No source code is available for type java.io.BufferedReader; did you forget to inherit a required module? [ERROR] Line 104: No source code is available for type java.io.FileReader; did you forget to inherit a required module? ... Any Ideas what could be wrong? Edit *.gwt.xml file: &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd"&gt; &lt;module rename-to='yyy'&gt; &lt;inherits name='com.google.gwt.user.User'/&gt; &lt;inherits name='com.google.gwt.user.theme.clean.Clean'/&gt; &lt;entry-point class='com.xxx.yyy.client.Yyy'/&gt; &lt;source path='client'/&gt; &lt;source path='shared'/&gt; &lt;source path='server'/&gt; &lt;inherits name="com.smartgwt.SmartGwt"/&gt; &lt;/module&gt;
has comment: http://stackoverflow.com/comment/32515640
tagged with: gwt
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32517358
score: 1

http://stackoverflow.com/comment/32666689
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21618257
has text: Yes, [here](http://docs.oracle.com/javase/tutorial/essential/environment/paths.html).

http://stackoverflow.com/a/21548031
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21547717
type: Answer
has comment: http://stackoverflow.com/comment/32584080
has body: The FindBugs tool has a number of rules for bugs related to serialization; see the list of bug descriptions. There is also an Eclipse plugin for FindBugs. Some related stuff: There is an Inspection in the YourKit memory profiler that will find objects that are declared as Serializable but have non-serializable fields: (That is more pertinent to your problems than classes that don't implement Serializable.) There is a Java runtime option described here to get more information about the cause of a "not serializable" exception.
score: 2
downvote count: 0
upvote count: 2
accepted answer of: http://stackoverflow.com/q/21547717

http://stackoverflow.com/q/21634510
has body: Good afternoon, I wonder what would be the correct way to find the serial number of hard disk and matherboard a PC with Linux operating system using java code. Use the Process p = Runtime.getRuntime () exec ("hdparm-I / dev / sda | grep Serial") command,. To get the hard disk, but the command is not executed. Could help me? Thanks Greetings!
has answer: http://stackoverflow.com/a/41156245
has answer: http://stackoverflow.com/a/21634586
tagged with: linux
has comment: http://stackoverflow.com/comment/32693583
favorite count: 0
type: UnansweredQuestion
has title: Get id of motherboard and hard disk in java for linux operating system?
downvote count: 0
score: 1
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32700903
answer count: 2
upvote count: 1

http://stackoverflow.com/comment/75184949
has text: @failed.down and then this page comes up .... :D
type: Comment
comment on: http://stackoverflow.com/q/21642530
score: 0
type: QuestionComment

http://stackoverflow.com/q/21514596
tagged with: vlcj
has comment: http://stackoverflow.com/comment/32583236
score: 0
has body: I am trying to make a java program that will record video and audio from my webcam (or some other stream/source). I am using code from the vlcj tutorial, andwhen I run it in Netbeans I get no error messages but it only records audio if the acodec is mpga, and only video if the acodec is mpga. Here is my code: package cyclops; /** * * @author Black Tie */ import uk.co.caprica.vlcj.binding.LibVlc; import uk.co.caprica.vlcj.runtime.RuntimeUtil; import com.sun.jna.Native; import com.sun.jna.NativeLibrary; import javax.swing.JFrame; import javax.swing.SwingUtilities; import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent; public class Cyclops { private final EmbeddedMediaPlayerComponent mediaPlayerComponent; public static void main(final String[] args) { NativeLibrary.addSearchPath( RuntimeUtil.getLibVlcLibraryName(),"C:\\Program Files\\VideoLAN\\VLC"); Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(),LibVlc.class); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Cyclops(); } }); } private Cyclops() { mediaPlayerComponent = new EmbeddedMediaPlayerComponent(); JFrame frame = new JFrame("Lesson Record"); frame.setContentPane(mediaPlayerComponent); frame.setLocation(100, 100); frame.setSize(450, 450); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); String mediaURL= "dshow://"; mediaPlayerComponent.getMediaPlayer().playMedia(mediaURL,":sout=#transcode{vcodec=h264,venc=x264{cfr=16},scale=1,acodec=mpga,ab=160,channels=2,samplerate=44100}:file{dst=C:\\Users\\Black Tie\\Documents\\vlcVideos\\trial13j.mpg"); } } If anyone could give me advice on what may be going wrong I would very much appreciate it. Thanks.
has comment: http://stackoverflow.com/comment/32571400
has comment: http://stackoverflow.com/comment/32660747
answer count: 0
type: UnansweredQuestion
tagged with: record
tagged with: vlc
tagged with: webcam
has comment: http://stackoverflow.com/comment/32671681
tagged with: java
type: Question
has title: Record video (and audio) from webcam using vlcj
has comment: http://stackoverflow.com/comment/32497684

http://stackoverflow.com/q/21577430
downvote count: 0
duplicate of: http://stackoverflow.com/q/7335018
favorite count: 0
tagged with: instanceof
has body: How can i determine if an object is instance of a parametrized type of a generic class for example ArrayList&lt;String&gt;? I tried: if(obj instanceof ArrayList&lt;String&gt;) but it failed with compiler error!
has answer: http://stackoverflow.com/a/21577555
tagged with: templates
possible better answer: http://stackoverflow.com/a/21577555
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21577580
upvote count: 3
type: Question
score: 3
tagged with: java
linked to: http://stackoverflow.com/q/3403909
has title: instanceof for template types in java
accepted answer: http://stackoverflow.com/a/21577580
answer count: 2
linked to: http://stackoverflow.com/q/7335018

http://stackoverflow.com/q/21635660
score: 0
tagged with: random
answer count: 2
tagged with: arrays
tagged with: multidimensional-array
possible better answer: http://stackoverflow.com/a/21635706
has answer: http://stackoverflow.com/a/21635717
has answer: http://stackoverflow.com/a/21635706
has title: Creating and initialising a 2D Array in Java
type: AnsweredQuestion
tagged with: netbeans
has body: I haven't used 2D Arrays before so apologies for any 'obvious statements'. I want to create a 2D Array for a 15 by 20 'table' and want the following to be applied: I want each row to be a separate Array. I want each row to have random 0's and 1's generated The code I have created creates the 15 x 20 table but not sure if each row is an Array and can't figure out how to put random 0's and 1's. Help would be appreciated! Thanks! for (int i=0; i &lt; ar.length; i++) { for (int j=0; j &lt; ar[i].length; j++) { ar[i][j] = 0; System.out.print(" " + ar[i][j]); } System.out.println(""); }
type: Question
accepted answer: http://stackoverflow.com/a/21635717
tagged with: java

xsd
tags question: http://stackoverflow.com/q/21630363
tags question: http://stackoverflow.com/q/21532631
tags question: http://stackoverflow.com/q/21595049
tags question: http://stackoverflow.com/q/21574154
tag name: xsd
tags question: http://stackoverflow.com/q/21620057
tags question: http://stackoverflow.com/q/21633797
tags question: http://stackoverflow.com/q/21527978
tags question: http://stackoverflow.com/q/21586396
tags question: http://stackoverflow.com/q/21573636
tags question: http://stackoverflow.com/q/21520519
type: Tag
tags question: http://stackoverflow.com/q/21606248

http://stackoverflow.com/comment/32563088
comment on: http://stackoverflow.com/q/21560164
score: 0
has text: Okay guys my problem is fixed, my php files had problems... i let some text at the tope of the code(before the <php>). Thanks !
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32486707
comment on: http://stackoverflow.com/q/21517025
has text: Where do you decode the base64 data to binary?
score: 1
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21591084
accepted answer of: http://stackoverflow.com/q/21591014
has comment: http://stackoverflow.com/comment/32618699
answers question: http://stackoverflow.com/q/21591014
type: Answer
score: 1
has comment: http://stackoverflow.com/comment/32618461
upvote count: 1
has body: Find the number of unique words. You can do it, by putting all the words from the stringArray to a hashmap. The hashmap will come handy later. Create an array like that retArr = new int[unique][2]; Complete solution below (beware, I didn't even compile it!) public static int[][] dupWords (String str) { String [] stringArray = str.split(" "); int countWords = 0; int index = 0; HashMap&lt;String, Integer&gt; indexMap = new HashMap&lt;String, Integer&gt;(); HashMap&lt;String, Integer&gt; countMap = new HashMap&lt;String, Integer&gt;(); int index = 0; for (int i = 0; i &lt; stringArray.size(); i++) { String s = stringArray[i]; if (!indexMap .containsKey(s)) { indexMap.put(s, index); countMap.put(s, 1); } else { int cnt = countMap.get(s); countMap.put(s, cnt+1); } index += s.length() + 1; } int [][] retArr = new int[map.size()][2]; for (int i = 0; i &lt; stringArray.size(); i++) { String s = stringArray[i]; retArr[i][0] = indexMap.get(s); retArr[i][1] = countMap.get(s); } return retArr; } Now, without HashMap, or any other dynamic structure it's quite difficult to do. The easiest approach is to create a bigger than necessary array and at the end trim it. This could look like this. public static int[][] dupWords (String str) { String [] stringArray = str.split(" "); int countWords = 0; int index = 0; int [][] retArr = new int[stringArray.size()][2]; int uniqeWords = 0; for (int i = 0; i &lt; stringArray.size(); i++) { String s = stringArray[i]; if (s != null) { retArr[uniqueWords][0] = str.indexOf(s); int cnt = 1; for (int j = i + 1; j &lt; stringArray.size(); j++) { if (s.equalsIgnoreCase(stringArray[j])) { stringArray[j] = null; cnt++; } } retArr[uniqueWords][1] = cnt; uniqueWords++; } } int[][] newRetArr = new int[uniqueWords][2]; for (int i = 0; i &lt; uniqueWords; i++) { newRetArr[i][0] = retArr[i][0]; newRetArr[i][1] = retArr[i][1]; } return newRetArr; }
has comment: http://stackoverflow.com/comment/32618441
has comment: http://stackoverflow.com/comment/32618903
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32619100

weblogic8.x
tag name: weblogic8.x
tags question: http://stackoverflow.com/q/21635838
type: Tag

http://stackoverflow.com/comment/32731410
type: Comment
comment on: http://stackoverflow.com/a/21652113
has text: Thank you. It means Infinispan is maintaining a single atomic variable for the whole cache right rather than for separate keys?
type: AnswerComment
score: 0

http://stackoverflow.com/q/21656481
type: Question
answer count: 2
tagged with: xtend
downvote count: 0
tagged with: eclipse-plugin
has answer: http://stackoverflow.com/a/61111540
tagged with: testng
favorite count: 0
has body: here's Xtend class, I cannot seems to get eclipse to run configuration of this TestNg file I wrote on eclipse xtend. I installed TestNg Plugin as well, but still I don't see a option. How can I run it? Does Xtend Plugin or TestNg plugin requires and modifications to support adding the run as configuration ? If so how may I add necessary changes? MySampleTestng.xtend file import org.testng.annotations.Test class MySampleTestng { @Test def void testPrintln() { println("Hello, World.") } }
has title: how to run xtend TestNg class?
tagged with: xtext
type: UnansweredQuestion
upvote count: 1
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/21865271

http://stackoverflow.com/comment/32710569
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21619719
has text: Thanks for the feedback. Sorry I'm not sure how to mark the update as I'm fairly new to this site. I tried your method and I also fixed the howManyMailItems method and it still doesn't work. I think there's something wrong with the MailClient class but I'm not sure what's causing the problem. Thanks a lot again. Appreciate your time and help.
type: AnswerComment

http://stackoverflow.com/a/21604360
type: Answer
has body: package de.indv.rentino.mk3.hibernate.lucene.search.sort; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Random; import java.util.Set; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.FieldCache; import org.apache.lucene.search.FieldComparator; import org.apache.lucene.search.FieldComparatorSource; import org.hibernate.search.bridge.TwoWayStringBridge; /** * Round Robin Sorting for Lucene * * @author Martin Braun */ public class RoundRobinFieldComparatorSource&lt;T&gt; extends FieldComparatorSource { private static long seed = new Random().nextInt(); public static void setNewSeed(long seed) { RoundRobinFieldComparatorSource.seed = seed; } private static final long serialVersionUID = -8959374194451783596L; private final Set&lt;T&gt; roundRobinValues; private final boolean excluded; private final TwoWayStringBridge stringBridge; private final Set&lt;String&gt; preferredValues; public RoundRobinFieldComparatorSource(TwoWayStringBridge stringBridge, Set&lt;T&gt; roundRobinValues) { this(stringBridge, roundRobinValues, new HashSet&lt;T&gt;()); } /** * same as * {@link #RoundRobinFieldComparatorSource(TwoWayStringBridge, Set, boolean)} * but with excluded set to false */ public RoundRobinFieldComparatorSource(TwoWayStringBridge stringBridge, Set&lt;T&gt; roundRobinValues, Set&lt;T&gt; preferredValues) { this(stringBridge, roundRobinValues, preferredValues, false); } /** * @param excluded * determines whether the passed roundRobinValues are to be * excluded in scheduling */ public RoundRobinFieldComparatorSource(TwoWayStringBridge stringBridge, Set&lt;T&gt; roundRobinValues, Set&lt;T&gt; preferredValues, boolean excluded) { this.stringBridge = stringBridge; this.roundRobinValues = roundRobinValues; this.excluded = excluded; this.preferredV…
answers question: http://stackoverflow.com/q/21528491
score: 0

http://stackoverflow.com/comment/32604256
has text: Thanks Angular Harsh. I have posted the code for the part that is causing me problems by editing into the original question. AJFarroll
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21551801

http://stackoverflow.com/comment/32740501
type: Comment
type: QuestionComment
has text: I am thinking of, searching through the entire array to find the string that contain e.g. apple, then pick them out and put them into a new arraylist. Next, I would sort the new array, and then put into into a third array first. next up, what's remaining in the very 1st array, shall be added into the 3rd array. do I make sense?
comment on: http://stackoverflow.com/q/21661390
score: 0

http://stackoverflow.com/comment/32626043
type: Comment
comment on: http://stackoverflow.com/a/21595157
has text: I don't think javazoom.jlgui.basicplayer.BasicPlayer could be run embedded in browser. Only option I see from their websites is to use JavaWS - running as a standalone player in each case.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/32601266
type: Comment
comment on: http://stackoverflow.com/a/21580487
has text: I would also be curious what your query code looks like. It's possible to leak with .fetch() if you're not careful even you manage your MongoClients correctly.
type: AnswerComment
score: 0

http://stackoverflow.com/q/21517361
tagged with: http://stackoverflow.com/tag/c
type: Question
has title: bitwise operation to extract each individual word from a long
answer count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/32488167
favorite count: 0
has comment: http://stackoverflow.com/comment/32488113
has answer: http://stackoverflow.com/a/21517538
tagged with: c++
has body: I have a long that corresponds to an assembly language instruction. Here's the problem; the first field is Opcode. It can be either 1 or 2 digits. So for example in 120602, 12 is the opcode. In 10602, 1 is the opcode. I want to extract each individual field; where opcode is the first 1-2 numbers on the left, 1 to the right of that is op1mode, 1 to the right of that is op1gpr, 1 to the right of that is op2mode, and finally, the last part is op2gpr. Ideally, I want to assign each to its own variable for later use, or separate them in an array. I was thinking that this can be achievable using bitwise operations; namely masks and shifts. How would one split the number with just bitwise operations?
type: UnansweredQuestion
tagged with: bit-manipulation
upvote count: 1
has answer: http://stackoverflow.com/a/21517542
score: 1
tagged with: java

http://stackoverflow.com/comment/32695797
comment on: http://stackoverflow.com/q/21635231
score: 0
type: Comment
type: QuestionComment
has text: yes its being called its sharing with gmail but failed to share via bluetooth whats the reason

http://stackoverflow.com/a/21526916
has body: How about using Charset.forName("UTF-8").encode(myString)
type: Answer
downvote count: 4
upvote count: 0
score: -4
has comment: http://stackoverflow.com/comment/32503514
answers question: http://stackoverflow.com/q/21526799

http://stackoverflow.com/comment/32573738
type: Comment
comment on: http://stackoverflow.com/q/21565882
has text: Your if statement also has a stray ; in it
score: 0
type: QuestionComment

http://stackoverflow.com/q/21598610
favorite count: 0
has answer: http://stackoverflow.com/a/21598671
upvote count: 3
has comment: http://stackoverflow.com/comment/32631772
tagged with: android
has comment: http://stackoverflow.com/comment/32631342
has comment: http://stackoverflow.com/comment/32631082
tagged with: android-activity
has title: what does super.onSaveInstanceState() do inside an overridden onSaveInstanceState()
downvote count: 0
accepted answer: http://stackoverflow.com/a/21610017
tagged with: java
type: Question
type: AnsweredQuestion
score: 3
has comment: http://stackoverflow.com/comment/32631126
has answer: http://stackoverflow.com/a/21610017
has comment: http://stackoverflow.com/comment/32631245
has comment: http://stackoverflow.com/comment/32654297
answer count: 2
has comment: http://stackoverflow.com/comment/32631365
has body: I am new to Android development. I was using overriden version of onSaveInstanceState() to save my own app data. I noticed that I did not call super.onSaveInstanceState(savedInstanceState) inside my function and the code worked fine. @Override public void onSaveInstanceState(Bundle savedInstanceState) { // TODO: // Save state information with a collection of key-value pairs // 4 lines of code, one for every count variable savedInstanceState.putInt(CREATE_KEY, mCreate); savedInstanceState.putInt(RESUME_KEY, mResume); savedInstanceState.putInt(RESTART_KEY, mRestart); savedInstanceState.putInt(START_KEY, mStart); } I was wondering if super.onSaveInstanceState(savedInstanceState) is called implicitly ? Also, what is the purpose of calling super.onSaveInstanceState(savedInstanceState) inside the overridden function.
possible better answer: http://stackoverflow.com/a/21598671

http://stackoverflow.com/comment/32539240
comment on: http://stackoverflow.com/a/21530716
score: 0
type: AnswerComment
type: Comment
has text: Okay that is an answer to one of my questions. Now the more difficult one. I don't have a token in requests. What am I missing?

http://stackoverflow.com/q/21611662
type: Question
has body: I am new to Android Development, and I can't for the life of me, figure out why this is giving me an error. The error is occurring on this line: 'bu.setOnClickListener(new OnClickListener() {' I am following the Android Development Fundamental tutorials on Lynda.com; and my code is identical to that of the teachers; or so I think. package com.lynda.lyndaproject; import android.os.Bundle; import android.app.Activity; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.view.Menu; import android.view.View; import android.widget.Button; public class Main extends Activity { Button bu = (Button) findViewById(R.id.button1); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); bu.setOnClickListener(new OnClickListener() { public void onClick(View v){ } }); } } By the way, Eclipse doesn't seem to be allowing me to import anything; and I do believe importing 'android.view.View' should have imported everything necessary.
has title: setOnClickListener Error: No Idea Why?
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/21611685
accepted answer: http://stackoverflow.com/a/21611685
tagged with: android
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32653356
tagged with: java
tagged with: eclipse

http://stackoverflow.com/comment/32500779
type: Comment
has text: i know it, I dont have access table1.deleteRow(row);
comment on: http://stackoverflow.com/a/21525188
score: 0
type: AnswerComment

http://stackoverflow.com/a/21536327
score: 2
downvote count: 0
type: Answer
has body: You will not be able to access anything that is protected or private in another package. They must be public.
upvote count: 2
answers question: http://stackoverflow.com/q/21536223
has comment: http://stackoverflow.com/comment/32521053

http://stackoverflow.com/comment/32644761
comment on: http://stackoverflow.com/q/21547373
type: Comment
type: QuestionComment
has text: Have you done any profiling with regards to what objects are taking up the memory? Most good profiling tools will help point out memory leaks (which looks like what you may have).
score: 0

http://stackoverflow.com/comment/32707829
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21642374
has text: @Dolda2000 Yep, you're remembering it wrong. `x*x` holding true would make it *reflexive*.

http://stackoverflow.com/comment/32728069
has text: Actually, C and C++ do provide the operators your're talking about (that's where most of the other languages got them from). It's not really useful or correct to think of them as eager boolean logic operators though.
score: 1
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21654109

oop
tags question: http://stackoverflow.com/q/21598414
tags question: http://stackoverflow.com/q/21564278
tags question: http://stackoverflow.com/q/21538858
tags question: http://stackoverflow.com/q/21540603
tags question: http://stackoverflow.com/q/21601227
tags question: http://stackoverflow.com/q/21598293
tag name: oop
tags question: http://stackoverflow.com/q/21524029
tags question: http://stackoverflow.com/q/21581061
tags question: http://stackoverflow.com/q/21557225
tags question: http://stackoverflow.com/q/21660694
tags question: http://stackoverflow.com/q/21664677
tags question: http://stackoverflow.com/q/21537982
tags question: http://stackoverflow.com/q/21618288
tags question: http://stackoverflow.com/q/21623499
tags question: http://stackoverflow.com/q/21585829
tags question: http://stackoverflow.com/q/21603172
tags question: http://stackoverflow.com/q/21623706
tags question: http://stackoverflow.com/q/21639966
tags question: http://stackoverflow.com/q/21640920
tags question: http://stackoverflow.com/q/21536240
tags question: http://stackoverflow.com/q/21562664
tags question: http://stackoverflow.com/q/21594812
tags question: http://stackoverflow.com/q/21590153
tags question: http://stackoverflow.com/q/21613231
tags question: http://stackoverflow.com/q/21637169
type: Tag
tags question: http://stackoverflow.com/q/21668268
tags question: http://stackoverflow.com/q/21673899

http://stackoverflow.com/a/21642920
answers question: http://stackoverflow.com/q/21642489
score: 0
type: Answer
has body: Actually, you wanted to only charge the 1% fee over the check amount less the $40 dollar fixed fee according to your original expression, so the expression should be: fee = 40 + (checkAmount - 40) * .01; There's a lot of duplication in your code, which makes it harder to see what's going on, and if you decide to change - for example - the message that you want to show to the user, you now need to change it in 4 locations, and there's a big change that you forget to do it somewhere, or that you make a typo. One of the goals of good programming is to avoid duplication as much as possible. public class ServiceCharge { public static void main(String[] args) { Scanner kb = new Scanner(System.in); System.out.println("I will calulate the service charge to cash your check"); System.out.print("Enter amount of check: $"); double checkAmount = kb.nextDouble(); if (checkAmount &gt; 0) { double fee; String feeMessage; if (checkAmount &lt;= 10) { fee = 1; feeMessage = "$1 service charge"; } else if ((checkAmount &gt; 10) &amp;&amp; (checkAmount &lt;= 100)) { feeMessage = "10 percent charge."; fee = (checkAmount * .10); } else if ((checkAmount &gt; 100) &amp;&amp; (checkAmount &lt;= 1000)) { feeMessage = "$5 charge plus 5 percent"; fee = 5 + ((checkAmount - 5) * .05); } else { feeMessage = "$40 processing fee plus 1 percent"; fee = 40 + ((checkAmount - 40) * .01); } checkAmount = checkAmount - fee; System.out.printf("Fee structure: " + feeMessage); System.out.printf("Processing fee: $%.2f\n", fee); System.out.printf("Check amount: $%.2f\n", checkAmount); System.out.println("Thanks for using Service Charger.\nGood bye"); } } } The next step you may want to look into is to decompose your program functionally into functions. For example, the part where you ask for the amount, the part where you do the calculation, and the part where you show the result, are three very distinct parts. Each of those three you may want to change separately - you may want to get the input from a file or …

http://stackoverflow.com/q/21545224
downvote count: 2
accepted answer: http://stackoverflow.com/a/21545290
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/32535866
has answer: http://stackoverflow.com/a/21545290
has comment: http://stackoverflow.com/comment/32535865
has body: here is the code.. Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_YEAR, -365 * 4); Date date = c.getTime(); Can anyone tell me, what exactly we are setting in "c" ? what the use of -365 * 4
type: AnsweredQuestion
upvote count: 0
tagged with: java
tagged with: calendar
type: Question
has title: what would be the value set in the calender instance c.add(Calendar.DAY_OF_YEAR, -365 * 4)?
score: -2
has comment: http://stackoverflow.com/comment/32536574

http://stackoverflow.com/q/21556079
answer count: 2
has title: Play Framework 2 Ebean specify default value for field
downvote count: 0
possible better answer: http://stackoverflow.com/a/37421289
favorite count: 0
tagged with: playframework-2.2
has body: I have a simple model in Play Framework 2, and I would like to specify a default value to be inserted on a specify INT column if none is provided when the INSERT is performed. Model: @Entity @Table(name = "DashboardOptions", schema = "dbo") public class DashboardOptions extends Model implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional = false) @Column(name = "id") public Long id; @Basic(optional = false) @Column(name = "userId") public Long userId; @Column(name = "chartType") public String chartType; public String name; public Integer size = 2; I'd like to have the size column populate with 2 by default, however, if I specify the default value as above, my database evolution does not reflect this: create table dbo.DashboardOptions ( id numeric(19) identity(1,1) not null, userId numeric(19) not null, chartType varchar(255), name varchar(255), size integer, constraint pk_DashboardOptions primary key (id)) ; What I would expect to see is this: create table dbo.DashboardOptions ( id numeric(19) identity(1,1) not null, userId numeric(19) not null, chartType varchar(255), name varchar(255), size integer default 2, constraint pk_DashboardOptions primary key (id)) ;
tagged with: ebean
has answer: http://stackoverflow.com/a/21557469
type: AnsweredQuestion
score: 7
tagged with: java
upvote count: 7
type: Question
accepted answer: http://stackoverflow.com/a/21557469
tagged with: playframework-evolutions
has answer: http://stackoverflow.com/a/37421289

http://stackoverflow.com/q/21515382
tagged with: cucumber-junit
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/31694456
has title: How to run cucumber-jvm tests with maven
type: Question
has answer: http://stackoverflow.com/a/40555291
upvote count: 11
has body: How do I run the cucumber tests that I have in the following locations with Maven. Source folders 'src/main/java' and 'src/main/resources' include step definitions and feature files in package 'com.testing.TestProject.login' created in each source folder. I have included plugins and dependencies in the POM file but when I run maven phase integration-test, cucumber tests are not getting executed. I'm new to Maven. Please let me know what to include in the POM file to run the cucumber tests with Maven. Here is my POM file: 4.0.0 com.testing MyMavenProject 1.0-SNAPSHOT jar MyMavenProject http://maven.apache.org <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <cucumber-jvm.version>1.1.5</cucumber-jvm.version> <selenium.version>2.39.0</selenium.version> <junit.version>4.11</junit.version> org.codehaus.mojo exec-maven-plugin 1.2.1 integration-test java info.cukes cucumber-core cucumber.api.cli.Main --format junit:target/cucumber-junit-report/allcukes.xml --format pretty --format html:target/cucumber-html-report --tags @login --glue com/ src/ info.cukes cucumber-core 1.1.5 junit junit ${junit.version} test org.seleniumhq.selenium selenium-java ${selenium.version} info.cukes cucumber-picocontainer ${cucumber-jvm.version} test info.cukes cucumber-junit ${cucumber-jvm.version} test org.testng testng 6.8.7 log4j log4j 1.2.16 commons-logging commons-logging 1.1.3 Thanks in advance.
tagged with: cucumber-jvm
answer count: 3
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21540561
tagged with: maven
score: 11
tagged with: selenium-webdriver

http://stackoverflow.com/a/21619998
type: Answer
has body: Well the code is picking integers randomly but it's printing them at the same time without checking for any duplicates. In addition, it's not specifying that it has to be between 1-3 So here is how it can be done. Of course you'll need to import java.util.Random first. Random rand = new Random(); int value = rand.nextInt(3) +1; // this will choose a number between 1-3 not 0-2 int secondvalue = rand.nextInt(3) +1; // same thing but we need 2 of them since we want 2 random numbers and not only 1 ! while(value == secondvalue) { //to see if the first random number = the second secondvalue = rand.nextInt(3) +1; // if so, regenerate the second randomly } // and finally print them System.out.println(" Value is " + value); System.out.println(" Value is " + second value); There are tons of ways to do this thing but I believe this is the easiest way to deal with it.
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/32669058
answers question: http://stackoverflow.com/q/21619997
score: 0

http://stackoverflow.com/comment/32764803
type: QuestionComment
comment on: http://stackoverflow.com/q/21675396
score: 0
has text: Apart of the technical details (which method is called), you should be aware of the idea behind object trees. A good example is `Collection` and its sub-types. If you refer to an object as a `Collection` you just see the methods of that interface, i.e. you can `add` and `get` items etc., but you don't care about other details (e.g. wheter it's an `ArrayList`, a `HashSet` or whatever). *TL;DR*: It simplifies programming.
type: Comment

http://stackoverflow.com/q/21540761
answer count: 1
tagged with: event-handling
tagged with: variables
tagged with: listener
has body: I am trying to make a simple calculator so that when the + button is pressed it adds two variables together but whenever the listener for the button is called, it resets the variable that I previously wanted stored. How can I get around this? public void actionPerformed(ActionEvent e) { int accumulator1 = 1; int userinput; if(e.getSource()==input) { userinput = Integer.parseInt(input.getText()); System.out.println(userinput); } if(e.getSource()==add) { accumulator1 = userinput + accumulator1; System.out.println(accumulator1); System.out.println(userinput); accumulator.setText(String.valueOf(accumulator1)); } }
type: UnansweredQuestion
tagged with: input
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32529038
has title: How to stop continually overwriting a variable when a button is clicked?
score: 0
has answer: http://stackoverflow.com/a/21540818

http://stackoverflow.com/q/21593876
type: UnansweredQuestion
has body: I have a web service as below. Any body please tell me what is the Url to invoke the getUserDetails(); ....://localhost:8080/Jersey-Rest/rest/hellow / I want the url after hellow/.... @Path("/hellow") public class HelloWorldService { @GET @Path("/{name1}/{name2}/") public Response getUserDetails(@PathParam("name1") String name1,@PathParam("name2") String name2){ String output = "User info .. "+name1+name2 ; return Response.status(200).entity(output).build(); } thank you
tagged with: java
tagged with: web-services
type: Question
score: 0
has title: Url to invoke the java web service
answer count: 1
tagged with: web
has answer: http://stackoverflow.com/a/21594284

http://stackoverflow.com/a/21697317
has comment: http://stackoverflow.com/comment/70586268
type: AcceptedAnswer
downvote count: 0
has body: --1. when programming in Java using Sikuli, you should always use sikuli-java.jar (sikuli-ide.jar contains much stuff not needed here). --2. Set a JVM option -Dsikuli.Debug=3 when running the exe to get more details about what's going on. I guess the problem is, that for some reason the export of the native libs does not work in the context of a launch4J exe (I did not test this yet). --3. always use the latest version (1.1.1 in this case, still nightly but pre-final ;-) http://sikulix.com
answers question: http://stackoverflow.com/q/21621000
has comment: http://stackoverflow.com/comment/32809448
accepted answer of: http://stackoverflow.com/q/21621000
type: Answer
score: 2
upvote count: 2

http://stackoverflow.com/comment/32552659
score: 0
type: Comment
type: QuestionComment
has text: Still doesn't work ...
comment on: http://stackoverflow.com/q/21528455

http://stackoverflow.com/comment/32698313
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/21636542
type: Comment
has text: Just a moment. Ok, in my case, in last iteration `catalog.sellProduct` return `false`, `flag` becomes `false`, `count` not incremented. In author's code, if exception in last iteration accured not `count++` accures, and `flag` still `false`. Really no difference I see.

http://stackoverflow.com/q/21633824
favorite count: 0
has comment: http://stackoverflow.com/comment/32698271
has comment: http://stackoverflow.com/comment/32696732
has answer: http://stackoverflow.com/a/21637005
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21637005
has answer: http://stackoverflow.com/a/47875118
has answer: http://stackoverflow.com/a/21633910
tagged with: log4j2
type: Question
has title: Programmatically find the log4j2 (beta9) log filename
has body: I am using Java 1.7 and Log4j2 (beta9) and I have the following log4j2.xml file: <?xml version="1.0" encoding="UTF-8"?> <PatternLayout pattern="[%d{dd/MMM/yyyy HH:mm:ss.SSS}]> %-5p - %m%n"/> <OnStartupTriggeringPolicy/> <DefaultRolloverStrategy fileIndex="max" max="10"/> <PatternLayout pattern="[%d{dd/MMM/yyyy HH:mm:ss.SSS}]> %-5p - %m%n"/> <AppenderRef ref="RollingFile"/> <AppenderRef ref="CONSOLE"/> <AppenderRef ref="ASYNC"/> And as far as the logging itself goes, it does what I need. As part of the error/exception sequence, I need to send an email with the log file as an attachment. How do I programmatically get the 'fileName="logs/foo.log"' bit? I would really hate to have to hard code this.
tagged with: java
score: 10
upvote count: 10
has comment: http://stackoverflow.com/comment/32692439
answer count: 3
accepted answer: http://stackoverflow.com/a/21633910
downvote count: 0

http://stackoverflow.com/comment/32546155
type: Comment
score: 0
has text: Ok thanks for your answer. I will take a look at your links first.
comment on: http://stackoverflow.com/a/21515727
type: AnswerComment

http://stackoverflow.com/q/21633879
upvote count: 1
has answer: http://stackoverflow.com/a/21636518
tagged with: java
type: UnansweredQuestion
has title: Close on socket's input stream takes too long
answer count: 1
downvote count: 0
score: 1
favorite count: 0
type: Question
tagged with: sockets
has comment: http://stackoverflow.com/comment/32692452
has body: We are having a problem every now and then with one of our clients, whose connections get disconnected after a specific time. The exception on the client side shows a "Read Timed out" message. Since we do not use socket timeouts in our Java application (we use the default values of 0), our first thought is that the client's timeouts must be coming from a proxy or router on the their side. Their IT department is looking into this problem. However, when the connection is aborted, our client application closes the socket and then establishes a new connection to our server. Upon the reception of a new connection from the same client, the server will initiate a cleanup operation on the old connection before it starts using the new one. That cleanup happens either when the server detects an EOS or any other read exception or when a new connection is accepted by the same client and the old one has not been cleaned-up for whatever reason (this is what happens here due to our server failing to detect an EOS). That cleanup operation includes actually some logging, clearing of various routing data structures and the final closing of the input and output streams. At that point we have observed, that the close of the input stream of the old socket blocks for 15 minutes and the time is always the same. As you can understand, then everything goes wrong because the new connection starts starving and the same problem starts from the beginning repeatedly. Now, I suppose that our socket on the server side is suffering from an indefinite FIN_WAIT_2 or TIME_WAIT state, in which the socket remains in one of those states without receiving the necessary ACKs (perhaps they are dropped), which could move it to CLOSED state. Although our server was not the one to break the connection in the first place, I suppose it is the proxy or router at the customer's side, which may have initiated and made it look like our server's close. I have read that setting the SO_LINGER option on the server side …
tagged with: tcp

http://stackoverflow.com/comment/40715325
comment on: http://stackoverflow.com/q/21616339
score: 0
has text: I have managed to get it working by using the Maven Shade plugin instead of jar-with-dependencies, which actually merges all the duplicate META-INF/* files into one large file instead of overwriting them. This seems to solve the issue.
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21524657
has body: what you want get in result ? is the result have to be f n 0 or f n 0: ? its have 2 different way one is seperate 1 letter after | the result is f n 0 and the next one is seperate just one | the result is f n 0: if you want any thing more ask
score: 0
has comment: http://stackoverflow.com/comment/32548188
type: Answer
answers question: http://stackoverflow.com/q/21524494

http://stackoverflow.com/comment/32491861
type: QuestionComment
comment on: http://stackoverflow.com/q/21519979
type: Comment
has text: when I do a Junit Test on eclipse I get "array lengths differed, expected.length = 4 actual.length = 7"
score: 0

http://stackoverflow.com/comment/32626708
type: AnswerComment
comment on: http://stackoverflow.com/a/21593583
type: Comment
has text: Oh that is not what I wanted to hear! I really can't afford $99 a year right now, so are there any alternative solutions for me to limit the impact of not having signed code? Also is this on all versions of osx?
score: 0

http://stackoverflow.com/comment/32501503
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21524775
has text: The dependency tree maven plugin requires it's own dependencies to execute. Don't worry, these will not be included in your project's artifact.

http://stackoverflow.com/q/21676868
has comment: http://stackoverflow.com/comment/32767440
has comment: http://stackoverflow.com/comment/32770091
tagged with: classcastexception
linked to: http://stackoverflow.com/q/1194656
has comment: http://stackoverflow.com/comment/32772571
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32770220
has comment: http://stackoverflow.com/comment/32773880
type: Question
has comment: http://stackoverflow.com/comment/32772356
linked to: http://stackoverflow.com/q/12279245
has body: I am trying to save/load instances of my TicketSet class in Java. Below is the class and the class variables. The Ticket and Variable class are also Serializable. public class TicketSet implements Serializable{ public final int setID; public int ticketNum; public Ticket[] tickets; private static int xCount[]; private static int yCount[]; private static int zCount[]; private Variable x; private Variable y; private Variable z; In another class I save an instance of the TicketSet class which seems to work fine. In the code, gen is just an instance of a controller class which initialises TicketSet. TicketSet set; if (f.exists()) { FileOutputStream fileOut =new FileOutputStream(f,true); AppendingObjectOutputStream out = new AppendingObjectOutputStream(fileOut); set = gen.getTSet(); out.writeObject(set); out.close(); fileOut.close(); } else { FileOutputStream fileOut =new FileOutputStream(f,true); ObjectOutputStream out = new ObjectOutputStream(fileOut); set = gen.getTSet(); out.writeObject(set); out.close(); fileOut.close(); } To load the instances of TicketSet, I have the following code which throws the error. ArrayList&lt;Integer&gt; tickid = new ArrayList&lt;Integer&gt;(); tSets = new HashMap&lt;Integer, TicketSet&gt;(); FileInputStream fileStr = null; ObjectInputStream reader = null; try { fileStr = new FileInputStream("TicketSets.ser"); reader = new ObjectInputStream(fileStr); System.out.println(fileStr.available()); TicketSet tSet= null; while (fileStr.available()&gt;0) { Object next = reader.readObject(); //ERROR HERE if (next instanceof TicketSet) { tSet = (TicketSet) next; System.out.println("ID: "+tSet.setID); tSets.put(tSet.setID, tSet); tickid.add(tSet.setID); } else { System.out.println("Unexpected object type: " + next.getClass().getName()); } } //System.out.println("Size: "+tSets.size()); reader.close(); fileStr.close(); } catch(IOException i) { i.printStackTrace(); } catch (ClassNotFoundException c) { System.out.println("TicketSet class not found"); c.pri…
has comment: http://stackoverflow.com/comment/32775279
tagged with: java
tagged with: fileoutputstream
has answer: http://stackoverflow.com/a/21707353
score: 0
has comment: http://stackoverflow.com/comment/32772636
tagged with: fileinputstream
answer count: 1
has title: Java ClassCastException while using FileInputStream
has comment: http://stackoverflow.com/comment/32767703

http://stackoverflow.com/a/21560487
has body: You can't do that with SFML because SFML don't provide such facilities.
score: 0
has comment: http://stackoverflow.com/comment/32584381
answers question: http://stackoverflow.com/q/21528903
type: Answer
has comment: http://stackoverflow.com/comment/32580373

http://stackoverflow.com/q/21652326
type: Question
has answer: http://stackoverflow.com/a/21652597
tagged with: list
answer count: 3
upvote count: 1
has answer: http://stackoverflow.com/a/21661407
tagged with: format
has title: Write ArrayList as a list in a text file
tagged with: java
type: UnansweredQuestion
downvote count: 0
score: 1
has answer: http://stackoverflow.com/a/21653225
has body: I'm using a getter method to return an ArrayList to my main method. I then save these lists into text files. The problem I have is in the way the output is displayed Is there a way to save my array Lists in this way eg: 12 45 56 34 65 rather than [12, 45, 56, 34, 65] I'm using a PrintStream and I'm outputting to a text file. Regards edit for(Subject sub : st.getSub()){ save.println(s.getSubject()); save.println(s.getHomeworkMark()); save.println(s.getExamMark()); } I have something liike that, but since im using a getter method, it doesnt let me loop through each record.... thos are retrieving from arrayLists, but when I output, it outputs as a whole rather than individuals
favorite count: 0
tagged with: arraylist

http://stackoverflow.com/comment/32599947
score: 0
comment on: http://stackoverflow.com/a/21580301
has text: That's not an error, that just means his code is quick. The other mistakes were coding errors. I did say it depends how he wanted the information. If he wants it to go to nano second precision he can change it. I provided a solution to his problem, that would most likely do what he needs it to do.
type: AnswerComment
type: Comment

http://stackoverflow.com/a/21622580
score: 0
has comment: http://stackoverflow.com/comment/32673264
has comment: http://stackoverflow.com/comment/32672569
has body: The Java Heap size does not reflect "How much memory am I using", it reflects "How much memory does the JVM have in total to use". You Mention in your question that "each pic is less than 200kb". That's irrelevant. You are loading it into an ImageBuffer, and the buffer doesn't care that your compressed JPEG file is less than 200kb. It is going to need at least 4 bytes pr. pixel in the image. This means that even a small 80x80 gravatar style image is 25Kb of memory. This is for each image you have. Since you are re-sizing this you need twice as much (one buffer for the source, one for the destination). Since you are handling multiple requests you need to further multiply by the amount of concurrent requests. So you end up having to use quite a few resources. I think a better design would be to scale the images up-front, and store both versions, then serve either version as a stream (that is, don't load them into memory).
answers question: http://stackoverflow.com/q/21551072
type: Answer

http://stackoverflow.com/comment/36655156
comment on: http://stackoverflow.com/q/21561861
has text: You've tried to do that? String newString = new String(oldString.getBytes("UTF-8"), "UTF-8"));
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32740903
has text: Have you considered putting all these names in an array or a collection of some sort?
comment on: http://stackoverflow.com/q/21661678
type: Comment
type: QuestionComment
score: 2

http://stackoverflow.com/q/21548548
has answer: http://stackoverflow.com/a/24416305
downvote count: 0
tagged with: pom.xml
score: 16
favorite count: 0
answer count: 5
tagged with: maven
upvote count: 16
has answer: http://stackoverflow.com/a/21549970
has answer: http://stackoverflow.com/a/31384663
type: AnsweredQuestion
has title: Adding AspectJ to pom.xml changed Java version with Maven, why?
tagged with: java
type: Question
has body: UPDATE: here is my maven-compiler-plugin configuration: org.apache.maven.plugins maven-compiler-plugin 2.3.2 1.6 1.6 I work on a multi-project application that I build with Maven. We decided to add AspectJ so I added the following code to pom.xml in the top level project: (from the official documentation) ... ... org.aspectj aspectjrt 1.7.3 ... ... org.codehaus.mojo aspectj-maven-plugin 1.5 compile test-compile ... ... and the following fragments to each subordinate projects: ... .... ... org.codehaus.mojo aspectj-maven-plugin ... org.aspectj aspectjrt .... ... Somehow this modification has overridden the Java version I use. If I run build I get multiple errors like this: Syntax error, annotations are only available if source level is 1.5 or greater That gives me the suspicion that my Java version (originally 1.6) was somehow reverted to 1.4. I did nothing - at least not knowingly - that could influence the Java version, so I suspect that the above mentioned AspectJ related code is responsible for the change. My question is how can AspectJ change the Java version and what should I do to fix this problem. Or do I misunderstand something completely and am I on the wrong track?
accepted answer: http://stackoverflow.com/a/21549970
has answer: http://stackoverflow.com/a/21549840
has answer: http://stackoverflow.com/a/25322804
tagged with: aspectj
possible better answer: http://stackoverflow.com/a/24416305

http://stackoverflow.com/comment/32564458
comment on: http://stackoverflow.com/q/21559984
score: 0
has text: nota : you have already asked this question yesterday and there was an answer already...
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32632344
has text: Can you post your complete xml layout and source for your activity?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21597600

http://stackoverflow.com/comment/32716682
has text: Generally speaking, you don't need to know. Can you say why you want to override what the scheduler does because there is only very specific cases where it helps.
comment on: http://stackoverflow.com/q/21647707
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/50834135
answers question: http://stackoverflow.com/q/21613308
type: Answer
has body: this is a short version of Sean Barbeau's answer &lt;stroke android:width="1dp" android:color="@color/white" /&gt; &lt;solid android:color="@color/dark_blue" /&gt; &lt;size android:width="14dp" android:height="14dp" /&gt;
score: 0

http://stackoverflow.com/a/21658792
upvote count: 1
type: AcceptedAnswer
type: Answer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21658541
score: 1
answers question: http://stackoverflow.com/q/21658541
has body: Try this: int step = 1; for (int i = 255; i &gt;= 0; i-=step) { String hex = Integer.toString(i, 16).toUpperCase(); hex = hex + hex + hex; //output hex String } See Integer.toString(int, int) for decimal to hexadecimal conversion Note that you have to go from R = G = B = 255 to R = G = B = 0 to get the gradient as shown in the image.

http://stackoverflow.com/q/21530290
downvote count: 0
has comment: http://stackoverflow.com/comment/32510725
has title: Class in JAR file not Autowired
favorite count: 0
type: UnansweredQuestion
tagged with: spring
has body: Problem Statement The class from a JAR file is not getting autowired. Spring version used is 3.0 Classes Involved : InventoryController > ProductService > ProductManager > ProductDao Stacktrace org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.site.dao.ProductDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:949) org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:818) org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:730) Modules site-admin is a webapp site-services (jar file) site-dao (jar file) InventoryController is a class in the admin webapp which depends on ProductService from site-service-1.0.jar (ProductService and ProductManager is in site-service-1.0.jar). ProductService depends on ProductManager which in turn depends on ProductDao which is in site-dao-1.0.jar (ProductDao is in site-dao-1.0.jar. At runtime the ProductDao is not getting autowired). The SimpleProductManager references ProductDao, but at runtime its not getting loaded. The stacktrace is defined above Need help/suggestions on what could be the issue Classes involved in this dependencies InventoryController > ProductService > ProductManager > ProductDao InventoryController package com.site.admin.controllers; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.propertyeditors.CustomDateEditor; import org.springframework.stereotype.Controller; import org.springframework.ui.Mode…
tagged with: spring-mvc
has answer: http://stackoverflow.com/a/21577899
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/21532252
tagged with: autowired
type: Question
has comment: http://stackoverflow.com/comment/32594223
answer count: 3
score: 3
has answer: http://stackoverflow.com/a/21534666

http://stackoverflow.com/q/21660678
has answer: http://stackoverflow.com/a/21660757
answer count: 1
has body: I have a POJO named Employee.Java who has an instance variable, lets call it birthdate. I have it's type mentioned as java.util.Date and it's corresponding column type in Oracle table is DATE. Employee.Java Class Employee{ private java.util.Date birthDate; } Table create table Employee(birthDate DATE); I have another class which takes an instance of Employee class and saves it to database. Since the type of birthdate column is DATE, it will be stored in the default format DD-MON-YY in table. I need to store the birthDate value in database in the format YYYY-MM-DD with java.util.Date typed instance variable. How can I achieve this task. Kindly assist me.
type: UnansweredQuestion
tagged with: oracle-database
tagged with: java
type: Question
tagged with: date
has title: Store Date in Oracle database
score: 0

http://stackoverflow.com/q/21541684
tagged with: connection
type: UnansweredQuestion
tagged with: network-programming
has title: Accessing MyAnimeList.net with Java
tagged with: java
has answer: http://stackoverflow.com/a/25882998
type: Question
answer count: 2
tagged with: url
score: 0
has answer: http://stackoverflow.com/a/30467273
linked to: http://stackoverflow.com/q/496651
has body: I am trying to access http://myanimelist.net with the following Java code I found on this git https://github.com/Autumn/javaMAL : String result = ""; try { URL url = new URL(sURL); URLConnection urlc = url.openConnection(); BufferedReader buffer = new BufferedReader(new InputStreamReader(urlc.getInputStream())); StringBuilder sb = new StringBuilder(); String str; while ((str = buffer.readLine()) != null) { sb.append(str); } result = sb.toString(); } catch (Exception e) { e.printStackTrace(); } return result; This is what I get back from the site Request unsuccessful. Incapsula incident ID: 163000490097146940-336953331276776217 but that is not the correct source for the website. Instead I should be getting something like this: MyAnimeList.net Anime Manga Characters People Fansub Groups Clubs Users Anime Reviews Recommendations Top Anime Fansub Groups Manga Reviews Recommendations Top Manga Community Forums Clubs Blogs Users Staff Help Industry People Characters News Top Favorites Join Login (I copied from Google Chrome using the view page source feature) For some reason it seems that I am being identified as a bot, but no one else using the git https://github.com/Autumn/javaMAL seemed to have that problem. Can someone explain what went wrong and how I can fix it? EDIT: I tried opening it with the demo JavaFX Browser and it works fine, but I tried using a JEditorPane in my program and it doesn't work... (gets the same code as I got with my code)...

http://stackoverflow.com/q/21610926
tagged with: xml-parsing
has answer: http://stackoverflow.com/a/21706798
answer count: 1
score: 0
has title: Can SimpleFramework deserialize skipping arbitrary depths along the way?
has body: I'm deserializing some XML that and I'd like to be able to easily deal with slightly different versions of the format. I'm a consumer of this XML, I cannot control the format to make my job easier. One version of the XML contains elements like this: apple orange I've got an annotated class like this to parse it: @Root(strict=false) public static class Food { @Attribute public String name; @ElementList(entry="member", inline=true) public List<String> members; } So far so good. Today, I discovered that the producer of this XML may also give me this to represent the same information: fruits apple orange That element is now in between entry and member. If possible, I would like a single annotated Food class that could handle both formats. These feels like something SimpleFramework could handle easily, but a search through the docs didn't help me. I'm hoping someone here knows the answer. If I have to I know I can detect this newer schema in another way and then switch to an entirely different set of annotated classes, but the differences are small enough, I'm trying to avoid that.
tagged with: simple-framework
type: UnansweredQuestion
tagged with: java
type: Question

http://stackoverflow.com/comment/32669611
comment on: http://stackoverflow.com/a/21620583
score: 0
type: AnswerComment
type: Comment
has text: So your variables have different types? Use Object[] instead. To show a variable stored in the array, just do it like System.out.println(variables[count - 1]); count - 1 is a number, the index and will help you to get the right variable from the array. If you have custom classes, created by you, you will probably want to override toString method.

grouplayout
type: Tag
tags question: http://stackoverflow.com/q/21676631
tag name: grouplayout
tags question: http://stackoverflow.com/q/21627970

http://stackoverflow.com/comment/32634017
type: QuestionComment
comment on: http://stackoverflow.com/q/21600344
has text: @agad the hashcode is used to separate the keys into small subsets, then `equals` is tested on each object in the set which has the good hashcode. If none of these objects verify `equals()` then your key will not be found.
score: 1
type: Comment

http://stackoverflow.com/q/21602696
has title: How to make outbound calls in AsteriskNow using Asterisk AMI with Java
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21694043
downvote count: 0
accepted answer: http://stackoverflow.com/a/21631335
favorite count: 0
tagged with: asteriskami
type: Question
possible better answer: http://stackoverflow.com/a/21694043
score: 1
tagged with: asterisk
answer count: 2
upvote count: 1
has answer: http://stackoverflow.com/a/21631335
has body: I would like to initiate a call from extension number to another in LAN network. I have done this task through FreePBX GUI. Now I am trying to execute this task by using Asterisk AMI with Java code. Below Java code shows some exception while in debugging. import java.io.IOException; import org.asteriskjava.manager.AuthenticationFailedException; import org.asteriskjava.manager.ManagerConnection; import org.asteriskjava.manager.ManagerConnectionFactory; import org.asteriskjava.manager.TimeoutException; import org.asteriskjava.manager.action.OriginateAction; import org.asteriskjava.manager.response.ManagerResponse; public class HelloManager { private ManagerConnection managerConnection; public HelloManager() throws IOException { ManagerConnectionFactory factory = new ManagerConnectionFactory( "192.168.68.173", "admin", "admin"); this.managerConnection = factory.createManagerConnection(); } public void run() throws IOException, AuthenticationFailedException, TimeoutException { OriginateAction originateAction; ManagerResponse originateResponse; originateAction = new OriginateAction(); originateAction.setChannel("SIP/1010"); originateAction.setContext("default"); originateAction.setExten("2020"); originateAction.setPriority(new Integer(1)); originateAction.setTimeout(new Integer(30000)); // connect to Asterisk and log in managerConnection.login(); // send the originate action and wait for a maximum of 30 seconds for Asterisk // to send a reply originateResponse = managerConnection.sendAction(originateAction, 30000); // print out whether the originate succeeded or not System.out.println("Enter Response="+originateResponse.getResponse()); // and finally log off and disconnect managerConnection.logoff(); } public static void main(String[] args) throws Exception { HelloManager helloManager; helloManager = new HelloManager(); helloManager.run(); } } Exception: run: Feb 06, 2014 4:04:16 PM org.asteriskjava.manager.internal.ManagerConnectionImpl connect INFO: Connecting to 192.1…
tagged with: java

http://stackoverflow.com/comment/32710990
comment on: http://stackoverflow.com/q/21644132
score: 0
type: Comment
type: QuestionComment
has text: So if you are talking about performance of the insert statement: If you do an insert without starting a transaction, SQLite is doing this implicite. So a single insert has the same performance, no matter if you start a transaction or not. If you have multiple inserts, it will be much faster within a transaction.

http://stackoverflow.com/comment/32618291
comment on: http://stackoverflow.com/a/21590120
type: AnswerComment
has text: Thank you for your suggestion about aggregator, which is a good solution to this problem. And you also correctly predicted "old files exist so the aggregator operates on those files" :)
type: Comment
score: 2

http://stackoverflow.com/a/21591994
upvote count: 5
score: 5
downvote count: 0
has comment: http://stackoverflow.com/comment/32622287
has body: To call a certain method from another class, you must first create a new object for that class, like this: Jframe frame = new Jframe(); frame.setVisible(true); //or whatever the method is in jframe.class Maybe rename the actual class name from jframe to something like frameone. I've heard that naming classes the same as classes in the Java API will cause trouble. Or, you could put it all in one class, with either two separate methods or put it all in the main method. If this doesn't help, then please paste the exact code on pastebin.org and give a link.
answers question: http://stackoverflow.com/q/21591807
type: Answer

http://stackoverflow.com/q/21592492
has body: I'm still very new to java programming, so please help me to correct any mistakes I might have overlooked or give tips on how to improve this program. Okay, so a lot of problems have been solved, and now I have a CardLayout, but I still have questions about how I should make my pipes show inside it. When I tried to add in my refresh rate timer and my speed timer, I have problems about how I need to declare and initialize boolean variables. Also, when I compile and run this game, I get files such as Game$1.class. Is there a way for me to clean this up, and could someone explain why this happens? Do these have an affect on the finished product? (When the game is compiled and packaged into a JAR.) I want to set playerIsReady to true when the play button is clicked. And from there, when the if statement is true, then switch to a panel that displays the pipes, and start moving the pipe across the screen. Preferably 3 instances of that pipe, each starting at different times, but whatever you can help with is fine. Some of this code needs work, so I have commented some parts out and left notes. My other questions about this game can be found here. This is my current code Game.java import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.Timer; import javax.swing.border.EmptyBorder; import javax.swing.SwingUtilities; public class Game { public static void main(String[] args) { Runnable r = new Runnable() { @Override public void run() { // the GUI as seen by the user (without frame) final CardLayout cl = new CardLayout(); final JPanel gui = new JPanel(cl); // remove if no border is needed gui.setBorder(new EmptyBorder(10,10,10,10)); JPanel menu = new JPanel(new GridBagLayout()); JButton playGame = new JButton("Play!"); ActionListener playGameListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cl.show(gui, "game…
type: Question
upvote count: 4
has title: How can I switch between jpanels?
linked to: http://stackoverflow.com/q/21587972
has answer: http://stackoverflow.com/a/21593127
downvote count: 0
score: 4
tagged with: awt
favorite count: 0
possible better answer: http://stackoverflow.com/a/21593127
answer count: 3
has comment: http://stackoverflow.com/comment/32621239
has answer: http://stackoverflow.com/a/21593171
has comment: http://stackoverflow.com/comment/32620804
tagged with: jframe
has comment: http://stackoverflow.com/comment/32622363
has comment: http://stackoverflow.com/comment/32665615
tagged with: swing
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21592836
linked to: http://stackoverflow.com/q/7296438
tagged with: java
linked to: http://stackoverflow.com/q/7143287
tagged with: jpanel
linked to: http://stackoverflow.com/q/9322474
has comment: http://stackoverflow.com/comment/32620934
accepted answer: http://stackoverflow.com/a/21593171

http://stackoverflow.com/q/21522762
has body: I am trying to pick up languages for my app. I have Traditional and Simplified Chinese as languages too. All other languages are working but in case of Chinese, where I have 2 values folders, named zh-rCN and zh-rTW, its not taking the languages. Where as if I rename any folder to just zh, it will start picking up that folder string. Also when I rename the folders to zh-CN and zh-TW, that is showing Error in res folder (AAPT Problem).? What can be done to show both languages separately.?
has answer: http://stackoverflow.com/a/21524620
has title: Traditional and Simplified Chinese languages not being picked up separately
downvote count: 0
linked to: http://stackoverflow.com/q/4189875
score: 2
answer count: 1
tagged with: string
favorite count: 0
tagged with: android-resources
upvote count: 2
type: UnansweredQuestion
tagged with: android
tagged with: java
type: Question

http://stackoverflow.com/q/21669633
has comment: http://stackoverflow.com/comment/32755531
has answer: http://stackoverflow.com/a/21670524
accepted answer: http://stackoverflow.com/a/21670524
has comment: http://stackoverflow.com/comment/32755643
type: Question
has title: REST disregards any part that is not English characters , when receiving UTF-8
type: AnsweredQuestion
has body: Sending ajax request in UTF8 to the server that uses REST , disregards any part that is not English characters I'm using JAVA with REST on the server side , and the client sends ajax requests in UTF8 , that includes Hebrew words . The AJAX request : var clientNumber = '12344432432'; var userID = '321321321'; var someHebrewWord = ...; var someEnglishWord = ....; var servletUrl = '/Management/services/manager/' + clientNumber + '/' + userID + '/' + someEnglishWord + '/' someHebrewWord; alert('Sending this :' + servletUrl); $.ajax({ url: servletUrl, type: 'POST', cache: false, data: { }, success: function(data){ alert('Return value is:' + data); window.location = "./replyPage.html"; } , error: function(jqXHR, textStatus, err){ alert('text status '+textStatus+', err '+err + " " + JSON.stringify(jqXHR)); } }); On the server side , I use REST : @Produces({ "application/json" }) @Path("/manager") public class Management { @POST @Path("{clientNumber }/{userID }/{someEnglishWord}/{someHebrewWord}") @Produces("application/json") public boolean insert(@PathParam("clientNumber") String clientNumber, @PathParam("userID") String userID, @PathParam("someEnglishWord") String someEnglishWord, @PathParam("someHebrewWord") String someHebrewWord) { // do some stuff } @POST @Path("{clientNumber }/{userID }/{someEnglishWord}") @Produces("application/json") public boolean updateSomething(@PathParam("clientNumber") String clientNumber, @PathParam("userID") String userID , @PathParam("someEnglishWord") String someEnglishWord) { // do other stuff } // more code } So , when the AJAX request is sent , the updateSomething() is invoked instead of insert() , even though I'm sending 4 fields , and not 3 ! What causes this , and how can I fix it ? Much appreciated
tagged with: java
answer count: 1
tagged with: javascript
tagged with: ajax
score: 0
tagged with: rest
tagged with: utf-8

http://stackoverflow.com/a/21608324
type: Answer
has comment: http://stackoverflow.com/comment/134260760
downvote count: 0
has body: Are you looking for java.lang.Math.ulp? Returns the size of an ulp of the argument. An ulp of a double value is the positive distance between this floating-point value and the double value next larger in magnitude.
has comment: http://stackoverflow.com/comment/127361398
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/21608161

http://stackoverflow.com/q/21645431
has answer: http://stackoverflow.com/a/21645491
has body: I am learning hadoop and I got through this line import org.apache.hadoop.mapreduce.Job; Job job = new Job(); I keep getting warning (deprecated class), I'm aware that using it will work fine. but I don't want to use deprecated classes. so what is the best way to do this? a link or a reference would be highly appreciated. note: I'm using hadoop 2.2.0
possible better answer: http://stackoverflow.com/a/33981593
has answer: http://stackoverflow.com/a/33981593
score: 13
tagged with: hadoop
answer count: 2
has title: what are the replacement for hadoop Job deprecated class
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/21645491
upvote count: 13
type: AnsweredQuestion
tagged with: java
type: Question

http://stackoverflow.com/q/21615337
upvote count: 1
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21615373
tagged with: java
possible better answer: http://stackoverflow.com/a/21615361
has answer: http://stackoverflow.com/a/21615361
type: Question
answer count: 2
has title: HashSet of integers
downvote count: 0
has comment: http://stackoverflow.com/comment/32660673
tagged with: hashset
tagged with: inheritance
has comment: http://stackoverflow.com/comment/32660642
tagged with: abstract-class
has answer: http://stackoverflow.com/a/21615373
score: 1
tagged with: generics
favorite count: 0
has body: public class MyClass&lt;Integer&gt; extends AnotherOne&lt;Integer&gt; { public MyClass(HashSet&lt;Integer&gt; ar) { super(ar); } } AnotherOne is an abstract(generic) class which has a constructor which gets HashSet&lt;T&gt; as a parameter. Then it has another method which uses the T type for its parameters. Everything is ok but I have to use Integer as a parameter to override that method and using Integer instead of int seems weird. Is there a way to use the primitive int?

http://stackoverflow.com/a/41514458
answers question: http://stackoverflow.com/q/21662190
upvote count: 2
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/70235848
downvote count: 0
has body: Although this is not documented clearly I have realized from experience that it has to do with dynamic data. If your class only contains statically typed data, then available() is able to estimate the size. If there are dynamic data in your object, like lists etc, then it is not possible to make that estimation.

http://stackoverflow.com/a/42115592
upvote count: 3
downvote count: 0
has body: to understant sentinel-controlled repetition let's see a simple example, import java.util.Scanner; // program uses class Scanner public class ClassAverage { public static void main(String[] args) { // create Scanner to obtain input from command window Scanner input = new Scanner(System.in); // initialization phase int total = 0; // initialize sum of grades int gradeCounter = 0; // initialize # of grades entered so far // processing phase // prompt for input and read grade from user System.out.print("Enter grade or -1 to quit: "); int grade = input.nextInt(); // loop until sentinel value read from user while (grade != -1) { total = total + grade; // add grade to total gradeCounter = gradeCounter + 1; // increment counter // prompt for input and read next grade from user System.out.print("Enter grade or -1 to quit: "); grade = input.nextInt(); } // termination phase // if user entered at least one grade... if (gradeCounter != 0) { // use number with decimal point to calculate average of grades double average = (double) total / gradeCounter; // display total and average (with two digits of precision) System.out.printf("%nTotal of the %d grades entered is %d%n", gradeCounter, total); System.out.printf("Class average is %.2f%n", average); } else // no grades were entered, so output appropriate message System.out.println("No grades were entered"); } } // end class ClassAverage now let's run it Enter grade or -1 to quit: 97 Enter grade or -1 to quit: 88 Enter grade or -1 to quit: 72 Enter grade or -1 to quit: -1 Total of the 3 grades entered is 257 Class average is 85.67 In a sentinel-controlled loop, prompts should remind the user of the sentinel. its a good Practice to do reference: Java™ How To Program (Early Objects), Tenth Edition
answers question: http://stackoverflow.com/q/21666508
type: Answer
score: 3

http://stackoverflow.com/a/21660460
score: 4
has comment: http://stackoverflow.com/comment/32822021
upvote count: 4
downvote count: 0
has body: This may not directly answer your question, but have you tried using Volley's NetworkImageView class ? Recently, I used Volley in a large project to display images, and it was faster and more stable than anything I've seen before. Volley is a networking library for Android developed by the good guys at Google, and it includes image downloading out of the box. It handles small or large images with ease. All you need to do is add the Volley library to your project and replace ImageView in your XML layout with com.android.volley.toolbox.NetworkImageView. Add the following variables to your Activity class: private RequestQueue mRequestQueue; private ImageLoader mImageLoader; Create the objects in the onCreate() method of your Activity: mRequestQueue = Volley.newRequestQueue(context); mImageLoader = new ImageLoader(mRequestQueue, new ImageLoader.ImageCache() { private final LruCache&lt;String, Bitmap&gt; mCache = new LruCache&lt;String, Bitmap&gt;(10); public void putBitmap(String url, Bitmap bitmap) { mCache.put(url, bitmap); } public Bitmap getBitmap(String url) { return mCache.get(url); } }); Then download the image the getView() method of your Adapter class: NetworkImageView image = (NetworkImageView)view.findViewById(R.id.image); image.setImageUrl("http://somerandomurl.com/somerandomimage.png",mImageLoader); In production code, you would use a global instance of both the RequestQueue and ImageLoader classes, and your onCreate() method wouldn't be cluttered as it is here. I wouldn't use a WebView to display images, though of course it can be done. If you really want to see which way is "faster", you can try out ImageView, NetworkImageView and WebView to load a large image and get a rough time estimate with the System.nanoTime() method.
type: Answer
answers question: http://stackoverflow.com/q/21659181

http://stackoverflow.com/a/21575173
type: Answer
upvote count: 0
answers question: http://stackoverflow.com/q/21574453
has body: At first, if it's a pure unit test you can get rid of @Before section using @RunWith and @InjectMocks annotations. They will handle the initialization phase. Second, you don't nee to put try-catch blocks, you can just declare the Exception in your testMethod. And it's better to use when() instead of stub(), like this: @RunWith(MockitoJUnitRunner.class) public class MyTest { @Mock private MyHelper mockedDependency; @InjectMocks private MyService serviceUnderTest; @Test public void test1() throws Exception { SomeObject someObject = null; // create my stub when(mockedDependency.doSomething("123", false, false)).thenReturn(someObject); // run the implementation ServiceResult serviceResult = serviceUnderTest.anotherMethod("123", false, false); // check the state assertNotNull(serviceResult); // check the behaviour of the mock verify(mockedDependency).doSomething("123", false, false); }} In your case line when(mockedDependency.doSomething is not important - test is checking the desired behaviour of MyServiceImpl anyway.
has comment: http://stackoverflow.com/comment/32591580
score: -1
downvote count: 1
has comment: http://stackoverflow.com/comment/32590498
has comment: http://stackoverflow.com/comment/32595428
has comment: http://stackoverflow.com/comment/32591052

http://stackoverflow.com/comment/32482739
comment on: http://stackoverflow.com/q/21514794
has text: I think your code will do what exactly you want. Are you facing any issues with that?
score: 1
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/34271038
type: AnswerComment
score: 0
has text: Hey,How Did You Do That? I have same problem.I m not able to figure out.I want to remove that mvc annotation tag, so how can i tell spring,where to look for conversion-service? Can you please brief me little bit more...
type: Comment
comment on: http://stackoverflow.com/a/21549358

http://stackoverflow.com/comment/32682611
comment on: http://stackoverflow.com/q/21628579
type: Comment
type: QuestionComment
has text: P.s. I am not behind a proxy server.
score: 0

jython-2.5
tag name: jython-2.5
type: Tag
tags question: http://stackoverflow.com/q/21572788

http://stackoverflow.com/a/21589637
type: Answer
has comment: http://stackoverflow.com/comment/32616363
has body: Scanner scan = new Scanner(System.in); String s = scan.nextLine(); PrintWriter p = new PrintWriter("outputFile.txt"); p.println(s); ... p.close(); Scanner can grab user command-line input and store it as a String, which can easily be sent to a file.
score: 2
has comment: http://stackoverflow.com/comment/32616417
has comment: http://stackoverflow.com/comment/32616172
accepted answer of: http://stackoverflow.com/q/21589575
upvote count: 2
answers question: http://stackoverflow.com/q/21589575
has comment: http://stackoverflow.com/comment/32616191
has comment: http://stackoverflow.com/comment/32616150
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32616331
downvote count: 0

http://stackoverflow.com/q/21662588
has comment: http://stackoverflow.com/comment/32743262
has answer: http://stackoverflow.com/a/59702033
has answer: http://stackoverflow.com/a/27250852
has comment: http://stackoverflow.com/comment/32743600
has answer: http://stackoverflow.com/a/39464087
tagged with: tomcat
has comment: http://stackoverflow.com/comment/32742651
favorite count: 0
has answer: http://stackoverflow.com/a/24124340
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/51663962
answer count: 10
has answer: http://stackoverflow.com/a/77965537
has answer: http://stackoverflow.com/a/50046042
has body: I am a beginner. I am trying to run a java JDBC program in Eclipse with tomcat server. But when I run the program a pop up "Java virtual machine launcher" window with "A java exception error has occurred" is coming up.I think the code compilation is fine. So how should I fix this problem.When I surf through different websites, some are saying that I should re-install java again . Is it true. Please help me with the answers. Thanks in advance
downvote count: 1
has answer: http://stackoverflow.com/a/56198397
has answer: http://stackoverflow.com/a/74809964
has answer: http://stackoverflow.com/a/29152652
type: Question
upvote count: 5
tagged with: java
score: 4
tagged with: eclipse
has title: Java virtual machine launcher error- A java exception has occurred

http://stackoverflow.com/comment/33120768
comment on: http://stackoverflow.com/q/21554088
type: QuestionComment
type: Comment
score: 0
has text: Could it be related to running open java 1.6?

http://stackoverflow.com/q/21591491
upvote count: 1
answer count: 1
tagged with: macos
favorite count: 0
tagged with: jframe
type: UnansweredQuestion
tagged with: swing
has title: JFrame minimized to dock name "java"
downvote count: 0
score: 1
linked to: http://stackoverflow.com/q/14917908
tagged with: java
tagged with: minimize
type: Question
has answer: http://stackoverflow.com/a/21598496
has body: I am displaying a JFrame on OS X and am getting "java" for the name of the application when it is minimized to the dock. I am passing -Xdock:name="Foo", and this is changing the name in the dock when the application is not minimized, but once we minimize the name in the dock is wrong. To minimize I am calling setExtendedState(JFrame.ICONIFIED).

http://stackoverflow.com/comment/32671691
has text: @GuyBouallet note that that answer seems to be contradicting answers given here, as it says it is put to both constant pool and the heap
comment on: http://stackoverflow.com/q/21621958
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/q/21568446
has comment: http://stackoverflow.com/comment/32579051
has comment: http://stackoverflow.com/comment/32579099
tagged with: java
downvote count: 1
has comment: http://stackoverflow.com/comment/32579218
has comment: http://stackoverflow.com/comment/32578862
tagged with: sympy
has comment: http://stackoverflow.com/comment/32578603
has answer: http://stackoverflow.com/a/21569120
has comment: http://stackoverflow.com/comment/32578967
tagged with: python-2.7
accepted answer: http://stackoverflow.com/a/21569120
type: AnsweredQuestion
score: 1
has body: In essence I have this program: from sympy.solvers import solve from sympy import Symbol x = Symbol('x') print solve(x**2 - 1, x) And I call this from Java using this code: public static BufferedReader runFile(Class&lt;?&gt; c, String py, List&lt;String&gt; args) { String cmd = c.getResource(py).getPath(); cmd=cmd.split(py)[0]; cmd=cmd.substring(0,cmd.length()-1); args.add(0, py); args.add(0, "python"); final ProcessBuilder pb = new ProcessBuilder(args); new ProcessBuilder(); pb.directory(new File(cmd)); pb.redirectError(); try { System.out.println(pb.directory().getPath()); for(String s:pb.command()){ System.out.println(s); } Process p=pb.start(); return new BufferedReader(new InputStreamReader(p.getErrorStream())); } catch (final IOException e) { throw new RuntimeException(e); } } When I run the Python program from a terminal everything works as intended, with nothing in the error stream, and it prints [-1,1]. But if I run it from the program, I get this in the error stream: Traceback (most recent call last): File "solve.py", line 1, in &lt;module&gt; from sympy.solvers import solve ImportError: No module named sympy.solvers
has comment: http://stackoverflow.com/comment/32578377
favorite count: 0
has comment: http://stackoverflow.com/comment/32578790
has comment: http://stackoverflow.com/comment/32578983
has comment: http://stackoverflow.com/comment/32578393
type: Question
upvote count: 2
answer count: 2
possible better answer: http://stackoverflow.com/a/21568755
tagged with: python
has answer: http://stackoverflow.com/a/21568755
has comment: http://stackoverflow.com/comment/32578423
has title: Why does my Python program fail when called from Java?
has comment: http://stackoverflow.com/comment/32579136
has comment: http://stackoverflow.com/comment/32578870

http://stackoverflow.com/comment/32602701
has text: As the Android blogpost says: "Just remember to keep such tasks small and light to avoid slowing down the user experience.", and you're just changing background color, so you should be fine. Check the links if you still have doubts.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21565618
type: Comment

http://stackoverflow.com/comment/32735574
score: 0
has text: Java will look for the resource in the same place where the class files are. If your class files are at .../modern-jogl-examples/bin/<package>/<filename>.class, then it will look for resources in .../modern-jogl-examples/bin/<the string you pass to getResource>. If Netbeans isn't automatically copying them to the correct location, then something is probably wrong with the way Netbeans is set up.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21658061

http://stackoverflow.com/a/21624960
score: 1
has body: The clone() method is defined on the root class Object (see here). It returns an Object, therefore, if you haven't changed its return type to the concrete class while overriding, you have to cast it to the proper type, e.g. : clone.add((Company) item.clone()); or define clone() with a covariant return type in your class as: public class Company implements Cloneable { // stuff ... public Company clone() throws CloneNotSupportedException { /* do clone */ } } Note that you have to override the clone method as it is defined with visibility protected. By convention, classes that implement this interface should override Object.clone (which is protected) with a public method. See Object.clone() for details on overriding this method. [source] Also see this question for other options.
type: Answer
has comment: http://stackoverflow.com/comment/32676650
upvote count: 1
accepted answer of: http://stackoverflow.com/q/21624841
has comment: http://stackoverflow.com/comment/32676439
answers question: http://stackoverflow.com/q/21624841
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32677098

http://stackoverflow.com/a/21522640
type: Answer
accepted answer of: http://stackoverflow.com/q/21520225
has body: It says the output stream is in a bad state. Verify that you have the right data with some debug logging such as: java.util.logging.Logger.getLogger("todtm.getImage").warning( "photo.length:" + photo.length ); Try commenting out the response.setContentType line in case it was affecting the output stream. Try replacing the '// sends image data' line with: javax.servlet.ServletOutputStream outputStream = response.getOutputStream(); outputStream.write(photo); // sends image data to more accurately isolate the operation the throws the exception. Put at least minimal logging into the catch block: java.util.logging.Logger.getLogger("todtm.getImage").warning( "cannotLoad:" + cannotLoad.getMessage(); );
score: 0
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21520225

http://stackoverflow.com/comment/32694325
comment on: http://stackoverflow.com/q/21634739
score: 0
has text: Yes, I actually use the shunting-yard algorithm! This is just for pre-formatting the string to simplify the parsing.
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21537043
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/17204147
has comment: http://stackoverflow.com/comment/32522447
tagged with: java
accepted answer: http://stackoverflow.com/a/21537089
has title: Command line options for java
possible better answer: http://stackoverflow.com/a/21537375
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/21537375
has comment: http://stackoverflow.com/comment/32522400
has comment: http://stackoverflow.com/comment/32522471
has comment: http://stackoverflow.com/comment/32522488
score: 0
has answer: http://stackoverflow.com/a/21537089
has comment: http://stackoverflow.com/comment/32522401
has comment: http://stackoverflow.com/comment/32522420
has comment: http://stackoverflow.com/comment/32522470
has comment: http://stackoverflow.com/comment/32522479
has body: I have been developing java programs using eclipse but for some time I wanted to edit/run (mostly for learning purposes) it on a command line on windows e.g. cmd - the only thing is in cmd (unlike ubuntu or shells editors), it doesnt do any formattting / color coding for any of the types or keywords - it looks like i am writing on a notepad. Is there any way I could get a colorful formatted editor for cmd for writing and compiling java programs. I still dont want to use intellisense or other IDE features - just something more than black and white cmd will do. Thanks

http://stackoverflow.com/q/21518401
score: 0
has title: issue with maven repository
tagged with: maven
has answer: http://stackoverflow.com/a/21518436
answer count: 1
has body: I just want to know if maven triggers automatically as soon as we add the dependency to pom.xml and save it? because i just added one new dependency to my existing pom.xml, It gave me the below error ArtifactDescriptorException: Failed to read artifact descriptor for org.springframework:spring-oxm:jar:3.0.5.RELEASE: ArtifactResolutionException: Could not transfer artifact org.springframework:spring-oxm:pom:3.0.5.RELEASE from/to nexus (http://vdidev-v1102-p:8081/nexus/content/groups/GroupMoodysFlexApps/): connection timed out to http://vdidev-v1102-p:8081/nexus/content/groups/GroupMoodysFlexApps/org/springframework/spring-oxm/3.0.5.RELEASE/spring-oxm-3.0.5.RELEASE.pom
tagged with: java
type: UnansweredQuestion
type: Question
has comment: http://stackoverflow.com/comment/32489251

http://stackoverflow.com/q/21541821
type: UnansweredQuestion
has title: Make a field mandatory, only if another field is null in Struts2
tagged with: java
tagged with: struts2
type: Question
tagged with: validation
answer count: 1
has answer: http://stackoverflow.com/a/21551183
has body: Assuming the following action class that can handle file uploading. @Namespace("/admin_side") @ResultPath("/WEB-INF/content") @ParentPackage(value="struts-default") public final class CategoryAction extends ActionSupport implements Serializable, ValidationAware, ModelDriven&lt;Category&gt; { private static final long serialVersionUID = 1L; private File fileUpload; private String fileUploadContentType; private String fileUploadFileName; private Long editId; //Getters and setters. @Validations( requiredFields={ @RequiredFieldValidator(fieldName="fileUpload", type= ValidatorType.FIELD, message="Uploading an image is mandatory.")}) @Action(value = "AddCategory", results = { @Result(name=ActionSupport.SUCCESS, type="redirectAction", params={"namespace", "/admin_side", "actionName", "Category", "currentPage", "${currentPage}", "message", "${message}", "editId", "${editId}", "status", "${status}"}), @Result(name = ActionSupport.INPUT, location = "Category.jsp")}, interceptorRefs={ @InterceptorRef(value="defaultStack", params={"params.acceptParamNames", "editId, fileUpload, fileUploadContentType, fileUploadFileName, catId, catName, visible, latest, currentPage, rowCount, totalPages, status", "validation.validateAnnotatedMethodOnly", "true"}) }) public String insertOrUpdate(){ //Do either insert or update based on editId. return ActionSupport.SUCCESS; } @Action(value = "Category", results = { @Result(name=ActionSupport.SUCCESS, location="Category.jsp"), @Result(name = ActionSupport.INPUT, location = "Category.jsp")}, interceptorRefs={ @InterceptorRef(value="defaultStack", params={"params.acceptParamNames", "id, currentPage, rowCount, totalPages, message, status", "validation.validateAnnotatedMethodOnly", "true", "validation.excludeMethods", "load"})}) public String load() throws Exception{ //This method is just required to return an initial view on page load. return ActionSupport.SUCCESS; } } I would like to validate fileUpload (mandatory) only when editId is null. If it is …
score: 0

http://stackoverflow.com/comment/32623959
type: Comment
type: QuestionComment
score: 0
has text: Try printing out the values of the intermediate values and/or conditionals each time, so you can see why the program is making the unexpected decision. That should show you the bug in your logic. Then all you need to do is figure out what it should be doing instead at that point.
comment on: http://stackoverflow.com/q/21593799

http://stackoverflow.com/comment/32486651
type: AnswerComment
score: 0
type: Comment
has text: Use classes. It's better coding practice.
comment on: http://stackoverflow.com/a/21516929

http://stackoverflow.com/a/21616574
type: Answer
answers question: http://stackoverflow.com/q/21616404
downvote count: 1
has comment: http://stackoverflow.com/comment/32662901
score: -1
has body: You can go with that code: public class Deneme { private static Scanner input; private static ArrayList&lt;String&gt; arr; public static void main(String... args) { input = new Scanner(System.in); arr = new ArrayList&lt;&gt;(); while (true) { System.out.print("Please enter a value: "); String val = input.nextLine(); if (arr.contains(val)) System.out .println("Please enter some other value you've already entered : " + val); else arr.add(val); } } }
upvote count: 0

http://stackoverflow.com/comment/32577417
comment on: http://stackoverflow.com/q/21567823
type: Comment
has text: Ok so, I have "Bacon" image from "x" xml. When I click a "Pig" button from "y" xml, I want to change "Bacon" into "Pig". What I did was set an onClickListner for "Pig", and when that is pressed, I made an Image variable, set it to "Bacon", use setImageResource and set "Bacon" into "Pig", but that resulted a nullReferenceException, so I want to know another way so that it doesn't trigger that error
type: QuestionComment
score: 0

http://stackoverflow.com/q/21516375
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32485621
has comment: http://stackoverflow.com/comment/32486068
tagged with: local-class
has comment: http://stackoverflow.com/comment/32485971
linked to: http://stackoverflow.com/q/21515693
has comment: http://stackoverflow.com/comment/32485587
possible better answer: http://stackoverflow.com/a/21516417
has body: Java allows me to define local abstract classes, like in this example: public class Foo { public void foo() { abstract class Bar { // Bar is a local class in foo() ... abstract void bar(); } new Bar() { // ... and can be anonymously instantiated void bar() { System.out.println("Bar!"); } }.bar(); } } For some reason, when I try to define a "local interface" instead of the local class, like this: public class Foo { public void foo() { interface Bar { // Bar was supposed to be a local interface... void bar(); } new Bar() { // ... to be anonymously instantiated void bar() { System.out.println("Bar!"); } }.bar(); } } Java complains that "The member interface Bar can only be defined inside a top-level class or interface". Is there a reason for this? Or am I missing a mistake I made?
has comment: http://stackoverflow.com/comment/32485658
type: Question
has comment: http://stackoverflow.com/comment/32485691
has answer: http://stackoverflow.com/a/21516417
score: 3
has answer: http://stackoverflow.com/a/21516677
tagged with: java
accepted answer: http://stackoverflow.com/a/21516677
has answer: http://stackoverflow.com/a/79301424
has comment: http://stackoverflow.com/comment/32485775
has comment: http://stackoverflow.com/comment/32485881
has comment: http://stackoverflow.com/comment/32485797
has answer: http://stackoverflow.com/a/69807746
has comment: http://stackoverflow.com/comment/32485824
has comment: http://stackoverflow.com/comment/32485699
downvote count: 1
has comment: http://stackoverflow.com/comment/32487727
favorite count: 0
answer count: 5
has comment: http://stackoverflow.com/comment/32487119
has comment: http://stackoverflow.com/comment/32485932
tagged with: interface
has answer: http://stackoverflow.com/a/66320618
upvote count: 4
has comment: http://stackoverflow.com/comment/32485747
has title: Is there such a thing as a "local interface" in Java?

http://stackoverflow.com/comment/32644625
type: AnswerComment
comment on: http://stackoverflow.com/a/21605826
type: Comment
has text: @user2582318 You only need to add `hibernate-core` to your `pom.xml` to get the other things it depends on.
score: 0

http://stackoverflow.com/comment/32687000
type: QuestionComment
has text: no difference the output is still the same.
comment on: http://stackoverflow.com/q/21630345
score: 0
type: Comment

http://stackoverflow.com/comment/32644284
has text: Yes, you can monitor yourself, but I doubt that it will be very robust. You need action taken when the VM gets under load. Meaning the process that needs to take action is then part of the VM that already is overloaded. Many monitoring tools, e.g. [Hyperic](http://www.hyperic.com/), allow you to monitor VM metrics via JMX and to automatically trigger an action, e.g. call a method on an MBean, if thresholds are breached. Maybe you should talk to your operations guys what kinds of tools they use to monitor your production environment.
type: Comment
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/21605805

spring
tags question: http://stackoverflow.com/q/21652509
tags question: http://stackoverflow.com/q/21657260
tags question: http://stackoverflow.com/q/21652490
tags question: http://stackoverflow.com/q/21620964
tags question: http://stackoverflow.com/q/21671731
tags question: http://stackoverflow.com/q/21622149
tags question: http://stackoverflow.com/q/21667418
tags question: http://stackoverflow.com/q/21651732
tags question: http://stackoverflow.com/q/21636566
tags question: http://stackoverflow.com/q/21599551
tags question: http://stackoverflow.com/q/21658547
tags question: http://stackoverflow.com/q/21528455
tags question: http://stackoverflow.com/q/21539053
tags question: http://stackoverflow.com/q/21552130
tags question: http://stackoverflow.com/q/21674463
tags question: http://stackoverflow.com/q/21571225
tags question: http://stackoverflow.com/q/21567553
tags question: http://stackoverflow.com/q/21636649
tags question: http://stackoverflow.com/q/21675512
tags question: http://stackoverflow.com/q/21519271
tags question: http://stackoverflow.com/q/21656739
tags question: http://stackoverflow.com/q/21645350
tags question: http://stackoverflow.com/q/21607660
tags question: http://stackoverflow.com/q/21598828
tags question: http://stackoverflow.com/q/21525135
tags question: http://stackoverflow.com/q/21530290
tags question: http://stackoverflow.com/q/21675483
tags question: http://stackoverflow.com/q/21557066
tags question: http://stackoverflow.com/q/21620723
tags question: http://stackoverflow.com/q/21622885
tags question: http://stackoverflow.com/q/21536240
tags question: http://stackoverflow.com/q/21583399
tags question: http://stackoverflow.com/q/21573990
tags question: http://stackoverflow.com/q/21657428
tags question: http://stackoverflow.com/q/21670104
tags question: http://stackoverflow.com/q/21560503
tags question: http://stackoverflow.com/q/21660552
tags question: http://stackoverflow.com/q/21615881
tags question: http://stackoverflow.com/q/21545096
tags question: http://stackoverflow.com/q/21527806
tags question: http://stackoverflow.com/q/21558215
tags question: http://stackoverflow.com/q/21659447
type: Tag
tags question: http://stackoverflow.com/q/21515313
tags question: http://stackoverflow.com/q/21584563
tags question: http://stackoverflow.com/q/21546433
tags question: http://stackoverflow.com/q/21536400
tags question: http://stackoverflow.com/q/21526767
tags question: http://stackoverflow.com/q/21542376
tags question: http://stackoverflow.com/q/21549805
tags question: http://stackoverflow.com/q/21559068
tags question: http://stackoverflow.com/q/21524205
tags question: http://stackoverflow.com/q/21571747
tags question: http://stackoverflow.com/q/21564891
tags question: http://stackoverflow.com/q/21523794
tags question: http://stackoverflow.com/q/21544576
tags question: http://stackoverflow.com/q/21648710
tags question: http://stackoverflow.com/q/21633555
tags question: http://stackoverflow.com/q/21624299
tags question: http://stackoverflow.com/q/21615049
tags question: http://stackoverflow.com/q/21673987
tags question: http://stackoverflow.com/q/21561567
tags question: http://stackoverflow.com/q/21615630
tags question: http://stackoverflow.com/q/21601367
tags question: http://stackoverflow.com/q/21677275
tags question: http://stackoverflow.com/q/21522947
tags question: http://stackoverflow.com/q/21550549
tags question: http://stackoverflow.com/q/21597883
tags question: http://stackoverflow.com/q/21535882
tags question: http://stackoverflow.com/q/21562773
tags question: http://stackoverflow.com/q/21675457
tags question: http://stackoverflow.com/q/21528271
tags question: http://stackoverflow.com/q/21574551
tags question: http://stackoverflow.com/q/21624643
tags question: http://stackoverflow.com/q/21650664
tags question: http://stackoverflow.com/q/21606034
tags question: http://stackoverflow.com/q/21563011
tags question: http://stackoverflow.com/q/21586555
tags question: http://stackoverflow.com/q/21532058
tags question: http://stackoverflow.com/q/21621901

http://stackoverflow.com/q/21524476
tagged with: java
has answer: http://stackoverflow.com/a/21524749
type: Question
has answer: http://stackoverflow.com/a/21524742
accepted answer: http://stackoverflow.com/a/21524742
has answer: http://stackoverflow.com/a/21524621
answer count: 6
has body: I need to parse this string as a date: Mon Jun 10 00:00:00 CEST 2013 Here is what I do: SimpleDateFormat sdf = new SimpleDateFormat("ccc MMM dd HH:mm:ss z yyyy"); Date date = sdf.parse(dateString); But I get a ParseException: Unparseable date: "Wed Oct 02 00:00:00 CEST 2013" (at offset 0) Any help please?
has comment: http://stackoverflow.com/comment/32499348
score: 0
linked to: http://stackoverflow.com/q/40025528
has comment: http://stackoverflow.com/comment/32499564
possible better answer: http://stackoverflow.com/a/21524541
tagged with: date-parsing
has comment: http://stackoverflow.com/comment/32499671
has answer: http://stackoverflow.com/a/74944614
has title: Error parsing date string
has answer: http://stackoverflow.com/a/21524546
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21524541

http://stackoverflow.com/comment/32573081
score: 1
type: AnswerComment
type: Comment
has text: @Zingo if you wan't to decode the data ,that you don't want to use hash-es you should be using something like AES ,with a secure key that you could get from a hash for example.
comment on: http://stackoverflow.com/a/21565611

http://stackoverflow.com/comment/32709448
score: 0
type: AnswerComment
has text: Thanks, that solved the problem. I'll accept your answer once the timer finishes
type: Comment
comment on: http://stackoverflow.com/a/21643511

http://stackoverflow.com/comment/32585286
has text: here this a tutorial for what `super` mean :http://docs.oracle.com/javase/tutorial/java/IandI/super.html
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21572588

http://stackoverflow.com/comment/32601931
has text: In C, array is a pointer to the memory address, and with index you access that memory. When your index accesses a memory which is outside of the array you may try to access memory which does not belong to your process. In such situation kernel will kill you with segmentation fault. IOW, segmentation fault tells you that you are trying to access memory outside of your process. In some situation you will get some rubbish.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21581898
score: 0

http://stackoverflow.com/a/21641388
has comment: http://stackoverflow.com/comment/32706369
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21641354
has comment: http://stackoverflow.com/comment/32706313
has body: Another possibility is that at the end of the entire section of code, you could add: if (gpa &gt; 4) gpa = 4; if (gpa &lt; 0) gpa = 0; if (letter1.equals("F") &amp;&amp; letter2.equals("+")) gpa = 0;
upvote count: 2
type: Answer
accepted answer of: http://stackoverflow.com/q/21641354
has comment: http://stackoverflow.com/comment/32706173
score: 2
has comment: http://stackoverflow.com/comment/32706242
has comment: http://stackoverflow.com/comment/32721762
has comment: http://stackoverflow.com/comment/32706255
has comment: http://stackoverflow.com/comment/32706148

http://stackoverflow.com/a/21559637
answers question: http://stackoverflow.com/q/21558975
type: Answer
score: 2
downvote count: 0
has body: The problem is clearly not in Joda-Time: public static void main(String[] args) { DateTime d = new DateTime(2013,12,31,23,59,52,DateTimeZone.UTC); System.out.println(d); System.out.println(d.getDayOfYear()); } prints 2013-12-31T23:59:52.000Z 365 I suggest you single-step through your code with an IDE debugger. (I know this is probably more of a comment than an answer but it's hard to put readable code in a comment)
upvote count: 2

http://stackoverflow.com/comment/35008643
comment on: http://stackoverflow.com/a/22802750
score: 0
type: AnswerComment
has text: i'm using 4.0.3 version of spring... spring-context-support-4.0.3.RELEASE has given class
type: Comment

http://stackoverflow.com/q/21618029
has comment: http://stackoverflow.com/comment/32665530
has comment: http://stackoverflow.com/comment/32665920
tagged with: arraylist
tagged with: int
score: 0
accepted answer: http://stackoverflow.com/a/21618390
has title: (Simple) Add different types to ArrayList <class>
tagged with: constructor
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21618390
has comment: http://stackoverflow.com/comment/32666301
tagged with: java
has body: So I need to get the int and the boolean into the contractor so I can calculate different things through methods. Is there a way I could do this through an ArrayList, or two. I just need help getting it there! Thank you for any help. Main Method: import java.util.ArrayList; public class Tester { public static void main(String[] args) { ArrayList&lt;Contructor&gt; cO2 = new ArrayList&lt;Constructor&gt;(); // add households to the arraylist CO2FromWaste homeData = new CO2FromWaste(); cO2.add(); for(Contructor dataRecord : cO2) { dataRecord.calcGrossWasteEmission(); dataRecord.calcWasteReduction(); dataRecord.calcNetWasteReduction(); } Constructor: public class Contructor { private int myNumPeople; private boolean myPaper, myPlastic, myGlass, myCans; private double myEmissions, myReduction, myNetEmissions; /** * Constructor for objects of type CO2FromWaste * @param numPeople number of people in a household * @param paper whether or not paper is recycled * @param plastic whether or not plastic is recycled * @param glass whether or not glass is recycled * @param cans whether or not cans are recycled */ Contructor(int numPeople, boolean paper, boolean plastic, boolean glass, boolean cans) { myNumPeople = numPeople; myPaper = paper; myPlastic = plastic; myGlass = glass; myCans = cans; myEmissions = 0.0; myReduction = 0.0; myNetEmissions = 0.0; }
type: Question
tagged with: arrays
answer count: 1

http://stackoverflow.com/q/21585756
tagged with: java
has title: SetContentView acting strangely
type: Question
tagged with: android-layout
score: 0
has body: I'm a new android developer and while I thought I had moved past problems like these I guess not. This is the deal, in my main class I set the content view and it works fine setContentView(R.layout.main); This works the way it usually does, after I type R.layout. it gives me a list of all the layouts I have in the res/layout folder. In this case: display_screen main seek_bar_preference Now in a separate activity I created I wanted to set the layout to display_screen, but when I type R.layout. in setContentView, I no longer get the list of xml files I saw before, and instead I get other values, activity_list_item:int browser_link_context_header:int expandable_list_conent it goes on for awhile and is clearly pulling these values from somewhere else other than the layout folder. Here is the full code of the DisplayScreen activity public class DisplayScreen extends Activity{ @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); //sets the layout setContentView(R.layout.display_screen); } } I HAVE compiled the code I cleaned the project I added the new activity to AndroidManifest.xml I have used setContentView in other projects without error, so I'm sure it's a small step I missed along the way. Any help appreciated.
answer count: 1
has comment: http://stackoverflow.com/comment/32608795
type: UnansweredQuestion
tagged with: android
has comment: http://stackoverflow.com/comment/32608664
has answer: http://stackoverflow.com/a/21585783
has comment: http://stackoverflow.com/comment/32608617

http://stackoverflow.com/comment/32666681
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21618575
has text: You first have to define a variable in Cell to store the value. Then as game progress you have to set the value of the Cell. You can then compare this value.

http://stackoverflow.com/q/21651404
has body: I have just started developing an android app, so i'm kinda new to java and xml. I have my frontpage, activity_main.xml and the java file, MainActivity.java On the activity_main.xml page i have inserted a button. When I click on this button it goes to page2.xml On page2.xml i have another button. The user is supposed to be redirected to page3.xml when he clicks the button. But nothing appears when the button on page2.xml is clicked. Following is button code on my activity_main.xml file &lt;Button android:id="@+id/page2" android:layout_width="fill_parent" android:layout_height="86dp" android:layout_marginTop="19dp" android:gravity="center_vertical" android:text="@string/knap" /&gt; This is the MainActivity.java file package com.example.testing; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.app.Activity; import android.content.Intent; public class MainActivity extends Activity { Button page2; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); page2 = (Button) findViewById(R.id.page2); page2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub startActivity(new Intent("com.example.minapp.PAGE2")); } }); } } I have also 'page2.java' package com.example.testing; import android.app.Activity; import android.os.Bundle; public class page2 extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.page2); } } And finally my AndroidManifest.xml file where i have these activities, &lt;activity android:name="com.example.testing.MainActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&g…
has comment: http://stackoverflow.com/comment/32736011
has title: Multiple xml files in one activity - Android application
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/21653786
tagged with: java
score: -1
tagged with: eclipse
upvote count: 0
answer count: 1
favorite count: 0
type: UnansweredQuestion
tagged with: android
has comment: http://stackoverflow.com/comment/32724014
tagged with: http://stackoverflow.com/tag/xml
has comment: http://stackoverflow.com/comment/32723234

http://stackoverflow.com/comment/32578586
has text: What is this program about? And where is the rest of the code?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21567037

http://stackoverflow.com/q/21608732
score: 2
has comment: http://stackoverflow.com/comment/32960960
answer count: 0
downvote count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32682918
favorite count: 0
type: Question
upvote count: 2
has title: JavaFX - Task/Background processing - How to call multiple methods in a task?
has body: I'm trying to teach myself JavaFX and stumbled over a problem I can't seem to fully understand even after reading anything remotely related I could find. What I'm trying to do : I basically want to run some quick processing in the background of my JavaFX application so to not block the UI for the user. While this is happening a UI element is put up which then should be removed as soon as the background process is finished. So what I attempted to do was to just move those method calls into a Task which should then run without making the UI freeze. Task task = new Task&lt;Void&gt;() { @Override protected Void call() { step1(); step2(); step3(); }}; new Thread(task).start(); I want to call multiple methods of the class we're currently in, but what's happening instead is that only the first method gets invoked. It seems to me that after step1 has reached it's end it doesn't actually "return" to the Task. I've tried looking up how this works and what I could do but honestly didn't get any smarter. Basically all examples of threading and workers only included how to loop and do recurring things but I really just want a "single execution" but in background. It's probably a really idiotic thing I'm trying to do and shows my little understanding of this but if anyone could point me into the right direction I'd be very thankful. Thanks a lot! Solution : When working with JavaFX the use of "Platform.runLater(task)" is advisable since a normal Thread cannot interact with the UI. A IllegalStateException will be thrown and the thread is halted/canceled(?). The Task itself can remain unchanged but has to be handed to the Platform to execute it to prevent this issue. I changed that one line and everything was perfect afterwards. I hope this might help someone, someday :-)
tagged with: background-process
tagged with: java
tagged with: javafx
tagged with: task

http://stackoverflow.com/q/21532927
upvote count: 0
tagged with: textview
has title: Android TextView troubles
favorite count: 0
has answer: http://stackoverflow.com/a/21532959
tagged with: android
possible better answer: http://stackoverflow.com/a/21532941
type: AnsweredQuestion
tagged with: java
downvote count: 2
type: Question
accepted answer: http://stackoverflow.com/a/21533048
score: -2
has answer: http://stackoverflow.com/a/21532941
has answer: http://stackoverflow.com/a/21533048
answer count: 3
has body: Ok so i'm starting to learn Android and i cant append or set the text of the TextView.. i always get a NullPointerException.. anyone help me out? Field variables public TextView t = null; public Button b = null; My onCreate method protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); t = (TextView)findViewById(R.id.textView1); b = (Button)findViewById(R.id.dummy_button); //t.append("hello again"); setContentView(R.layout.activity_fullscreen); final View controlsView = findViewById(R.id.fullscreen_content_controls); final View contentView = findViewById(R.id.fullscreen_content); // Set up an instance of SystemUiHider to control the system UI for // this activity. mSystemUiHider = SystemUiHider.getInstance(this, contentView, HIDER_FLAGS); mSystemUiHider.setup(); mSystemUiHider .setOnVisibilityChangeListener(new SystemUiHider.OnVisibilityChangeListener() { // Cached values. int mControlsHeight; int mShortAnimTime; @Override @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) public void onVisibilityChange(boolean visible) { if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB_MR2) { // If the ViewPropertyAnimator API is available // (Honeycomb MR2 and later), use it to animate the // in-layout UI controls at the bottom of the // screen. if (mControlsHeight == 0) { mControlsHeight = controlsView.getHeight(); } if (mShortAnimTime == 0) { mShortAnimTime = getResources().getInteger( android.R.integer.config_shortAnimTime); } controlsView .animate() .translationY(visible ? 0 : mControlsHeight) .setDuration(mShortAnimTime); } else { // If the ViewPropertyAnimator APIs aren't // available, simply show or hide the in-layout UI // controls. controlsView.setVisibility(visible ? View.VISIBLE : View.GONE); } if (visible &amp;&amp; AUTO_HIDE) { // Schedule a hide(). delayedHide(AUTO_HIDE_DELAY_MILLIS); } } }); The listener i decided to put the append in.. contentView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(…

http://stackoverflow.com/comment/32744054
has text: Thanks for the details and suggestions. I will keep the settings as it is now.
type: Comment
comment on: http://stackoverflow.com/a/21661581
type: AnswerComment
score: 0

http://stackoverflow.com/q/21632736
answer count: 1
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/21633569
has body: I have written a simple scala swing application, with a text field and a button. Whenever user clicks on the button, the content gets copied to the clipboard. But, as soon as the application is closed, the clipboard content is lost. Why ? Is there a way to get around this ? This is my source code : package com.loloof64.scalatest import java.awt.Dimension import java.awt.Toolkit import java.awt.datatransfer.Clipboard import java.awt.datatransfer.StringSelection import java.awt.datatransfer.Transferable import scala.swing.BoxPanel import scala.swing.Button import scala.swing.MainFrame import scala.swing.SimpleSwingApplication import scala.swing.TextField import scala.swing.Orientation import scala.swing.event.ButtonClicked object ClipboardCopyTest extends SimpleSwingApplication { def writeToClipboard(str:String) { val clipboard:Clipboard = Toolkit.getDefaultToolkit().getSystemClipboard() val transferData:Transferable = new StringSelection(str) clipboard.setContents(transferData, null) } override def top = new MainFrame { val textfield = new TextField(60) val button = new Button("Copy to clipboard") contents = new BoxPanel(Orientation.Vertical){ contents += (textfield, button) listenTo(button) reactions += { case _:ButtonClicked =&gt; writeToClipboard(textfield.text) } } val prefSize = new Dimension(300,200) override def size = prefSize } } helps are welcome i am under ubuntu 13.10 64 bits and I have scala 2.10.3
score: 2
upvote count: 2
tagged with: scala
linked to: http://stackoverflow.com/q/14242719
tagged with: swing
type: Question
type: AnsweredQuestion
tagged with: java
has title: Copied data to clipboard get lost whenever I close the frame
has answer: http://stackoverflow.com/a/21633569

http://stackoverflow.com/a/21598851
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/32688975
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/21575692
has body: Try including org.glassfish.extras glassfish-embedded-all 3.0 provided this dependency in your pom.xml

http://stackoverflow.com/a/21557098
answers question: http://stackoverflow.com/q/21556993
score: 9
upvote count: 9
has comment: http://stackoverflow.com/comment/32561118
downvote count: 0
has body: They work the same way, whether there is a recursive statement in there or not. In your expression: (subTree(t1.left, t2) || subTree(t1.right, t2)) if the first call to subTree(t1.left, t2) evaluates to true, the second expression won't be called or attempted to be evaluated. This is just the standard short-circuit behaviour of the || and &amp;&amp; operators and is how the operators work with any arguments given to them.
type: Answer

http://stackoverflow.com/a/21796254
type: Answer
answers question: http://stackoverflow.com/q/21574142
score: 0
has body: I had a similar problem while installing soprano from Macports. I think you have to install the command-line tool from Xcode. Use the terminal and "xcode-select --install" (w/o quotation marks). This worked fine for me. I hope this is helpful for you, too.

http://stackoverflow.com/a/21530544
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32511109
accepted answer of: http://stackoverflow.com/q/21530482
has comment: http://stackoverflow.com/comment/32510693
type: Answer
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/32514155
has body: container.setLayout(new GridLayout(0,1)); container.add(matricepc); container.add(matrice); EDIT: This ´GridLayout´ constructor expects two parameters: The first one is the number of rows, and the second one is the number of columns. When either of them is 0, then the respective number will be chosen based on the other one, and the number of components that are added. In this example: You specify that you want 1 column (and the number of rows does not matter - but since you add 2 components, the number of rows will be 2 - thus, you could also have written new GridLayout(2, 1). EDIT2: Not really related to the original question, but more or less a general hint: Don't underestimate the power of nesting in order to achieve a particular layout. In this case, you can give A BorderLayout to the main container (the content pane) A GridLayout to a new panel that only contains the matrix-panels and put the 'panelForMatrices' into the main container: container.setLayout(new BorderLayout()); JPanel panelForMatrices = new JPanel(new GridLayout(0,1)); panelForMatrices.add(matricepc); panelForMatrices.add(matrice); container.add(panelForMatrices, BorderLayout.CENTER); JPanel lateralPanel = ... container.add(lateralPanel, BorderLayout.EAST);
upvote count: 2
answers question: http://stackoverflow.com/q/21530482

http://stackoverflow.com/q/21658622
has comment: http://stackoverflow.com/comment/32735779
score: 2
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32735911
downvote count: 0
tagged with: java
has comment: http://stackoverflow.com/comment/32735893
has comment: http://stackoverflow.com/comment/32735813
has comment: http://stackoverflow.com/comment/32736177
has comment: http://stackoverflow.com/comment/32735634
type: Question
has body: I have a question regarding generic types in Java. Specifically, at present, I have some code similar to this: public interface Foo { public &lt;T&gt; void bar(T[] list) } public class FooImpl implements Foo{ @Override public &lt;T extends Comparable&lt;? super T&gt;&gt; void bar(T[] list) { ... } } The problem is, that the compiler now complaints, that I have not implemented the bar-method in my FooImpl class. What I want is to put some extra restriction on the generic type, specifically that they should be comparable. But I don't want to put that restriction in my Foo interface, as all implementations does not need that restriction. Is this possible, and what should I do to fix it? Thanks a lot in advance! EDIT 1: Fixed typos Class --> class and Interface --> interface. But the return types are still void, not T, which is irrelevant, I suppose. My actual return type is a boolean. EDIT 2: The actual code, as requested: public interface SortedCriteria { public &lt;E&gt; boolean isSorted(E[] list); } public class AscendingCriteria implements SortedCriteria { @Override public &lt;E extends Comparable&lt;? super E&gt;&gt; boolean isSorted(E[] list) { int length = list.length; for (int i = 1; i &lt; length; i++) { if (list[i].compareTo(list[i-1]) &lt; 0) return false; } return true; } }
tagged with: subtyping
accepted answer: http://stackoverflow.com/a/21658815
upvote count: 2
has comment: http://stackoverflow.com/comment/32735669
answer count: 1
tagged with: generics
has answer: http://stackoverflow.com/a/21658815
favorite count: 0
has title: Java: Specifying generic type restrictions in a subtype

http://stackoverflow.com/q/21622419
score: 2
has comment: http://stackoverflow.com/comment/32680529
tagged with: bar-chart
downvote count: 0
answer count: 1
has answer: http://stackoverflow.com/a/22065514
linked to: http://stackoverflow.com/q/17115106
favorite count: 0
has title: How to show Multiple data series in jfree chart
upvote count: 2
accepted answer: http://stackoverflow.com/a/22065514
has comment: http://stackoverflow.com/comment/32700364
tagged with: swing
has comment: http://stackoverflow.com/comment/32680024
type: Question
type: AnsweredQuestion
tagged with: java
linked to: http://stackoverflow.com/q/2780493
tagged with: jfreechart
has comment: http://stackoverflow.com/comment/32672504
has body: I want to add multiple datasets in one row. How we can do this with Jfree chart? so that my output comes with multiple color codes in single row of BAR graph public class Demo { public static void main(String arg[]){ DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(2, "Amu-referet Form", "Dtest"); dataset.setValue(7, "ApraisalForm", "Richa Dept"); dataset.setValue(4, "Feedback", "Test department"); dataset.setValue(12, "HES report", "Vipul HR dept"); dataset.setValue(6, "Marks", "Chandan"); JFreeChart chart = ChartFactory.createBarChart3D("Any title", "x label", "y label", dataset, PlotOrientation.HORIZONTAL, true, true, true); ChartFrame frame1=new ChartFrame("Bar Chart",chart); frame1.setVisible(true); frame1.setSize(400,350); } }
tagged with: jasper-reports

http://stackoverflow.com/comment/32521260
type: Comment
comment on: http://stackoverflow.com/a/21536460
type: AnswerComment
has text: There's other special case checking that can be done, like null checks, what if old name and new name are the same, etc.
score: 0

http://stackoverflow.com/comment/32497646
type: Comment
comment on: http://stackoverflow.com/a/21522953
score: 0
type: AnswerComment
has text: Ah!! i did not see aaron's update last time. I got the answer. But what do you mean ascii tools? eclipse is able to provide yen symbol, so you mean eclipe is more than ascii tool?

http://stackoverflow.com/q/21677949
tagged with: google-calendar-api
upvote count: 1
has comment: http://stackoverflow.com/comment/32805045
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/21697897
type: Question
downvote count: 0
has comment: http://stackoverflow.com/comment/32769243
tagged with: android
accepted answer: http://stackoverflow.com/a/21697897
answer count: 1
score: 1
favorite count: 0
linked to: http://stackoverflow.com/q/5883938
has body: I'm trying to build a simple example application that counts the number of events on a specific calendar (I know the CALENDAR_DISPLAY_NAME of the Calendar) for today only. I believe I need to query todays events with CalendarContract, and then count the number of rows in the cursor? Is that correct? What would be the minimal, most efficient way to do the query on the single calendar, and have it return only the minimal possible set of data (event id only?) ?
has title: How to count the number of events on a specific calendar for today only?

http://stackoverflow.com/a/21665955
accepted answer of: http://stackoverflow.com/q/21665862
answers question: http://stackoverflow.com/q/21665862
type: AcceptedAnswer
upvote count: 5
type: Answer
has body: If you are looking to integrate the public Google Calendar (www.google.com/calendar) with your Android Application, you have to use the Google Calendar API. The easiest method would be download the Google Calendar Client Library from here and then use the API Reference here. In the Client Library Page, you want to download "Google APIs Client Library for Java (rc)" package to integrate into your Android App. You will first need to go to API Console to create an App with Calendar API Access . If you do not want to use the native library, you can even do it using REST API (use HTTP GET &amp; POST Commands), example App here Hope this helps.
downvote count: 0
has comment: http://stackoverflow.com/comment/32749165
has comment: http://stackoverflow.com/comment/54045326
score: 5

http://stackoverflow.com/q/21607842
tagged with: criteria-api
has title: How best to model Hibernate Criteria Query
type: Question
tagged with: java
tagged with: hibernate
has answer: http://stackoverflow.com/a/21613953
has body: I have a pseudo sql query which looks like this: from TableA as a join fetch TableB as b WHERE (a.id, a.revision) IN ( SELECT id, MAX (revision) FROM TableA GROUP BY id) and (b.id, b.revision) IN ( SELECT id, MAX (revision) FROM TableB GROUP BY id); and I would like to use the hibernate criteria api to do the same. I have a solution but it has a weakness: final Criteria criteria = getSession().createCriteria(TableA.class, "a"); criteria.setFetchMode("btables", FetchMode.JOIN); //$NON-NLS-1$ criteria.add(Restrictions.sqlRestriction("({alias}.id, {alias}.revision) IN ( SELECT id, MAX (revision) FROM TableA GROUP BY id)")); Criteria bSubCriteria = criteria.createCriteria("a.btables", "b"); bSubCriteria.add(Restrictions.sqlRestriction("({alias}.id, {alias}.revision) IN ( SELECT id, MAX (revision) FROM TableB GROUP BY id)")); My problem with the solution is that I have to explicitly name the table in the sql restriction. Does anyone have a better way I could model this, without injecting any sql, or by getting Hibernate to resolve the name of the table?
score: 0
tagged with: sql
answer count: 1
accepted answer: http://stackoverflow.com/a/21613953
linked to: http://stackoverflow.com/q/634342
type: AnsweredQuestion

http://stackoverflow.com/a/21659000
answers question: http://stackoverflow.com/q/21657886
has comment: http://stackoverflow.com/comment/32740235
has comment: http://stackoverflow.com/comment/32736785
has comment: http://stackoverflow.com/comment/32736771
type: Answer
has body: You can use one jPanel.Override paint or paintComponent method and draw your picture with graphic object. public class MyCustomPanel extends JPanel{ private Image img; public MyCustomPanel(// use constructor to get img or load it directly from below){ //load image } public void paintComponent(Graphics g) { super.paintComponent(g); // Draws the img to the BackgroundPanel. g.drawImage(img, 0, 0, this); } } Then you can go to your main class and use this JPanel MyCustomPanel mcp=new MyCustomPanel(//img path); mcp.add(new JLabel("Hello"),BorderLayout.CENTER); add(mcp),BorderLayout.CENTER); //etc I hope you understand Next time post some code if you want to have answr faster and more complex/better suited for your case.
score: 0
has comment: http://stackoverflow.com/comment/32737351

http://stackoverflow.com/q/21667484
tagged with: android
answer count: 0
type: UnansweredQuestion
tagged with: android-actionbar
upvote count: 1
has comment: http://stackoverflow.com/comment/33578913
type: Question
has comment: http://stackoverflow.com/comment/33578886
has comment: http://stackoverflow.com/comment/32755992
has body: My overflow menu show "cale" instead of "calendar" as following image: I have add the menu as following: &lt;menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"&gt; &lt;item android:id="@+id/action_calendar" android:icon="@drawable/ic_action_go_to_today" app:showAsAction="never" android:title="@string/calendar" android:showAsAction="never" /&gt; &lt;item android:id="@+id/action_help" android:orderInCategory="100" app:showAsAction="never" android:showAsAction="never" android:icon="@drawable/ic_action_help" android:title="Help"/&gt; &lt;item android:id="@+id/action_refresh" android:orderInCategory="100" app:showAsAction="never" android:showAsAction="never" android:icon="@drawable/ic_action_refresh" android:title="Check for Updates"/&gt; &lt;/menu&gt; The activity public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_activity, menu); return super.onCreateOptionsMenu(menu); } Could anyone tell us what is wrong with my code ? I think the top left point of the overflow menu rect was incorrect. I have try some example on action bar. It all show the correct as following: Hi sorry I have found the problem is caused by setting android:anyDensity="false" on manifest. Action bar menu shows off screen Thank you!
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32753829
has comment: http://stackoverflow.com/comment/32754689
linked to: http://stackoverflow.com/q/10257565
downvote count: 0
tagged with: android-menu
has comment: http://stackoverflow.com/comment/33578863
favorite count: 0
has title: Android Action bar overflow menu not show correctly

http://stackoverflow.com/a/21662890
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21661583
type: Answer
accepted answer of: http://stackoverflow.com/q/21661583
has body: One of the SwingUtilities.convertPoint() methods should do what you want. The following example prints java.awt.Point[x=54,y=22]. JFrame f = new JFrame("Test"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new JLabel("Test"), BorderLayout.WEST); JButton b = new JButton("Test"); f.add(b); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); System.out.println(SwingUtilities.convertPoint(b, b.getX(), b.getY(), f));
has comment: http://stackoverflow.com/comment/58206710
score: 9
upvote count: 9

http://stackoverflow.com/comment/32560757
comment on: http://stackoverflow.com/a/21558616
has text: Oh and it looks like it is not calling the `hasCode()` and `equals()` methods according to my debugger.
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/32716772
score: 3
comment on: http://stackoverflow.com/q/21647785
type: Comment
has text: Please show us, by showing us how in the code or configuration you did that, what you mean by "the servlet is mapped to the JSP", and "the JSP is mapped to the servlet". A foward is not a redirect. A redirect is not a forward. Currently, in the code you posted, you get a redirect loop because the servlet redirects to itself.
type: QuestionComment

http://stackoverflow.com/q/21641565
has body: for (int i = 0; i &lt; str.length(); i ++) // Checks every position of array { arr[i] = str.charAt(i); // Ignore this, not needed if (arr[i] != ',' || arr[i] != '.' || arr[i] != '$') // Checks every position of array to see if any character equals a comma, decimal point, or a dollar sign { // Ignore below /* valueString = String.valueOf(value); numOfAsterisks = arr.length - valueString.length(); for (int asterisk = 0; asterisk &lt;= numOfAsterisks; asterisk ++) { System.out.print("*"); } System.out.println((int)value); */ } } Here, what I want to do is to check an array of characters and see if the array contains a comma, a decimal point, or a dollar sign. If the array does not contain any of these characters, then the commented-out portion (where it says "Ignore below") will be executed. The only problem I have here is that because if (arr[i] != ',' || arr[i] != '.' || arr[i] != '$') is under the outside for loop, the commented-out part is executed multiple times. I need the code to execute only once, but still check each position of the array.
favorite count: 0
score: -1
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/21641594
downvote count: 1
type: Question
upvote count: 0
has title: Using a for loop to search an array
accepted answer: http://stackoverflow.com/a/21641594
answer count: 1

http://stackoverflow.com/comment/32593209
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21573278
has text: @goroncy you can check http://stackoverflow.com/questions/21569601/hibernate-criteria-for-getting-details-based-on-keys-no
score: 0

http://stackoverflow.com/comment/126361011
type: Comment
comment on: http://stackoverflow.com/a/21590120
score: 0
type: AnswerComment
has text: Awesome answer. Finally I understand the difference between parent and aggregator. Thank you!

http://stackoverflow.com/comment/32748309
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21665386
has text: Here is something odd, when I delete the time.log file from the directory, the FileNotFoundException does not get thrown. I was expecting it to fail when outputStream was instanciated and it didn't...

http://stackoverflow.com/comment/32721585
score: 4
comment on: http://stackoverflow.com/a/21650266
type: AnswerComment
type: Comment
has text: 'Of course, if you have more threads than cores' - you mean 'Of course, if you have more READY threads than cores'.

http://stackoverflow.com/comment/32573260
has text: I'm not looking for import, as I already said xD
type: AnswerComment
type: Comment
score: 1
comment on: http://stackoverflow.com/a/21565767

http://stackoverflow.com/comment/32577662
has text: :) Glad the question helped!
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21558054
score: 0

http://stackoverflow.com/comment/32649219
has text: @halex Yes, I actually missed that in my examples!
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21609183
type: AnswerComment

http://stackoverflow.com/comment/32677642
type: QuestionComment
comment on: http://stackoverflow.com/q/21625561
score: 0
has text: @assylias - I donno how I missed that.. thanks :)
type: Comment

http://stackoverflow.com/a/21529481
downvote count: 0
has comment: http://stackoverflow.com/comment/91342638
has body: The javadoc of BufferedReader.readLine() states: Read a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed. If the card doesn't send some kind of end of line, this method will never return. Try to read directyl from clientSocket.getInputStream(). This doesn't do any buffering.
answers question: http://stackoverflow.com/q/21529030
score: 4
has comment: http://stackoverflow.com/comment/32509012
type: Answer
upvote count: 4

http://stackoverflow.com/a/23492127
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/36934212
score: 1
has body: Try the SingleColumnValueFilter instead: https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/filter/SingleColumnValueFilter.html
upvote count: 1
answers question: http://stackoverflow.com/q/21636787

http://stackoverflow.com/comment/32605519
type: AnswerComment
comment on: http://stackoverflow.com/a/21584070
type: Comment
has text: This worked! Thanks for the help!! So can "==" operator only be used for integers and booleans?? Is it because strings are objects, and not primitives?? thanks! :)
score: 0

http://stackoverflow.com/a/21643791
score: 0
has body: public static void main( final String[] args ) { EmbeddedNeo4j hello = new EmbeddedNeo4j(); hello.createDb(); hello.removeData(); hello.shutDown(); } You are creating DB then calling removeData.
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/21643144
answers question: http://stackoverflow.com/q/21643144

http://stackoverflow.com/q/21641172
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21650243
has title: How to convert user inputted char to its numerical position in Java?
tagged with: java
has body: So I'm stuck on this problem in my Java intro class. I'm a complete newbie at this stuff, so any help is appreciated. I have to design and create a program that accepts a user inputted letter (which should be either a-z or A-Z) and determine what position it holds in the alphabet. (so a would equal 0) I keep having issues with string to char and char to int conversions. Any tips or leads on how to design this program would be much appreciated. I've been working on this program literally all day and haven't had made any discernible progress.
linked to: http://stackoverflow.com/q/2564541
linked to: http://stackoverflow.com/q/8879714
type: Question
has comment: http://stackoverflow.com/comment/32706636
has answer: http://stackoverflow.com/a/21641211
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/21650686
duplicate of: http://stackoverflow.com/q/2564541

http://stackoverflow.com/comment/32565088
has text: @HotLicks Please see Edit 2 above for more code information on how 366 is being derived. Does this clarify?
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/21558975

http://stackoverflow.com/a/21643665
answers question: http://stackoverflow.com/q/21621313
has body: Option #1 All java solution, no apache required, only servlet container like Tomcat. If you remember the spec, you need to define mapping in web.xml, so once your code get executed it's too late to change anything about incoming request URL, mapping has already happened. Suboption a: You don't use any MVC frameworks like Spring or Struts. Put your code into interceptor filter and issue an http redirect according to your rules. It has a drawback of additional http request i.e. increased latency Suboption b: If you do use some MVC engine, it already route all requests via some single marshaling servlet which decides about which filters and servlest to call. Extend this logic to inject your rewrite rules. This solution has best possible latency but non transferable between MVC engines. Option #2 (which I'd probably implement first) Have a cron job, that reads your rules from DB, forms a new .htaccess file and puts it into the appropriate folder. You don't need to restart Apache, it will read it on every request. Yes it will be a bit slower, but I bet you would not notice it anyway and dev cost is like ~1h at most.
score: 0
type: Answer

http://stackoverflow.com/a/21586979
type: Answer
answers question: http://stackoverflow.com/q/21586765
has comment: http://stackoverflow.com/comment/32647790
score: 0
has body: In the second class, after the second line in the constructor, have you tried? add(panel2); See if this works.
has comment: http://stackoverflow.com/comment/32611242
has comment: http://stackoverflow.com/comment/32611640
has comment: http://stackoverflow.com/comment/32611373

http://stackoverflow.com/a/21641892
has body: Unless I'm misinterprinting the quesiton, sounds like you want to read [0-9] multiple times. Safest/best way I can think of would be to scan it as an int (so it parses out extrenous text), convert to string, parse, then convert back the seperate integers. e.g. Scanner guess = new Scanner(System.in); int[] array = new int[3]; System.out.println("Enter 3 numbers from 0 to 9"); if (guess.hasNextInt()) { String g = guss.nextInt().toString().; int max = g.length() &gt; 2 ? 3 : g.length(); for(int i = 0; i &lt; max; i++) { array[i] = Character.getNumericValue(g.charAt(i)); } } else { //bad guess } If you expect that user will instead enter it as something like 1 2 3, you can put it in a while loop until you get at least 3 items in your array.
type: Answer
answers question: http://stackoverflow.com/q/21641716
score: 0

http://stackoverflow.com/a/21568622
score: 1
has body: In the nested for loop, you start j at prime. However, consider the prime 2: it is at index 0, not index 2. Things should work out if you start j at prime-first. Also, as a commenter pointed out, your print loop should start at index 0 rather than first.
upvote count: 1
type: AcceptedAnswer
type: Answer
answers question: http://stackoverflow.com/q/21568476
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21568476

http://stackoverflow.com/q/21676785
type: AnsweredQuestion
type: Question
has body: Simple code no problem long x = Integer.MAX_VALUE; System.out.println(x * 2 + "...." + Long.MAX_VALUE); = 4294967294....9223372036854775807 but what is happening here? why -2 System.out.println(2 * Integer.MAX_VALUE + "...." + Long.MAX_VALUE); = -2....9223372036854775807 and why elements is 149998, doesn't the compiler converts these to long? long elements = 2 * Integer.MAX_VALUE + 150000; System.out.println(elements + "...." + Long.MAX_VALUE); 149998....9223372036854775807 -thanks
has answer: http://stackoverflow.com/a/21676909
has title: Simple Java integer and long arithmetics
has comment: http://stackoverflow.com/comment/32768645
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/32767148
possible better answer: http://stackoverflow.com/a/21676842
accepted answer: http://stackoverflow.com/a/21676909
has answer: http://stackoverflow.com/a/21676842
has answer: http://stackoverflow.com/a/21690757
tagged with: long-integer
has answer: http://stackoverflow.com/a/21676944
tagged with: int
answer count: 4

http://stackoverflow.com/comment/32635720
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21601407
has text: @sᴜʀᴇsʜᴀᴛᴛᴀ one more question. Can I deploy my GWT application using devMode? I mean I don't want complicated web server applications. What I want is to package the whole thing together with the execution script like `javaw gwt-dev-mode myapplication` and send to my friend. so he can directly execute and run the application on his pc. can I do that?

http://stackoverflow.com/q/21563040
upvote count: 1
tagged with: methods
type: Question
tagged with: for-loop
has body: Trying to write a method to tell me if a number is in an array or not. So far I have.. public static boolean inList(double number, double[] list){ for (double i : list) { if (i == number){ return false; } } return true; //if its not in the array I want the if statement to run. } So far this hasn't worked for me, for some reason it can't identify when some numbers are in the array or not.
tagged with: if-statement
tagged with: boolean
has title: How to find if a number is in an array?
has answer: http://stackoverflow.com/a/21563231
downvote count: 0
has comment: http://stackoverflow.com/comment/32567848
score: 1
has answer: http://stackoverflow.com/a/21563082
favorite count: 0
has answer: http://stackoverflow.com/a/21563085
type: UnansweredQuestion
answer count: 4
has answer: http://stackoverflow.com/a/21563390
tagged with: java
has comment: http://stackoverflow.com/comment/32567955

http://stackoverflow.com/a/21611565
has comment: http://stackoverflow.com/comment/32653309
has comment: http://stackoverflow.com/comment/32653252
answers question: http://stackoverflow.com/q/21611458
has body: Read in the xml to main memory, and do the search there. If there are only String referecnes then introduce an own integer reference. And initialize that once. That way you should be very fast, much faster than any database.
score: 0
type: Answer

http://stackoverflow.com/comment/32764447
comment on: http://stackoverflow.com/q/21674111
type: QuestionComment
type: Comment
has text: see http://stackoverflow.com/questions/5101739/android-listview-with-complex-header
score: 0

http://stackoverflow.com/comment/32722786
has text: How would one debug the issue if the return value turned out to be false? In my case, when my files weren't being deleted, it was because all of the library calls I was using did not close their files after they were done with it! It looks like at least the files are being closed here. But I'm assuming OP did not post the complete code so there's a try/catch somewhere and that message should explain what's going on.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21650682
type: AnswerComment

http://stackoverflow.com/comment/32706092
type: Comment
has text: you're right, just edited, didn't think it was really relevant, he might as well simply implement his own Pair class
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21640499

http://stackoverflow.com/a/21668595
score: 2
has body: You're shadowing the variable play1. Replace Character play1 = new Athlete("Ellisaville", "President"); with play1 = new Athlete("Ellisaville", "President"); The same applys to play2
upvote count: 2
answers question: http://stackoverflow.com/q/21668567
downvote count: 0
type: Answer

http://stackoverflow.com/q/21572021
type: Question
linked to: http://stackoverflow.com/q/9554636
answer count: 1
score: 0
accepted answer: http://stackoverflow.com/a/21602837
has body: By clicking on the button opens a new frame and until it is fully loaded (including execute a query in the database) I can not continue to work in the initial JFrame. (edit fields). How to organize the opening frame (in the background, apparently) without losing focus and editing capabilities?
has comment: http://stackoverflow.com/comment/32584081
tagged with: event-dispatch-thread
has answer: http://stackoverflow.com/a/21602837
tagged with: jframe
has comment: http://stackoverflow.com/comment/32587531
tagged with: swing
has comment: http://stackoverflow.com/comment/32586177
has comment: http://stackoverflow.com/comment/32586651
has title: How to open a new JFrame without losing focus and editing?
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/comment/32753006
score: 0
type: Comment
has text: Yes, "ASC" and "CENT" are String ticker symbols.
comment on: http://stackoverflow.com/a/21665916
type: AnswerComment

http://stackoverflow.com/comment/32601910
type: Comment
score: 1
has text: @AngeloUknown Unless you really need more precision than double allows, which is unusual for calculations involving physically measured quantities, you would be better off just working in double with infix operators.
type: AnswerComment
comment on: http://stackoverflow.com/a/21578934

http://stackoverflow.com/q/21673894
tagged with: java
has body: I am having the spring configuration to read the files from ftp location as below. &lt;bean id="fileReader" class="org.springframework.batch.item.file.FlatFileItemReader"&gt; &lt;property name="resource" value="ftp://FTPADMINTEST:12456@ftp.mycompany.net/IT/SE/box/dev/downloaded/CHI-20863.csv"/&gt; ------------- using above configuration i could read files.But recently we created mount point for this location to access directly these files. Created mount point for this location is /BOX/DEV. Now i am trying to access same using the below configuration using the mount pint path. &lt;bean id="fileReader" class="org.springframework.batch.item.file.FlatFileItemReader"&gt; &lt;property name="resource" value="file://BOX/DEV/CHI-20863.csv"/&gt; But could not read files and getting the exception: Input resource does not exist class path resource [/BOX/DEV/CHI-20863.csv] Plese suggest me how to configure to use files using mount point location.
type: Question
tagged with: mount-point
tagged with: spring-batch-admin
tagged with: spring-batch
upvote count: 2
answer count: 1
downvote count: 0
tagged with: unix
favorite count: 0
type: UnansweredQuestion
has title: Spring batch: How to read files from mount point created in UNIX server location directly?
has answer: http://stackoverflow.com/a/23018575
score: 2
has comment: http://stackoverflow.com/comment/34616214

http://stackoverflow.com/q/21549551
has answer: http://stackoverflow.com/a/21549867
has comment: http://stackoverflow.com/comment/32545000
favorite count: 0
linked to: http://stackoverflow.com/q/13649703
has comment: http://stackoverflow.com/comment/32543241
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21549669
score: 3
upvote count: 3
tagged with: java
has comment: http://stackoverflow.com/comment/32543293
type: Question
has body: Golden ratio is a special ratio which can be related to ratio between different dimensions of parts of a living organism. Mathematically, it can be found by the following formula : (1+sq.root(5))/2) By using any kind of data-type I couldn't store such a value. double is the best, but I can't get 20 decimal places using it. So, I thought, if I can find the last digits of the ratio after calculating it, and then store it in some variable and go on doing this. In the end I could have made it complete by joining the decimal places one after the other. example : from 1.61083, I would extract 3,0,8,0,1,6 and join it. Still I'm having problems since even during calculation it does not use such an accurate variable. Can somebody help ?
downvote count: 0
has answer: http://stackoverflow.com/a/21549810
tagged with: decimal
answer count: 3
has title: Finding the golden ratio accurately till 20 decimal places
has answer: http://stackoverflow.com/a/21549669
possible better answer: http://stackoverflow.com/a/21549810
tagged with: calculator

http://stackoverflow.com/a/78230217
downvote count: 1
answers question: http://stackoverflow.com/q/21641398
type: Answer
upvote count: 0
has body: I followed these steps for adding the path to a .jar file in intelliJ: Go to File->Prject Structure->SDKs Select Classpath tab Select Your SDK (probably first in a list) Click "+" icon and add your .jar And this was no longer need to add some code like, all works properly try{ Class.forName("org.sqlite.JDBC"); } catch (Exception e){ ... } I think the problem was caused by problems in jar registration, not by lazy package load
score: -1

http://stackoverflow.com/comment/32722191
comment on: http://stackoverflow.com/a/21650789
type: AnswerComment
score: 0
type: Comment
has text: Using the same you have used. I mean, the `switch` will be the same, you have to see what you will need to change and what not.

http://stackoverflow.com/q/21656311
has comment: http://stackoverflow.com/comment/32732378
has comment: http://stackoverflow.com/comment/32732000
type: UnansweredQuestion
has title: how to get value from two table in mysql with from one table distinct and from other table multiple value?
tagged with: java
tagged with: mysql
type: Question
has body: i have two table in database like: table_one with fields like: class , day_of_week and id(pk); table_two with fields like: id(fk) , subjects and what i tried is: select distinct day_of_week ,subjects from table_one as tbl_one ,table_two as tbl_two where tbl_one.id =tbl_two.id and class_name='One'[?]; and my result comes out for my report like: day of week: ** ** subjects Sunday A Sunday B Monday A Monday B but it should come like this: day of week subjects Sunday A B Monday A B
has comment: http://stackoverflow.com/comment/32732727
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/21657105

http://stackoverflow.com/q/21557943
tagged with: javafx-2
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/21567350
answer count: 1
downvote count: 0
has body: I'm trying to make a combo box table cell in a table in JavaFX. I have used a string converter so that false displays "No" and true displays "Yes" in the table, and this is working. However, when I click on the cell to edit it, the combo box still shows "false" and "true", as seen below: I am setting up my table cell like this: colPossibleDischarge.setCellValueFactory(new PropertyValueFactory&lt;RoomProperty, Boolean&gt;("discharge")); colPossibleDischarge.setCellFactory(new Callback&lt;TableColumn&lt;RoomProperty, Boolean&gt;, TableCell&lt;RoomProperty, Boolean&gt;&gt;() { @Override public TableCell&lt;RoomProperty, Boolean&gt; call(TableColumn&lt;RoomProperty, Boolean&gt; roomPropertyBooleanTableColumn) { return new ComboBoxTableCell&lt;RoomProperty, Boolean&gt;(new YesNoStringConverter(),true,false); } }); and my string converter looks like this: public class YesNoStringConverter extends StringConverter&lt;Boolean&gt; { @Override public String toString(Boolean bool) { return (bool?"Yes":"No"); } @Override public Boolean fromString(String s) { return s.equalsIgnoreCase("yes"); } } What am I doing wrong?
favorite count: 0
has title: JavaFX StringConverter not applying to combo box
accepted answer: http://stackoverflow.com/a/21567350
tagged with: combobox

http://stackoverflow.com/q/21555411
upvote count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/32559475
favorite count: 0
type: UnansweredQuestion
answer count: 0
score: 1
tagged with: java
tagged with: javadoc
has body: I have found a number of tutorials showing how to write your own doclet, such as http://www.developer.com/java/other/article.phpr/3085991/Javadoc-Programming.htm (about 2/3 down the page) http://www.zdnet.com/customize-javadoc-output-with-doclets-2039233344/ They tell you to begin with import com.sun.javadoc.Doclet; public class MyDoclet extends Doclet { public static boolean start(RootDoc r_d) { ... and call it with javadoc -doclet my.package.MyDoclet *.java But I don't want to write whole new doclet, I just want to tweak the Standard Doclet (two examples below). It seems that the first step is to duplicate the existing Standard Doclet source code, change the package names from com.sun... to com.mywebsite.doclet..., and then execute it, so the output is exactly the same as the standard doclet. I did find this old tutorial, but the classes and packages it mentions don't exist in the 1.7 JDK (com.sun.javadoc.* is there, but not com.sun.tools.*). Should I just do search-and-replace on the JavaDoc output, and forget about the Standard Doclet altogether? I would appreciate a little guidance. Thank you for any advice. UPDATE: I grepped all source code in the 1.7 JDK, and found no instances of "No Frames" or "overview-summary". So it seems the standard doclet is not there. Two examples of what I am trying to do: Add &lt;meta name="viewport" content="width=device-width" /&gt; to the head of each page, so it can be viewed on mobile devices A few classes in my library have lots of generics, such as ClassName&lt;X extends Something, Y extends SomethingElse&gt;, I want to force the generics to be on a new line: Such as ClassName &lt;X extends Something, Y extends SomethingElse&gt;
type: Question
linked to: http://stackoverflow.com/q/19862735
has title: How to tweak the standard doclet--not write an entirely-new doclet?
has comment: http://stackoverflow.com/comment/32577344
has comment: http://stackoverflow.com/comment/32559868

http://stackoverflow.com/comment/32548061
comment on: http://stackoverflow.com/a/21552306
type: AnswerComment
score: 0
type: Comment
has text: You have to refactor this code to if / else all the time until the time Android starts supporting Java 1.7. No other options are available.

http://stackoverflow.com/a/21603471
score: 0
has body: Integer max2( List&lt;Integer&gt; list ){ if(list.size() &lt; 2) throw... Integer[] max = new Integer[]{ list.get(0), list.get(1) }; if( max[0] &lt; max[1] ){ max[0] = max[1]; max[1] = list.get(0); } return maxdo( list, 2, max ); } Integer maxdo( List&lt;Integer&gt; list, int pos, Integer[] max ){ if( pos &gt;= list.size() ) return max[1]; Integer next = list.get(pos); if( next &gt; max[0] ){ max[1] = max[0]; max[0] = next; } else if( next &gt; max[1] ){ max[1] = next; } return maxdo( list, pos+1, max ); } Not tested, not tried with javac, but I think you'll get the idea.
answers question: http://stackoverflow.com/q/21603176
type: Answer

http://stackoverflow.com/q/21622540
tagged with: spring-mvc
score: 1
tagged with: java
type: Question
tagged with: websphere
has body: getting an error while running in web preview server in eclipse but the same projects runs fine in tomcat. Error [ERROR ] SRVE0293E: [Servlet Error]-[Failed to load listener: org.springframework.web.context.ContextLoaderListener]: java.lang.ClassNotFoundException: org/springframework/web/context/ContextLoaderListener at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:190) at com.sun.beans.finder.ClassFinder.findClass(ClassFinder.java:75) at com.sun.beans.finder.ClassFinder.findClass(ClassFinder.java:110) at java.beans.Beans.instantiate(Beans.java:216) at java.beans.Beans.instantiate(Beans.java:80) at com.ibm.ws.webcontainer.webapp.WebApp.loadListener(WebApp.java:2176) at [internal classes] [ERROR ] SRVE0279E: Error occured while processing global listeners for the application {0}: {1} java.lang.NullPointerException [ERROR ] SRVE8052E: Logging ClassNotFoundException org/springframework/web/servlet/DispatcherServlet [ERROR ] SRVE0276E: Error while initializing Servlet [dispatcher]: javax.servlet.UnavailableException: SRVE0200E: Servlet [org.springframework.web.servlet.DispatcherServlet]: Could not find required class - org/springframework/web/servlet/DispatcherServlet at com.ibm.ws.webcontainer.servlet.ServletWrapper$1.run(ServletWrapper.java:1497) at [internal classes] [ERROR ] SRVE0315E: An execption occurred: com.ibm.ws.webcontainer.webapp.WebAppErrorReport: javax.servlet.UnavailableException: SRVE0200E: Servlet [org.springframework.web.servlet.DispatcherServlet]: Could not find required class - org/springframework/web/servlet/DispatcherServlet at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:486) at [internal classes] Caused by: javax.servlet.UnavailableException: SRVE0200E: Servlet [org.springframework.web.servlet.DispatcherServlet]: Could not find required class - org/springframework/web/servlet/DispatcherServlet ... 3 more
downvote count: 0
has title: Running Maven Spring project in eclipse using Web preview server
answer count: 1
has comment: http://stackoverflow.com/comment/32672380
favorite count: 0
type: UnansweredQuestion
tagged with: maven
upvote count: 1
has answer: http://stackoverflow.com/a/21630338

http://stackoverflow.com/comment/32680339
comment on: http://stackoverflow.com/q/21626979
has text: @BoristheSpider , I do not understand how to store the value ?
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/32699833
type: Comment
comment on: http://stackoverflow.com/a/21637525
has text: No luck. .*? does not match.
type: AnswerComment
score: 0

http://stackoverflow.com/a/21610914
answers question: http://stackoverflow.com/q/21610774
upvote count: 1
type: Answer
downvote count: 0
score: 1
has body: You can't do this automatically with Perforce, but you could easily set up a cron job (or a build job if you have a CI system like Jenkins) to use the p4 integrate command to merge any changes in A into B.

http://stackoverflow.com/q/21565763
has body: I have a JFrame, and whenever I switch from one JFrame using a JButton it starts out normally, but whenever I create a new instance of the first JFrame, the JButton is in an incorrect location and is the wrong size. Example on startup and when another one is created Code: public class Menu extends JFrame implements Runnable { private static final long serialVersionUID = 1L; public static int Number_of_Participants = 0; protected JPanel window = new JPanel(); double p; private JButton Participants; private Rectangle rParticipants; protected int Button_width = 240; protected int Button_height = 48; boolean running = false; Thread thread; JFrame frame = new JFrame(); public Menu() { window.setBackground(Color.BLUE); frame.setSize(new Dimension(800, 600)); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.getContentPane().add(window); frame.setLocationRelativeTo(null); frame.setVisible(true); Image image = null; try { image = ImageIO.read(new File("res/BG.jpg")); } catch (IOException e) { e.printStackTrace(); } generateFiles(); drawButtons(); startMenu(); frame.repaint(); } public void drawButtons() { rParticipants = new Rectangle(520, 12, Button_width, Button_height); Participants = new JButton("A"); Participants.setBounds(rParticipants); window.add(Participants); Participants.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { frame.dispose(); new Participant(Number_of_Participants); } }); } } Participant.java extends Menu.java int Participant_ID; public Participant(int Participant_ID) { super(); this.Participant_ID = Participant_ID; } makes a JButton that goes back to Menu.java
downvote count: 1
has comment: http://stackoverflow.com/comment/32574623
upvote count: 0
has comment: http://stackoverflow.com/comment/32575462
has answer: http://stackoverflow.com/a/21567109
has comment: http://stackoverflow.com/comment/32573640
has comment: http://stackoverflow.com/comment/32573242
has title: JButton changes size
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32573247
answer count: 1
tagged with: user-interface
score: -1
favorite count: 0
type: Question
tagged with: jframe
accepted answer: http://stackoverflow.com/a/21567109
tagged with: swing
has comment: http://stackoverflow.com/comment/32573309
tagged with: java

http://stackoverflow.com/comment/32657075
score: 1
has text: ButtonGroup is not based on Component and therefore can not be added the the UI
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21613411

http://stackoverflow.com/q/21592010
tagged with: java
has answer: http://stackoverflow.com/a/21592218
has body: I am working on getting some of the code within this project to run as a Java Application instead of an Android app: https://code.google.com/p/pandoroid/ I am working on a Pandora client and would like to use the api developed within the project, however it seems to rely on some android dependencies when it comes to the xml parser. can anyone recommend a library that would be compatible with minimum code editing? errors revolve around: import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserFactory; import org.xmlpull.v1.XmlSerializer; (I actually solved these by googling and finding the libraries) and more importantly import android.util.xml; Thanks in advance!
tagged with: pandora
has title: Java xml parser compatible with android
type: Question
answer count: 1
score: 0
tagged with: xml-parsing
tagged with: http://stackoverflow.com/tag/xml
type: UnansweredQuestion
tagged with: android

http://stackoverflow.com/comment/32494307
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21518608
has text: What do you mean by multiple strings = 9000 ? You can make many constants as you want : static final String MAX_VALUE = "9000"; static final String MAX_VALUE2 = "9000"; static final String MAX_VALUE3 = "9000";

http://stackoverflow.com/comment/32676538
comment on: http://stackoverflow.com/q/21623911
score: 0
type: Comment
type: QuestionComment
has text: Thanks Haris, I double checked all those packages from Synaptics. All are installed. Still not seeing that libcxcore.so under /usr/lib

jogl
tag name: jogl
tags question: http://stackoverflow.com/q/21610901
type: Tag

stream
tags question: http://stackoverflow.com/q/21617263
tags question: http://stackoverflow.com/q/21577848
tags question: http://stackoverflow.com/q/21642786
tags question: http://stackoverflow.com/q/21557794
tags question: http://stackoverflow.com/q/21567374
type: Tag
tag name: stream

button
tags question: http://stackoverflow.com/q/21533692
tags question: http://stackoverflow.com/q/21660030
tags question: http://stackoverflow.com/q/21672211
tags question: http://stackoverflow.com/q/21597474
type: Tag
tags question: http://stackoverflow.com/q/21522902
tags question: http://stackoverflow.com/q/21651436
tags question: http://stackoverflow.com/q/21667717
tags question: http://stackoverflow.com/q/21590067
tag name: button

http://stackoverflow.com/q/21646913
has answer: http://stackoverflow.com/a/21647009
possible better answer: http://stackoverflow.com/a/21646979
has answer: http://stackoverflow.com/a/21646979
has comment: http://stackoverflow.com/comment/32715218
has body: I am coding Zombies infect people in a city whereas: 2: There is no person 1: Uninfected people 0: Zombies Zombies will infect all normal people that are around Zombies. Below is my Java program but I am getting the error: StackOverflowError. public class InfectGame { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int a[][] = { { 1, 1, 1, 1, 2, 2, 2, 1, 1, 0 }, { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 2, 1, 1, 2, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1 }, { 1, 1, 1, 1, 0, 1, 1, 1, 2, 1 }, { 2, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 2, 2, 2, 1, 1, 1, 1, 1, 1, 2 }, }; int i = 0; int j = 0; for (i = 0; i &lt; 10; i++) { for (j = 0; j &lt; 10; j++) { if (a[i][j] == 0) { run_test(i, j, a, 0, 10); } } } i = 0; j = 0; for (i = 0; i &lt; 10; i++) { System.out.print("\n"); for (j = 0; j &lt; 10; j++) { System.out.print(a[i][j] + " "); } } } public static void run_test(int x, int y, int a[][], int v, int size) { if ((x &lt; 0) || (x &gt;= size)) return; if ((y &lt; 0) || (y &gt;= size)) return; // System.out.print(a[x][y] + " "); // a[x][y] = v; if (a[x][y] != 2) { a[x][y] = v; if (x + 1 &lt; size) { run_test(x + 1, y, a, v, size); } if (x &gt; 0) { run_test(x - 1, y, a, v, size); } if (y + 1 &lt; size) { run_test(x, y + 1, a, v, size); } if (y &gt; 0) { run_test(x, y - 1, a, v, size); } } } } Exception in thread "main" java.lang.StackOverflowError at InfectGame.run_test(InfectGame.java:55) at InfectGame.run_test(InfectGame.java:58) at InfectGame.run_test(InfectGame.java:55) at InfectGame.run_test(InfectGame.java:58) at InfectGame.run_test(InfectGame.java:55) at InfectGame.run_test(InfectGame.java:58) at InfectGame.run_test(InfectGame.java:55) at InfectGame.run_test(InfectGame.java:58) at InfectGame.run_test(InfectGame.java:55) at InfectGame.run_test(InfectGame.java:58) at InfectGame.run_test(InfectGame.java:55) at InfectGame.ru…
type: AnsweredQuestion
tagged with: recursion
linked to: http://stackoverflow.com/q/214741
tagged with: java
accepted answer: http://stackoverflow.com/a/21647009
has answer: http://stackoverflow.com/a/21647174
type: Question
has title: Recursive function StackOverflowError
has comment: http://stackoverflow.com/comment/57626946
score: 0
answer count: 3
has comment: http://stackoverflow.com/comment/32715172

http://stackoverflow.com/comment/32938601
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21712007
has text: `[INFO] >>> tomcat7-maven-plugin:2.2:run (default-cli) @ ...` but hotswap not working anyway.

http://stackoverflow.com/a/21637161
has comment: http://stackoverflow.com/comment/32702885
score: 4
type: Answer
upvote count: 4
downvote count: 0
has body: Retrofit can't know how you want to join the strings in the path. While commas seem obvious, there's no reason why someone might want pipes (|) or colons (:) or whatever. Because of this fact, we don't do anything and rely on you to choose. There's two solutions to this: Use String as the argument type and join at the call site. For example: foo.getObject(Joiner.on(',').join(things)); Use a custom object whose toString() method deals with returning the correct format for one or many objects.
answers question: http://stackoverflow.com/q/21617792
accepted answer of: http://stackoverflow.com/q/21617792
type: AcceptedAnswer

http://stackoverflow.com/a/21673192
score: 0
has body: Update the code in which while reading the file you will take the decision : int sevenCount = 0; int fourteenCount = 0; int data = 0; while ((data = reader.read()) != -1) { sevenCount++; fourteenCount++; if(sevenCount==7) { buf.append("-"); // append - at every 7th character sevenCount = 0; } if(fourteenCount==14) { buf.append("\n"); // change line after evrry 14th character fourteenCount = 0; } if(((char)data) == '*') { char c = '!'; //Change the code when char contain * data = (int)c; } else { buf.append((char)data); } }
answers question: http://stackoverflow.com/q/21672927
has comment: http://stackoverflow.com/comment/32762479
type: Answer
has comment: http://stackoverflow.com/comment/32764095
has comment: http://stackoverflow.com/comment/32761611
has comment: http://stackoverflow.com/comment/32763067
has comment: http://stackoverflow.com/comment/32761421

http://stackoverflow.com/q/21577265
type: UnansweredQuestion
tagged with: spring
downvote count: 1
type: Question
tagged with: java
tagged with: hibernate
score: -1
has answer: http://stackoverflow.com/a/21578627
answer count: 2
upvote count: 0
tagged with: jpa
favorite count: 0
has title: Getting error on a simple query
tagged with: hibernate-mapping
has body: I am trying to learn JPA with hibernate provider. below is the query which I am trying to fire: Query query=eManager.createQuery("from ShopBaseData"); List list=query.getResultList(); I am getting below error when I am trying to execute the code: Caused by: java.sql.SQLException: Fail to convert to internal representation at oracle.jdbc.driver.CharCommonAccessor.getBigDecimal(CharCommonAccessor.java:414)[:11.2.0.3.0] at oracle.jdbc.driver.OracleResultSetImpl.getBigDecimal(OracleResultSetImpl.java:548)[:11.2.0.3.0] at oracle.jdbc.driver.OracleResultSet.getBigDecimal(OracleResultSet.java:372)[:11.2.0.3.0] at org.hibernate.type.descriptor.sql.DecimalTypeDescriptor$2.doExtract(DecimalTypeDescriptor.java:67) at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:65) at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:261) Can someone please help me to understand what can be the possible cause of error?
has answer: http://stackoverflow.com/a/21577351

http://stackoverflow.com/q/21578476
has answer: http://stackoverflow.com/a/21578499
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21578592
tagged with: java
tagged with: ontouchlistener
has body: I am creating a game that requires a SurfaceView to implement OnTouchListener. During the game I want to pause the Listener for some specific time.I tried returning false from the onTouch() method , but still the method keeps executing.Is there any other way to have the listener paused for sometime? And anyone please explain what returning false from onTouch() actually mean?
answer count: 3
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/21578580
accepted answer: http://stackoverflow.com/a/21578580
upvote count: 8
possible better answer: http://stackoverflow.com/a/21578592
tagged with: android
has title: What actually happens if I return false in a OnTouchListener?
score: 8
tagged with: return

http://stackoverflow.com/q/21652101
has comment: http://stackoverflow.com/comment/32724421
tagged with: java
has title: I have to modify a Polynomial implemented with integers, so that it can hold BigIntegers as well
has body: I have to modify a Polynomial implemented with integers, so that it can hold BigIntegers as well. I'm getting null pointer exception error. Please help! Exception at Graph.Polynomial.plus(Polynomial.java:59) and at Graph.Polynomial.main(Polynomial.java:189) package Graph; import java.math.BigInteger; public class Polynomial { private BigInteger[] coef; // coefficients private int deg; // degree of polynomial (0 for the zero polynomial) /** Creates the constant polynomial P(x) = 1. */ public Polynomial(){ coef = new BigInteger[1]; coef[0] = new BigInteger("1"); deg = 0; } /** Creates the linear polynomial of the form P(x) = x + a. */ public Polynomial(BigInteger a){ coef = new BigInteger[2]; coef[1] = new BigInteger("1"); coef[0] = a; deg = 1; } /** Creates the polynomial P(x) = a * x^b. */ public Polynomial(BigInteger a, BigInteger b) { coef = new BigInteger[b.intValue()+1]; coef[b.intValue()] = a; deg = degree(); } /** Return the degree of this polynomial (0 for the constant polynomial). */ public int degree() { int d = 0; for (int i = 0; i < coef.length; i++) if (coef[i]!= new BigInteger("0")) d = i; return d; } /** Return the sum of this polynomial and b, i.e., return c = this + b. */ public Polynomial plus(Polynomial b) { Polynomial a = this; Polynomial c = new Polynomial(new BigInteger(("0"), Math.max(a.deg, b.deg))); for (int i = 0; i <= a.deg; i++) c.coef[i] = c.coef[i].add(a.coef[i]); for (int i = 0; i <= b.deg; i++) c.coef[i] = c.coef[i].add(b.coef[i]); c.deg = c.degree(); return c; } /** Return the difference of this polynomial and b, i.e., return (this - b). */ public Polynomial minus(Polynomial b) { Polynomial a = this; Polynomial c = new Polynomial(new BigInteger("0", Math.max(a.deg, b.deg))); for (int i = 0; i <= a.deg; i++) c.coef[i] = c.coef[i].add(a.coef[i]); for (int i = 0; i <= b.deg; i++) c.coef[i] = c.coef[i].subtract(b.coef[i]); c.deg = c.degree(); return c; } /** Return the product of this polynomial and b, i.e., return (this * b). */ public P…
type: Question
answer count: 2
downvote count: 4
duplicate of: http://stackoverflow.com/q/21597081
has comment: http://stackoverflow.com/comment/32724490
upvote count: 0
has comment: http://stackoverflow.com/comment/32724542
tagged with: int
has comment: http://stackoverflow.com/comment/32724545
has answer: http://stackoverflow.com/a/21652174
has answer: http://stackoverflow.com/a/21652178
linked to: http://stackoverflow.com/q/21597081
favorite count: 0
tagged with: biginteger
type: UnansweredQuestion
score: -4
has comment: http://stackoverflow.com/comment/32724446

http://stackoverflow.com/q/21615287
tagged with: java
has comment: http://stackoverflow.com/comment/32660976
tagged with: sieve-of-eratosthenes
has comment: http://stackoverflow.com/comment/32660659
has title: block expression from Sieve of Eratosthenes, twin prime, number of primes in Java
has comment: http://stackoverflow.com/comment/32660650
has comment: http://stackoverflow.com/comment/32660905
has body: I need help, do not know how I can correct the error and allow the program to run. Program is all primes spend 3-12345. Number of primes and twin primes. All results must be block expression. I would be thankful for any help! public class SieveOfEratosthenes { //final N and byte f[] there is provision must not be changed! static final int N = 12345; static byte f[] = new byte[(N + 1) / 2]; public static void main(String[] args) { System.out.println(sieve()); System.out.println(twinPrime()); System.out.println(countPrime()); } private static int sieve() { int prime; for (int i = 3; i &lt; N; i++) return f[i] = false; //cancel all Primzahle /* * sieves with all primes i, where i is the smallest * prime factor of a composite number j = k*i. * The smallest prime factor of a complex number j * can not be greater than the root of j &lt;= n */ for (int i = 2; i &lt; Math.sqrt(N); i++) { do { //now i is prime return i; } while (f[i] = true); //and underline its multiples, starting with i * i for (int j = i * i; j &lt; N; j++) { return f[j] = true; } } //Give the prime numbers greater than n from sqrt. //Thus, those have not yet been deleted for (int i = Math.sqrt(N) + 1; i &lt;= N; i++) { do { return i; } while (f[i] = true); } //now i is prime return i = prime; } //Twin prime private static int twinPrime() { for (int n = 1; n &lt;= N; n++) { if (((6 * n - 1) % 2 != 0) &amp;&amp; ((6 * n + 1) % 2 != 0)) { //mark all twin prime with "*" return Integer.parseInt((n + "*")); } } } //Number of primes private static int countPrime() { return Integer.bitCount(twinPrime()); } }
answer count: 0
has comment: http://stackoverflow.com/comment/32660755
score: 0
type: UnansweredQuestion
type: Question
has comment: http://stackoverflow.com/comment/32661129

http://stackoverflow.com/comment/32485279
type: Comment
type: QuestionComment
has text: I am almost certain that the piece of code you have showed is not causing your problem. Can you add the whole class?
comment on: http://stackoverflow.com/q/21516220
score: 0

http://stackoverflow.com/comment/32540437
has text: actually I don't get it. Can you receive \/folder1\/folder2 from json ?
comment on: http://stackoverflow.com/a/21547550
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/a/21649742
upvote count: 1
score: 1
downvote count: 0
type: Answer
has body: The stack overflows is commonly :- excessively deep or infinite recursion. In simple terms,for an example: calling a method within a method. public static void proneToStackOverFlow() { proneToStackOverFlow(); } public static void main(String[] args) { proneToStackOverFlow(); }
answers question: http://stackoverflow.com/q/21649429

http://stackoverflow.com/comment/32721480
type: AnswerComment
type: Comment
has text: Can you please explain?
score: 0
comment on: http://stackoverflow.com/a/21650051

http://stackoverflow.com/comment/32690665
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21632985
has text: You don't need your extra spaces considering the strings you are adding already have them.

http://stackoverflow.com/q/21565787
type: Question
score: 3
tagged with: blender
has body: I created a simple model of a barrel (.zip) in Blender 2.69. Then I created a UV map in Blender and made a UV mapped texture out of it (its in the archive, too). Then I imported my texture in Blender, now the mapping matches: In Blender the model looks fine so far: By using the Ogre exporter plugin that I installed via the jmonkeyengine SDK, I exported the model. The result of this is my OgreXML format file of the barrel (I did not export material). Now, I tried to add the barrel to my world like this: this.barrel = this.assetManager.loadModel("models/barrel/Barrel.mesh.xml"); Material barrelMat = new Material(this.assetManager, "Common/MatDefs/Light/Lighting.j3md"); barrelMat.setTexture("DiffuseMap", this.assetManager.loadTexture("models/barrel/Barrel.jpg")); barrelMat.setBoolean("UseMaterialColors", true); barrelMat.setColor("Diffuse", ColorRGBA.White); barrelMat.setColor("Specular", new ColorRGBA(0.3f, 0.1f, 0, 1)); barrelMat.setFloat("Shininess", 4f); this.barrel.setMaterial(barrelMat); this.rootNode.attachChild(this.barrel); The result is this: Is there something else I have to consider when setting the texture for my UV mapped model?
accepted answer: http://stackoverflow.com/a/21572514
tagged with: 3d
downvote count: 0
answer count: 1
tagged with: jmonkeyengine
favorite count: 0
has title: jme3 - UV map misplaced on model exported from Blender
tagged with: uv-mapping
type: AnsweredQuestion
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/21572514

http://stackoverflow.com/comment/32567067
score: 0
comment on: http://stackoverflow.com/a/21562509
type: Comment
has text: @user3236641 so you got
type: AnswerComment

http://stackoverflow.com/q/21562591
answer count: 1
favorite count: 0
tagged with: project-reactor
downvote count: 0
has body: I'm trying to configure Reactor to use Chronicle based persistence, and I cannot find by information about this in documentation. I see two ways: Create my own dispatcher supporting PersistentQueue Use EventBatcher with such queue to wrap my Reactor instance Which option is better? Or maybe there is another solution which I overlooked?
has title: How to use PersistentQueue in Reactor?
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21563270
accepted answer: http://stackoverflow.com/a/21563270
score: 1
tagged with: java
tagged with: chronicle-queue
tagged with: queue
upvote count: 1

http://stackoverflow.com/comment/32741391
score: 0
type: Comment
has text: @shine It should be in meters; [the docs for distanceTo](http://developer.android.com/reference/android/location/Location.html#distanceTo(android.location.Location)) say `Returns the approximate distance in meters between this location and the given location.`.
type: AnswerComment
comment on: http://stackoverflow.com/a/21640172

http://stackoverflow.com/comment/32567838
type: AnswerComment
comment on: http://stackoverflow.com/a/21561350
score: 0
has text: It works. For settext, it works after I change it to setText. I'm trying it now. Thank you
type: Comment

http://stackoverflow.com/q/21533310
tagged with: java
has body: with Hough Transform (OpenCV) detect lanes //do Hough transform to find lanes Imgproc.HoughLinesP(thresholdImage, lines, rho, theta, threshold, VActivity.HOUGH_MIN_LINE_LENGTH, VActivity.HOUGH_MAX_LINE_GAP); for (int x = 0; x &lt; lines.cols(); x++) { double[] vec = lines.get(0, x); double x1 = vec[0], y1 = vec[1], x2 = vec[2], y2 = vec[3]; Point start = new Point(x1, y1); Point end = new Point(x2, y2); double dx = x2 - x1; double dy = y2 - y1; double angle = Math.atan2(dy, dx) * 180 / Math.PI; Log.i(VActivity.TAG, Double.toString(angle)); if (Math.abs(angle) &lt;= VActivity.LINE_REJECT_DEGREES) { Log.i(VActivity.TAG, "Reject: " + Double.toString(angle)); // reject near horizontal lines continue; } Core.line(mRgba, start, end, new Scalar(255, 0, 0), 3); } At code result i have 4 lines x1, x2, y1, y2, but sometimes algorithm don't detect lanes and need save in some hash table detected lanes or something else? Point start = new Point(x1, y1); Point end = new Point(x2, y2); What do you think about? I need to find distance from first lane to second to remind user for crossing the one line to another line...
score: 0
has comment: http://stackoverflow.com/comment/32515786
has comment: http://stackoverflow.com/comment/32515543
has title: How detect distance from first and second detected lane - Hough transform (OpenCV)
type: UnansweredQuestion
tagged with: android
has comment: http://stackoverflow.com/comment/32515845
answer count: 0
type: Question
tagged with: opencv
has comment: http://stackoverflow.com/comment/32515732

http://stackoverflow.com/a/21613705
upvote count: 1
has body: I apologize for my dumbness. the logic in the isUserInRole method is completely relevant! I had a NPE in there that I didn't see and was causing the 500.
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 1
accepted answer of: http://stackoverflow.com/q/21613597
answers question: http://stackoverflow.com/q/21613597

http://stackoverflow.com/q/21564605
has answer: http://stackoverflow.com/a/21565220
type: Question
has comment: http://stackoverflow.com/comment/32571142
has comment: http://stackoverflow.com/comment/32570980
has comment: http://stackoverflow.com/comment/32571056
has comment: http://stackoverflow.com/comment/32571087
has comment: http://stackoverflow.com/comment/32592928
upvote count: 2
has title: Why are the Unmodifiable collections protected to the Collections package?
answer count: 2
has comment: http://stackoverflow.com/comment/32571066
has comment: http://stackoverflow.com/comment/32571028
downvote count: 1
linked to: http://stackoverflow.com/q/11146255
has comment: http://stackoverflow.com/comment/32571712
has answer: http://stackoverflow.com/a/21565168
accepted answer: http://stackoverflow.com/a/21565168
favorite count: 0
has comment: http://stackoverflow.com/comment/32570927
possible better answer: http://stackoverflow.com/a/21565220
has comment: http://stackoverflow.com/comment/32571014
has body: I cannot fathom why Java wishes to hide immutable unmodifiable collections from being passed around. It makes life harder on devs because you can't guarantee that a class is returning anything immutable unmodifiable, forcing you to smatter calls to Collections.unmodifiableWhatever throughout your code. This is both wasteful and annoying. Is there a reason I'm missing behind why you would make these methods protected, or another library I'm missing that contains public versions of immutable and/or unmodifiable collections? For the purposes of learning more about java, let's say Scala does not count as an answer to "a library that contains public versions of immutable collections" :)
has comment: http://stackoverflow.com/comment/32571065
type: AnsweredQuestion
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32571540
has comment: http://stackoverflow.com/comment/32571094
has comment: http://stackoverflow.com/comment/32571131
linked to: http://stackoverflow.com/q/8892350

http://stackoverflow.com/comment/32685318
type: Comment
comment on: http://stackoverflow.com/a/21629943
type: AnswerComment
score: 0
has text: Ok. got it. But how to import the jar. Lyk we use import java.util.StringTokenize for using StringTokenize class in the program.

http://stackoverflow.com/comment/32730416
score: 0
type: AnswerComment
has text: In my personal view, a txt file is a file.. not a DB.. It does not have a particular format or means of accessing/editing/storing data.. You would not call a JPG image a database or a PDF document... WHILE a CSV can "sort of" be seen as a DB... Its still... on that point of being one and not being one at the same time.
type: Comment
comment on: http://stackoverflow.com/a/21655396

http://stackoverflow.com/a/75388178
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21592224
has body: According to the Java 7 API, the 'executeBatch&quot; function doesn't return an object of ResultSet, but an array of integers. You can process the values based on the API to see which commands in the batch were successful.

http://stackoverflow.com/a/21539836
upvote count: 1
has comment: http://stackoverflow.com/comment/32527942
has comment: http://stackoverflow.com/comment/32527574
score: 1
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32528053
answers question: http://stackoverflow.com/q/21539734
type: Answer
has comment: http://stackoverflow.com/comment/32527673
accepted answer of: http://stackoverflow.com/q/21539734
has comment: http://stackoverflow.com/comment/32527818
has body: Even if the method was correct, i.e: public static int intconvert(String numb, int index, int times) { if (index == numb.length()) { return x; } integer = Integer.parseInt(String.valueOf(numb.charAt(index))); // x += integer * times; // add int and multiply it return intconvert(numb, index++, times * 10); // } You'll still get an StackOverFlow exception, because you of the way you increment your x, it will never enter the stopping condition. If I understood what you wanted to do, the solution is: public class Cenas { public static int x = 0; public static int integer; public static int intconvert(String numb, int index, int times) { integer = Integer.parseInt(Character.toString(numb.charAt(index))); // x += integer * times; // add int and multiply it if (index == 0) { return x; } return intconvert(numb, --index, times * 10); // } public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter the String digit: "); String number = scan.nextLine(); System.out.println(intconvert(number, number.length() - 1, 1)); } Start at the algarism with the less weight and work your way to the beggining index, also you were missing the print statement at your main call. Because you are incrementing your "times" 10 times by each iteration you must start ate the last index of the string. Example: 123 = 1 * 100 + 2 * 10 + 3 * 1 Your problem was not recursion but the algorithm you were using.

http://stackoverflow.com/q/21557822
has body: i wish to read file + folder+ shortcut on desktop with its created date and modified/last access date...so what changes should i made import java.io.File; import java.util.ArrayList; import java.util.List; public class read { public static void main(String[] args) { List&lt;File&gt; fileList =new ArrayList(); final File folder = new File("C:\\Users\\ROSH\\Desktop"); new read().listFilesForFolder(folder, fileList); } public void listFilesForFolder(final File folder,List&lt;File&gt; fileList) { File[] filesInFolder = folder.listFiles(); if (filesInFolder != null) { for (final File fileEntry : filesInFolder) { if (fileEntry.isDirectory()) { System.out.println("DIR : "+fileEntry.getName()); listFilesForFolder(fileEntry,fileList); } else { System.out.println("FILE : "+fileEntry.getName()); fileList.add(fileEntry); } } } }
has comment: http://stackoverflow.com/comment/32558458
answer count: 0
tagged with: java
type: Question
score: 0
linked to: http://stackoverflow.com/q/2723838
has comment: http://stackoverflow.com/comment/32558744
has title: how to read desktop folder and files.........my below program reading all the files (which are inside folder too)
has comment: http://stackoverflow.com/comment/32558767
has comment: http://stackoverflow.com/comment/32558713
has comment: http://stackoverflow.com/comment/32558574
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32558431

http://stackoverflow.com/a/32538792
type: Answer
score: 0
answers question: http://stackoverflow.com/q/21568210
has body: Your code does not produce the opposite, because the opposite would mean that you have spaces but on the right side. The right side of your output is simply empty, making you think you have the opposite. You need to include spaces in order to form the shape you want. Try this: public class Test{ public static void main (String [] args){ for(int line = 1; line &lt;= 5; line++){ //i decreases with every loop since number of spaces //is decreasing for(int i =-1*line +5; i&gt;=1; i--){ System.out.print(" "); } //j increases with every loop since number of numbers //is decreasing for(int j = 1; j &lt;= line; j++){ System.out.print(line); } //End of loop, start a new line System.out.println(); } } } You approached the problem correctly, by starting with the number of lines. Next you have to make a relation between the number of lines (the first for loop) and the for loops inside. When you want to do that remember this formula: Rate of change*line + X = number of elements on line You calculate rate of change by seeing how the number of elements change after each line. For example on the first line you have 4 spaces, on the second line you have 3 spaces. You do 3 - 4 = -1, in other words with each line you move to, the number of spaces is decreasing by 1. Now pick a line, let's say second line. By using the formula you will have -1(rate of change) * 2(line) + X = 3(how many spaces you have on the line you picked). You get X = 5, and there you go you have your formula which you can use in your code as you can see on line 4 in the for loop. for(int i = -1 * line +5; i >= 1; i--) You do the same for the amount of numbers on each line, but since rate of change is 1 i.e with every line the amount of numbers is increasing by 1, X will be 0 since the number of elements is equal to the line number. for(int j = 1; j &lt;= line; j++){

http://stackoverflow.com/comment/32610115
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21586513
has text: So multiply by a factor?

http://stackoverflow.com/comment/32664367
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21617139
has text: @All: Strange that every answer got a down vote.
score: 0

http://stackoverflow.com/comment/32708029
comment on: http://stackoverflow.com/a/21642553
has text: Actually, *symmetric* is the term used with regards to binary relations, while *commutative* is the term for binary operations. `==` can of course be considered as either, but I considered it primarily as an operation in this case (I thought it reasonable considering I was primarily interested in its side effects, rather than as a relation).
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/q/21618461
favorite count: 0
has answer: http://stackoverflow.com/a/21628077
tagged with: android
has comment: http://stackoverflow.com/comment/32666193
type: AnsweredQuestion
score: 1
has answer: http://stackoverflow.com/a/21621725
has answer: http://stackoverflow.com/a/21622088
tagged with: java
upvote count: 1
has comment: http://stackoverflow.com/comment/32667534
has comment: http://stackoverflow.com/comment/32670617
has comment: http://stackoverflow.com/comment/32693101
has title: How can I intercept a method call to a library class in Java or Android?
type: Question
tagged with: aspectj
has comment: http://stackoverflow.com/comment/32693809
possible better answer: http://stackoverflow.com/a/21621725
downvote count: 0
has body: I have a library class that is a singleton and does NOT implement any interface (So I'm assuming I cannot use dynamic proxies). But, I need the same functionality as the dynamic proxy. I need to hijack the call, log some data and pass on the call to the library as is. Is it possible to do this without having to use AspectJ or Spring AOP? (I'm not sure how to use these frameworks, but I will have to look into it if there is no other way).
tagged with: spring-aop
accepted answer: http://stackoverflow.com/a/21622088
answer count: 3

http://stackoverflow.com/comment/32671510
comment on: http://stackoverflow.com/a/21621902
score: 0
type: AnswerComment
has text: Well, I'm in a good mood :-) So I thought it would be a nice idea to show an elegant, though not perfect (as I already pointed out, solution. I learned a lot about programming languages by reading (well written) code. And my little present does leave some (home)work to do. At least the asking person was honest about the fact that this is homework.
type: Comment

http://stackoverflow.com/comment/32747558
has text: The solution you describe with an `int` will not work in Java, because in Java (unlike in C or C++) an `int` is always 32 bits, no matter if the JVM and operating you are running on is 32-bit or 64-bit.
comment on: http://stackoverflow.com/q/21664979
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/a/21554998
has body: Select all div.content and get the first and second Elements els = doc.select("div.content"); System.out.println(els.get(1).text()); System.out.println(els.get(2).text()); or Elements els = doc.select("div.content:eq(1)"); System.out.println(els.first().text()); els = doc.select("div.content:eq(2)"); System.out.println(els.first().text());
score: 0
answers question: http://stackoverflow.com/q/21554690
type: Answer
accepted answer of: http://stackoverflow.com/q/21554690
has comment: http://stackoverflow.com/comment/32553295
has comment: http://stackoverflow.com/comment/32553395
has comment: http://stackoverflow.com/comment/32553210
type: AcceptedAnswer

http://stackoverflow.com/q/21652723
has answer: http://stackoverflow.com/a/21652801
has answer: http://stackoverflow.com/a/21657791
has title: How can I use functional programming to do string manipulation?
upvote count: 1
type: AnsweredQuestion
tagged with: command-pattern
accepted answer: http://stackoverflow.com/a/21652801
score: 1
tagged with: java
tagged with: functional-java
possible better answer: http://stackoverflow.com/a/21652759
type: Question
has body: I'm writing a function where I'm essentially doing the same thing over and over. I have the function listed below public String buildGarmentsString(List&lt;Garment&gt; garments) { StringBuilder garmentString = new StringBuilder(10000); for(int i=0;i&lt;4;i++) { garmentString.append(this.garmentProductId(i,garments.get(i).getProductId())); garmentString.append(this.garmentColor(i,garments.get(i).getColor())); for(int j=0;j&lt;garments.get(i).getSizes().size();j++) { //check xxsml if(garments.get(i).getSizes().get(j).getXxsml() &gt;0) { garmentString.append(this.garmentSizes(i, Size.xxsml(),garments.get(i).getSizes().get(j).getXxsml())); } //check xsml if(garments.get(i).getSizes().get(j).getXsml() &gt; 0) { garmentString.append(this.garmentSizes(i,Size.xsml(),garments.get(i).getSizes().get(j).getXsml())); } //check sml if(garments.get(i).getSizes().get(j).getSml() &gt; 0) { garmentString.append(this.garmentSizes(i,Size.sml(),garments.get(i).getSizes().get(j).getSml())); } //check med if(garments.get(i).getSizes().get(j).getMed() &gt; 0) { garmentString.append(this.garmentSizes(i,Size.med(),garments.get(i).getSizes().get(j).getMed())); } //check lrg if(garments.get(i).getSizes().get(j).getLrg() &gt; 0) { garmentString.append(this.garmentSizes(i,Size.lrg(),garments.get(i).getSizes().get(j).getLrg())); } //check xlrg if(garments.get(i).getSizes().get(j).getXlg() &gt; 0) { garmentString.append(this.garmentSizes(i,Size.xlg(),garments.get(i).getSizes().get(j).getXlg())); } //check xxlrg if(garments.get(i).getSizes().get(j).getXxl() &gt;0) { garmentString.append(this.garmentSizes(i,Size.xxlg(),garments.get(i).getSizes().get(j).getXxl())); } //check xxxlrg if(garments.get(i).getSizes().get(j).getXxxl() &gt;0) { garmentString.append(this.garmentSizes(i,Size.xxxlg(),garments.get(i).getSizes().get(j).getXxxl())); } } } } This is my garmentSizes function: public String garmentSizes(int garmentNumber, String size,int numberToSend) { String garmentSizes = "&amp;garment["+garmentNu…
has answer: http://stackoverflow.com/a/21652759
tagged with: functional-programming
tagged with: lambdaj
downvote count: 0
favorite count: 0
answer count: 3

http://stackoverflow.com/comment/32758753
has text: you also want types which are comparable *to themselves*: `<T extends Comparable<? super T>>`
type: Comment
score: 1
comment on: http://stackoverflow.com/q/21664932
type: QuestionComment

http://stackoverflow.com/q/21666392
tagged with: spring-mvc
type: AnsweredQuestion
downvote count: 0
tagged with: java
tagged with: tomcat6
type: Question
score: 4
tagged with: servlet-3.0
accepted answer: http://stackoverflow.com/a/21674975
answer count: 1
has title: Spring MVC Interceptor error response not caught by Tomcat custom error handler
favorite count: 0
has body: In my Spring MVC app (servlet 3.0), I have defined a custom error handler in web.xml: /error which maps to a Controller: @Controller class CustomErrorController { @RequestMapping("error") public String customError(HttpServletRequest request, HttpServletResponse response, Model model) { ... } } This works fine for most errors, such as 404 errors. However, I have also defined an Interceptor which returns a 403 response if there is no authenticated user: @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { HttpSession httpSession = request.getSession(); ((HttpServletResponse) response).setStatus(HttpURLConnection.HTTP_FORBIDDEN); return false; } The 403 response is not being caught by the custom error handler - the browser just gets no response with an error code of 403. I presume this is because I am doing something incorrectly in the Interceptor - How should I change the code in the Interceptor so that normal error handling works?
has comment: http://stackoverflow.com/comment/32749851
has answer: http://stackoverflow.com/a/21674975
upvote count: 4
tagged with: spring

http://stackoverflow.com/q/21630345
has comment: http://stackoverflow.com/comment/32688223
has comment: http://stackoverflow.com/comment/32687873
has comment: http://stackoverflow.com/comment/32691340
has comment: http://stackoverflow.com/comment/32686180
score: 0
has comment: http://stackoverflow.com/comment/32687614
has title: HttpSession & ServletContext not giving desired outcome
has comment: http://stackoverflow.com/comment/32687000
has comment: http://stackoverflow.com/comment/32687374
has comment: http://stackoverflow.com/comment/32686134
answer count: 0
has comment: http://stackoverflow.com/comment/32687091
has comment: http://stackoverflow.com/comment/32687335
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32686091
has body: I am new to servlet. My code executes without errors but i don't get the desired outcome. @WebServlet(description = "A simple", urlPatterns = { "/SimpleServlet" }) public class SimpleServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter wr = response.getWriter(); String uname = request.getParameter("unam"); HttpSession ses = request.getSession(); ServletContext cont = request.getServletContext(); if (uname != "" &amp;&amp; uname != null) { ses.setAttribute("userses", uname); cont.setAttribute("userses", uname); } wr.println("In RequestHttp method your name is "+ uname); wr.println("In Sesssion method your name is " + (String)ses.getAttribute("userses")); wr.println("In Context method your name is " + (String)cont.getAttribute("userses")); } } So when i run in Eclipse IDE the below http://localhost:8080/SimpleServletProject/SimpleServlet?unam=1 Result In RequestHttp method your name is 1 In Sesssion method your name is 1 In Context method your name is 1 Nothing wrong with this. So when I run in chrome the below http://localhost:8080/SimpleServletProject/SimpleServlet Result In RequestHttp method your name is null In Sesssion method your name is null In Context method your name is null I am expecting Context Method your name is 1. I went back to Eclipse IDE and this time i did this below http://localhost:8080/SimpleServletProject/SimpleServlet Result In RequestHttp method your name is null In Sesssion method your name is null In Context method your name is null Here I am expecting Session method is 1. What is the mistake I am making?
type: Question
has comment: http://stackoverflow.com/comment/32686412
has comment: http://stackoverflow.com/comment/32686753
tagged with: java
tagged with: servlets
has comment: http://stackoverflow.com/comment/32687973
has comment: http://stackoverflow.com/comment/32688575
has comment: http://stackoverflow.com/comment/32686133

http://stackoverflow.com/q/21627459
type: Question
has title: How to occupy entire editorss area with a view?
tagged with: eclipse-rcp
score: 0
has comment: http://stackoverflow.com/comment/32691632
answer count: 1
tagged with: eclipse-plugin
has answer: http://stackoverflow.com/a/21631156
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32692449
has body: How to occupy entire editorss area with a view? I can do this by layout.addView(ID, IPageLayout.BOTTOM, 1.0f, "org.eclipse.ui.editorss"); but it appears temporary (view stops occupying full area at some drag). I know it is prohibited by the doc. Also I can't do this from plugin.xml. If I set 1.0 then the value is ignored and assumed 0.5. Is it possible? UPDATE Interactively I can put editor into view area. Can I do opposite, i.e. put view onto editor area? UPDATE 2 Ok I found a way to occupy entire editor area by a view interactively: one should drag to the left of the area title so that short green mark appears: This way any view can be put anywhere. Hence, the question is reasonable and persists: how to do that programmatically? UPDATE 3 This works in Juno and Kepler and probably above, but not works in Indigo and probably below. UPDATE 4 And the dragging also works in written plugins. I.e. I can place my view to entire area manually, but I don't know how to do this programmtically.
tagged with: java
tagged with: eclipse

http://stackoverflow.com/comment/32725106
has text: So what's the problem? What isn't working with this code?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21652483

http://stackoverflow.com/q/21590603
tagged with: java
type: Question
tagged with: bigdecimal
upvote count: 3
has comment: http://stackoverflow.com/comment/32617714
answer count: 1
has answer: http://stackoverflow.com/a/21590660
accepted answer: http://stackoverflow.com/a/21590660
favorite count: 0
has body: I want to get the exponent of a BigDecimal. `1M` (`1E0M`) -&gt; `0` `10M` (`1E1M`) -&gt; `1` `11M` (`1.1E1M`) -&gt; `1` `1E2M` -&gt; `2` `1.0E2M` -&gt; `2` `100M` (`1.00E2M`) -&gt; `2` scale, at least by itself, is not what I need. I would really rather not have to use .toPlainString and hack something around that. I'm a little surprised that the exponent I want isn't part of the internal representation of a BigDecimal. I'm using BigDecimal from Clojure, but any logic that works for Java is welcome too.
has title: Get exponent of a BigDecimal
tagged with: clojure
type: AnsweredQuestion
score: 3
downvote count: 0

http://stackoverflow.com/a/21687143
answers question: http://stackoverflow.com/q/21678082
type: Answer
has body: First thing I would try is: &lt;forward name="login" path="/home/success.jsp?id=&lt;%=id%&gt;" /&gt; or &lt;forward name="login" path="/home/success.jsp?id=${id}" /&gt;
score: 0

http://stackoverflow.com/q/21675390
has body: I've a doubt. I don't know where insert each eventlistener in a pattern MVC. Is it right to insert them in a controller or is better insert eventlistener directly in view?And from view eventlistener can call a controller to do something.
upvote count: 1
answer count: 1
tagged with: user-interface
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/21676267
accepted answer: http://stackoverflow.com/a/21676267
tagged with: model-view-controller
type: AnsweredQuestion
score: 1
tagged with: java
has title: Model-view-control and swing gui
tagged with: swing
has comment: http://stackoverflow.com/comment/32765068
type: Question

http://stackoverflow.com/a/21535574
has comment: http://stackoverflow.com/comment/32520980
has comment: http://stackoverflow.com/comment/32520229
answers question: http://stackoverflow.com/q/21535489
type: Answer
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/32520528
has comment: http://stackoverflow.com/comment/32520941
accepted answer of: http://stackoverflow.com/q/21535489
has body: When you read data from the input stream, you read until it is close, but you don't close the connection until after you have recieved a reply, which you won't get until you close the connection. i.e. you have a deadlock. You need some way of knowing when the message has been sent, while the connection is still open so you can send a reply. I suggest sending a \n at the end of your line and stop reading when you see this.
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32520936

http://stackoverflow.com/comment/32705578
type: Comment
score: 3
comment on: http://stackoverflow.com/q/21641073
type: QuestionComment
has text: What problem is that?

http://stackoverflow.com/a/21587381
type: Answer
answers question: http://stackoverflow.com/q/21587345
downvote count: 0
has comment: http://stackoverflow.com/comment/32611981
score: 1
has body: There are two problems with this code. The first one iswith this line: frage.toLowerCase(); This method returns a string, it doesn't modify the string in place (since String objects in Java are immutable). You can just use frage.toLowerCase() as the key. Then you have this line: ratschlagMap.get(frage); This method returns the value for the key frage. But you don't do anything with this value, not even assign it to a variable. This is a bug.
has comment: http://stackoverflow.com/comment/32611829
upvote count: 1
has comment: http://stackoverflow.com/comment/32611860
has comment: http://stackoverflow.com/comment/32612082

http://stackoverflow.com/a/21524883
has comment: http://stackoverflow.com/comment/32502715
answers question: http://stackoverflow.com/q/21523451
type: Answer
has body: Here is some code snippet from the AbstractTableViewer#virtualSetSelectionToWidget(List list, boolean reveal), which is called, when you use v.setSelection(new StructuredSelection(model.get(counter - 1)), true);: if (getContentProvider() instanceof ILazyContentProvider) { ILazyContentProvider provider = (ILazyContentProvider) getContentProvider(); // Now go through it again until all is done or we are no longer // virtual // This may create all items so it is not a good // idea in general. // Use #setSelection (int [] indices,boolean reveal) instead for (int i = 0; virtualElements.size() &gt; 0 &amp;&amp; i &lt; doGetItemCount(); i++) { provider.updateElement(i); Item item = doGetItem(i); if (virtualElements.contains(item.getData())) { indices[count++] = i; virtualElements.remove(item.getData()); if (firstItem == null) { firstItem = item; } } } } as you can see it always iterates over all elements (confessing, that It might not be the best idea), as per Eclipse 3.x. Tree viewer has different implementation (which is actually understandable, that there you actually have kind of visibility levels and in table you don't have those). I think, that refreshing of elements in general could be handled without dependency on content provider, so that only visible elements are refreshed (at least on demand).
has comment: http://stackoverflow.com/comment/32503013
has comment: http://stackoverflow.com/comment/32503268
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/32502058
upvote count: 2

http://stackoverflow.com/comment/32683466
type: Comment
score: 0
has text: most probably its failing in your adapter's getView(...) method.
comment on: http://stackoverflow.com/q/21628911
type: QuestionComment

http://stackoverflow.com/comment/33753765
type: Comment
comment on: http://stackoverflow.com/a/21546990
score: 1
has text: ok, what you will do with Selections Handles? it's shows as the PopupWindows. And doesn't calculate View#setScale, so drag&drop wouldn't work, text selection will work like without scale. Pins will be appear in places like not scaled
type: AnswerComment

http://stackoverflow.com/comment/32510098
type: Comment
score: 2
comment on: http://stackoverflow.com/q/21530325
type: QuestionComment
has text: The best way is probably not writing that part yourself because managing a large dataset requires memory management, hashing is just a minor problem. Look at SQLite (maybe [FTS](http://www.sqlite.org/fts3.html) or maybe [lucene](http://lucene.apache.org/core/) or whatever suits your needs.

http://stackoverflow.com/comment/32711171
type: Comment
comment on: http://stackoverflow.com/a/21644153
type: AnswerComment
has text: This: `System.out.println("You have " + Integer.toString(entriesLeft) + " numbers left");`
score: 0

scala
tags question: http://stackoverflow.com/q/21603161
tags question: http://stackoverflow.com/q/21587288
tags question: http://stackoverflow.com/q/21663627
tags question: http://stackoverflow.com/q/21609048
tags question: http://stackoverflow.com/q/21582045
tags question: http://stackoverflow.com/q/21562135
tags question: http://stackoverflow.com/q/21518341
tags question: http://stackoverflow.com/q/21677142
tags question: http://stackoverflow.com/q/21576065
tags question: http://stackoverflow.com/q/21555936
tags question: http://stackoverflow.com/q/21604763
tags question: http://stackoverflow.com/q/21675323
tags question: http://stackoverflow.com/q/21632736
tags question: http://stackoverflow.com/q/21568542
tags question: http://stackoverflow.com/q/21658491
tag name: scala
tags question: http://stackoverflow.com/q/21527555
tags question: http://stackoverflow.com/q/21537148
type: Tag
tags question: http://stackoverflow.com/q/21647394
tags question: http://stackoverflow.com/q/21586948

http://stackoverflow.com/comment/32484079
comment on: http://stackoverflow.com/q/21515291
score: 0
type: Comment
type: QuestionComment
has text: sure, juste edited the op

http://stackoverflow.com/a/21588994
score: 1
has body: In Object Oriented Programming (or OOP) you're representing real-life objects, information or concepts - as objects. This is helpful partially because many objects can have the same properties. In your exercise you're building a number-representing class Num which is supposed to evaluate properties of that number. To actually construct such number in your code you can use the call to the class's constructor: // this can be a call in your main function, or anywhere in fact! Number two = new Number(2); // this represents the number "2" later on, you use methods from the class of that objects, to give out properties of that object: System.out.println("Is two odd? " + two.isOdd()); In order to do those things you write two classes. One is called the main class, which drives the program (constructs objects, performs prints to the user and more...) and another is a more passive class, the number class, which represents a number (and has methods that operate on that number). Putting everything together: the main class will look something like this (only longer): import java.util.Scanner; public class Main { public static void main(String[] args) { Num two = new Num(2); System.out.println("Is two odd? " + two.isOdd()); // and scanner... Scanner in = new Scanner(System.in); Num x = new Num(in.nextInt()); // add more methods and call them on x } } And the number class will look something like this (again, longer): public class Num { private int number; public Num(int num) { // save number in object's state. this.number = num; } public boolean isOdd() { // print if the number is odd or not return this.number % 2 != 0; } } Another great programming skill is searching: When you're in trouble, Google has all answers. Think about the terms that uniquely identify your problem and use them in your search (for example: "How do I use a while loop in java?" is probably the same as searching "while loop java") You can also start by using Oracle's tutorials on Learning the Java Language
answers question: http://stackoverflow.com/q/21588695
upvote count: 1
type: Answer
downvote count: 0

http://stackoverflow.com/a/21666005
has comment: http://stackoverflow.com/comment/32749434
upvote count: 1
has body: In your code your use the constructor without automatic line flushing. PrintWriter(OutputStream out) Creates a new PrintWriter, without automatic line flushing, from an existing OutputStream. You should therefore use outputStream.flush() or use the constructor with automatic line flushing: PrintWriter(OutputStream out, boolean autoFlush). For details see http://docs.oracle.com/javase/7/docs/api/java/io/PrintWriter.html
has comment: http://stackoverflow.com/comment/32772989
has comment: http://stackoverflow.com/comment/32764288
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/21665386
type: Answer
has comment: http://stackoverflow.com/comment/32749146
has comment: http://stackoverflow.com/comment/32758248
has comment: http://stackoverflow.com/comment/32789342

http://stackoverflow.com/a/21662135
type: Answer
has comment: http://stackoverflow.com/comment/32742283
has comment: http://stackoverflow.com/comment/32741740
score: 3
accepted answer of: http://stackoverflow.com/q/21662091
upvote count: 3
answers question: http://stackoverflow.com/q/21662091
has comment: http://stackoverflow.com/comment/32742533
type: AcceptedAnswer
downvote count: 0
has body: It's fundamentally not the same because you can't perform bit shifting with non integer numbers. Therefore, doing something like 7 &gt;&gt; 1 will return 3, but 7 * 0.5 will return the proper float value 3.5
has comment: http://stackoverflow.com/comment/32744765

http://stackoverflow.com/q/21560613
type: Question
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/21566035
tagged with: mapreduce
tagged with: hadoop
has title: Setting the number of hadoop tasks/node
has answer: http://stackoverflow.com/a/21566937
downvote count: 0
favorite count: 0
answer count: 3
has answer: http://stackoverflow.com/a/21561257
has body: I am running a Hadoop job on a cluster that is shared by several of our applications. We have about 40 nodes and 4 mapper slots/node. Whenever my job (which is nothing but mapper) runs, it takes up all the 160 slots and blocks other jobs from running. I have tried to set the property from within the job "mapred.tasktracker.map.tasks.maximum=1" and also "mapred.map.tasks" to 30 (to limit it to only 30 nodes) from with the task code. conf.setInt ( "mapred.tasktracker.map.tasks.maximum", 1 ); conf.setInt ( "mapred.map.tasks", 30 ); conf.setBoolean ( "mapred.map.tasks.speculative.execution", false ); I have 2 questions: a. When the job runs, the job.xml reflects the "mapred.tasktracker.map.tasks.maximum=1", but the job still ends up taking 160 slots. b. The mapred.map.tasks in the job.xml is not 30. It is still a big number (like 800). Any help would be appreciated.
tagged with: hbase
type: UnansweredQuestion
upvote count: 1

http://stackoverflow.com/comment/32592078
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/21576726
has text: Why bother with the interface? its not actually giving you anything if you give your code a way out of using it. Just use the abstract class... or define your interface properly...
type: Comment

http://stackoverflow.com/q/21527976
has comment: http://stackoverflow.com/comment/32505463
has title: java inheritance accessing super class variables inside subclass?
type: Question
score: -2
has comment: http://stackoverflow.com/comment/32505838
tagged with: java
downvote count: 3
has body: I have below class. public class A { private String name; private String age; //getters and setters } public class B extends A { // Some setters and getters } public class C extends B { // here can i access name and age properties using public getters of A ? } Can I access A class members in Class C ? Thanks!
upvote count: 1
answer count: 1
linked to: http://stackoverflow.com/q/2584377
type: UnansweredQuestion
tagged with: inheritance
duplicate of: http://stackoverflow.com/q/2584377
linked to: http://stackoverflow.com/q/215497
has comment: http://stackoverflow.com/comment/32505485
duplicate of: http://stackoverflow.com/q/215497
favorite count: 0
has answer: http://stackoverflow.com/a/21528240

http://stackoverflow.com/comment/32809471
type: AnswerComment
score: 0
type: Comment
has text: Absolutely Perfect :)
comment on: http://stackoverflow.com/a/21565398

http://stackoverflow.com/comment/32526729
type: QuestionComment
comment on: http://stackoverflow.com/q/21539335
has text: i try your code and it working with me well , check if you have image with name bob.png in assets folder it may not exists
score: 0
type: Comment

http://stackoverflow.com/q/21606176
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21606468
has title: Rendering <p:outputPanel> based on selected <h:selectOneRadio > option in JSF
type: Question
tagged with: jakarta-ee
tagged with: primefaces
tagged with: java
score: 0
answer count: 2
has body: I have two panels: &lt;p:outputPanel id="contentDisplay"&gt; &lt;p:outputPanel id="dashboarddisplay"&gt; I need to render either one of the &lt;p:outputPanel&gt; above by selecting the &lt;h:selectOneRadio&gt; button. Here is the code that I have for &lt;h:selectOneRadio&gt;: &lt;h:selectOneRadio id="choice" style="width:100%" value="#{Bean.selectedChoice}"&gt; &lt;f:selectItem id="item1" itemLabel="Hours Allocation" itemValue="1" /&gt; &lt;f:selectItem id="item2" itemLabel="DashBoard" itemValue="2" /&gt; &lt;p:ajax render="contentDisplay dashboarddisplay " execute="@this" update="contentDisplay dashboarddisplay" listener="#{cmpmBean.onChoiceSelect}" /&gt; &lt;/h:selectOneRadio&gt; How do I pass the selected value of the &lt;f:selectItem&gt; to the backing bean? Though the ajax event is triggered I could not able to get the value for the variable "onChoiceSelect" in the backing bean. Any suggestions will really helpful to resolve this issue.
has answer: http://stackoverflow.com/a/21607926
tagged with: jsf

http://stackoverflow.com/a/21655409
has comment: http://stackoverflow.com/comment/32730723
score: 10
has comment: http://stackoverflow.com/comment/32732925
upvote count: 10
type: Answer
has body: When the server accepts a connection you get a Socket that represents that connection. Socket has a getInetAddress() method that will return the remote's address, and a corresponding getPort() method that will return the remote's port. For example: Socket newSock = s.accept(); InetAddress addr = s.getInetAddress(); int port = s.getPort();
downvote count: 0
has comment: http://stackoverflow.com/comment/32740664
has comment: http://stackoverflow.com/comment/32763735
answers question: http://stackoverflow.com/q/21655187

http://stackoverflow.com/q/21601211
tagged with: java
has body: SUppose I have a String like below: static String MSG = "4: \n"+ ":xx:xyz\n"+ ":xx:abcdef\n"+ ":xx:axvavsba\n"+ ":xx:/000000000000\n"+ ":xxs:/abcssd\n"+ "efg\n"+ "ijk\n"+ "lmn\n"+ "pqr\n"+ ":xx:asasasasas"; from this I want to convert into byte[] messageBytes = MSG.getBytes("utf-8"); and from the messageBytes, I want to extract string based on the position along with its line number for example if I will give extract(startIndex, endIndex) it should return original string in that position along with its line number Here Line number I am refering is each string inside :: reffers to one line number I tried using String str = new String(ArrayUtils.subarray(messageByte, startIndex, endIndex), "utf-8"); I am able to retrive the string but how can I extract the respective line number. ANy help on this will be appricated. Purpose of doing this is as a string might contatin some japanese charecters so if I will apply regex then I will not get the exact string so to accomplish the same job I am trying this approach. Any suggestion or new approach will be also good.
has comment: http://stackoverflow.com/comment/32635754
type: Question
has title: How to get the String and its line position from byte[]
score: 0
answer count: 1
has comment: http://stackoverflow.com/comment/32635403
has answer: http://stackoverflow.com/a/21614351
accepted answer: http://stackoverflow.com/a/21614351
tagged with: regex
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32635332

http://stackoverflow.com/q/21547480
has comment: http://stackoverflow.com/comment/32539846
possible better answer: http://stackoverflow.com/a/21547578
has body: Here I am in the class GameBoard. In this class, I am trying to make a GameTree that returns a list of all possible next moves from this board. While this portion of the code runs, it effects the GameBoard that this code is contained it, resulting in all moves actually being made on the GameBoard, where I am simply trying to return boards with a single move on them. Here is the code within GameBoard: for(int i = 1; i &lt; 7; i++) { for(int j = 1; j &lt; 7; j++) { //if valid move, add a board with this move to the list if(isValidMove(i, j)) { GameBoard tempBoard = new GameBoard(slots); //printout to make sure both object references are different, which they always are System.out.println("this board: " + this + " temp: " + tempBoard); tempBoard.makeMove(2, i, j); //use 2 as it is for the AI's move tempBoard.rotateA(); tempBoard.setLastMove(i + " " + j + " " + "A"); System.out.println("Board with move " + tempBoard.getLastMove()); tempBoard.printBoard(); returnList.add(tempBoard); } } } I cannot figure out why this doesn't simply create a new GameBoard object, play the valid move, and add it to the list. Instead by the end of this for loop the GameBoard is filled up with all possible moves. EDIT: Slots is a private int[][] for the GameBoard class.
score: 0
answer count: 2
accepted answer: http://stackoverflow.com/a/21547590
has title: Why is a new object effecting the current one?
has comment: http://stackoverflow.com/comment/32539851
has answer: http://stackoverflow.com/a/21547578
has answer: http://stackoverflow.com/a/21547590
has comment: http://stackoverflow.com/comment/32539886
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32539742
tagged with: object
tagged with: java
has comment: http://stackoverflow.com/comment/32539781
has comment: http://stackoverflow.com/comment/32539911
tagged with: eclipse
type: Question

http://stackoverflow.com/a/21651663
type: Answer
downvote count: 0
score: 1
has body: In a nutshell, the Singletons pattern means that: The constructor of your class is private You create a public factory method, where YOU take care of: If it is the first time that an instance is requested, create an instance with new YourClass() If an instance was already created in a previous call, you don't create a new one, but return the previous one. So, when any other class needs an instance of that class, they are enforced to call that factory method, since the constructor is private, and inside of that method, you write the code to ensure there is only one instance. Thats all. With this only one object can be created, so all the possible instances of the object are actually the same, but of course any call to any public method of that object will be normally executed, no matter how many times it is called.
upvote count: 1
answers question: http://stackoverflow.com/q/21651393

http://stackoverflow.com/comment/32490924
comment on: http://stackoverflow.com/q/21517486
score: 0
type: Comment
has text: possible duplicate of [Output in a table format in Java's System.out](http://stackoverflow.com/questions/2745206/output-in-a-table-format-in-javas-system-out)
type: QuestionComment

http://stackoverflow.com/comment/33109190
type: AnswerComment
comment on: http://stackoverflow.com/a/21590362
score: 0
type: Comment
has text: Thank you for the explanation. About the code example you provided, I don't know anything about controls in java, and GUI in general. Is that the only time listeners are used? Could you provide a more general "hello world" type example to clarify my doubts? When I see the word control and action listener, I get completely confused and forced to think about GUI.. Thank you.

http://stackoverflow.com/q/21633677
has body: let me just say that I'm still learning Java and the subtleties of Eclipse, and I come to you because I am unsure how to properly phrase my question to Google or to StackOverflow's search engine. Apologies if its infinitely trivial. I am trying to understand the process of converting JSON-format strings into objects in Java. I found following example online: import java.io.IOException; import org.apache.log4j.Logger; import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper;public class JsonToJavaConverter { private static Logger logger = Logger.getLogger(JsonToJavaConverter.class); public static void main(String args[]) throws JsonParseException, JsonMappingException, IOException { JsonToJavaConverter converter = new JsonToJavaConverter(); String json = "{\n" + " \"name\": \"Garima\",\n" + " \"surname\": \"Joshi\",\n" + " \"phone\": 9832734651}"; // converting JSON String to Java object converter.fromJson(json); } public Object fromJson(String json) throws JsonParseException, JsonMappingException, IOException { User garima = new ObjectMapper().readValue(json, User.class); logger.info("Java Object created from JSON String "); logger.info("JSON String : " + json); logger.info("Java Object : " + garima); return garima; } public static class User { private String name; private String surname; private long phone; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getSurname() { return surname; } public void setSurname(String surname) { this.surname = surname; } public long getPhone() { return phone; } public void setPhone(long phone) { this.phone = phone; } @Override public String toString() { return "User [name=" + name + ", surname=" + surname + ", phone=" + phone + "]"; } }} Now, here's the silly part (please don't string me up for asking): import org.apache.log4j.Logger; import org.codehaus.jackson.JsonParseException; im…
type: AnsweredQuestion
has title: Jackson for beginners in Eclipse
tagged with: java
tagged with: http://stackoverflow.com/tag/json
accepted answer: http://stackoverflow.com/a/21633805
has answer: http://stackoverflow.com/a/21633750
tagged with: eclipse
type: Question
score: 9
has answer: http://stackoverflow.com/a/21633758
has answer: http://stackoverflow.com/a/21633805
tagged with: jackson
possible better answer: http://stackoverflow.com/a/21633758
answer count: 3
has comment: http://stackoverflow.com/comment/32692114
favorite count: 0
upvote count: 9
downvote count: 0

http://stackoverflow.com/a/29827373
score: -2
type: Answer
answers question: http://stackoverflow.com/q/21564478
upvote count: 0
has body: What I've been taught to do thus far is to provide the setters and getters within the constructor, then actually set and get it within whatever method, (in your case main), that you want to use it for. But, that's if your fields are private. If they're public like in your case, then I would say setting your variables in the field or constructor, then calling them where/whenever you want to use them makes much more sense...
downvote count: 2

http://stackoverflow.com/q/21645046
score: 0
answer count: 1
has title: How to suppress stdout for Stanford NLP ColumnDataClassifier.makeClassifier() function
tagged with: nlp
type: UnansweredQuestion
tagged with: classification
tagged with: java
linked to: http://stackoverflow.com/q/4799006
type: Question
tagged with: stanford-nlp
has body: I am making a call to edu.stanford.nlp.classify.ColumnDataClassifier.makeClassifier(), and I need to block the std out that it generates. I tried setting displayedColumn=-1 in the .prop file, but it does not see to me help. The following is the console output makeClassifier() generates that I want to eliminate. Can someone help? Console output: QNMinimizer called on double function of 1596 variables, using M = 15. An explanation of the output: Iter The number of iterations evals The number of function evaluations SCALING &lt;D&gt; Diagonal scaling was used; &lt;I&gt; Scaled Identity LINESEARCH [## M steplength] Minpack linesearch 1-Function value was too high 2-Value ok, gradient positive, positive curvature 3-Value ok, gradient negative, positive curvature 4-Value ok, gradient negative, negative curvature [.. B] Backtracking VALUE The current function value TIME Total elapsed time |GNORM| The current norm of the gradient {RELNORM} The ratio of the current to initial gradient norms AVEIMPROVE The average improvement / current value EVALSCORE The last available eval score Iter ## evals ## &lt;SCALING&gt; [LINESEARCH] VALUE TIME |GNORM| {RELNORM} AVEIMPROVE EVALSCORE Iter 1 evals 1 &lt;D&gt; [M 1.000E-1] 6.808E-1 0.00s |3.890E-1| {1.111E-2} 0.000E0 -
has answer: http://stackoverflow.com/a/21645337

http://stackoverflow.com/comment/32639937
comment on: http://stackoverflow.com/a/21603472
type: Comment
has text: Have you tried the code again? I added the brackets and the dollar sign around the expression
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32591785
type: QuestionComment
comment on: http://stackoverflow.com/q/21565624
type: Comment
has text: Set something up in eclipse. `Window->Preferences->General->Workspace->Refresh on access`. This meight help that it does not happen again
score: 0

http://stackoverflow.com/comment/32709858
type: AnswerComment
comment on: http://stackoverflow.com/a/21642931
type: Comment
has text: wow! your answer shows why i should read about records before hand XD, anyhow i am still a newbie :P
score: 0

http://stackoverflow.com/comment/32499411
score: 1
type: Comment
comment on: http://stackoverflow.com/q/21524117
type: QuestionComment
has text: @ᴍarounᴍaroun Good call on the recursive part. Here is an [example](http://stackoverflow.com/a/21494050/418556) of doing that.

http://stackoverflow.com/comment/32634176
comment on: http://stackoverflow.com/a/21600620
type: AnswerComment
score: 0
type: Comment
has text: how about `public void add(int index, E element)`??

http://stackoverflow.com/comment/32667847
comment on: http://stackoverflow.com/q/21619438
has text: Yes that would be correct
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21658798
has body: You dont need to concern about IN vs OUT really. Just use IN always. Or better yet do not use in at all, as that is implied, eg ${in.headers.foo} is the same as ${headers.foo}. See this FAQ http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21572069
answers question: http://stackoverflow.com/q/21572069
score: 3
type: Answer
upvote count: 3

http://stackoverflow.com/comment/32641022
score: 0
type: Comment
type: QuestionComment
has text: yes, its more than that.. its approx 20 secs.
comment on: http://stackoverflow.com/q/21603629

http://stackoverflow.com/comment/32624827
type: Comment
type: QuestionComment
has text: In java when mathematics is performed, the expression is converted into one type e.g. 2/3 will be divides as an integer and result will get saved in minutes variable. Similarly for seconds (25/3600). Adding f (floating suffix) will hint the compiler to convert it to float while performing calculation. So, if you could try something like this 2.0/3.0 or 35.0/3600.0 or just adding it with one of the operand (like you did by adding f), the expression will result the expected outcome.
comment on: http://stackoverflow.com/q/21594840
score: 0

http://stackoverflow.com/comment/32579230
has text: I'm sorry :c! Your code sample those output correctly. Although I'm working with recursive methods and it should call upon itself?
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21568982

http://stackoverflow.com/comment/32693225
has text: Yes, it is thread safe.
type: Comment
comment on: http://stackoverflow.com/q/21634315
score: 0
type: QuestionComment

http://stackoverflow.com/q/21567388
has comment: http://stackoverflow.com/comment/32616001
score: 0
tagged with: maven
has answer: http://stackoverflow.com/a/21589686
tagged with: spring
type: AnsweredQuestion
has title: finding changes eclipse makes to maven project
tagged with: java
has comment: http://stackoverflow.com/comment/32614185
tagged with: eclipse
type: Question
accepted answer: http://stackoverflow.com/a/21589686
has comment: http://stackoverflow.com/comment/32576821
has body: I have a maven project which I have downloaded from this link. When I make a couple changes to it, it runs perfectly from the command line when I type: mvn clean install tomcat7:run-war -Dmaven.test.skip=true in the directory to which the zip was extracted. (The only 2 changes required to make it work on the command line are to 1.) add a plugin tag for tomcat 7 in pom.xml and 2.) create a context.xml file in the webapp/META-INF folder. Everything else in the app remains the same as the github verion, and the app runs fine from the command line using the command given above and then typing the url in the browser.) However, when I import the project into eclipse as an existing maven project, and then try to run the app, the app starts throwing errors related to not finding a couple of jars which are clearly in the repository. The app no longer compiles from the command line, or from eclipse. I even tried to run the app as a maven build from eclipse and even changed the maven instance eclipse uses to the freestanding maven that works from the command line instead of the embedded maven in eclipse, but the app still threw the same errors when I tried to run it. But then, when I repeated the steps with a fresh copy of the app, the fresh copy runs fine from the command line, while the copy that eclipse touched does not compile by any method. It seems that eclipse has made some changes to the app in the process of importing it as an existing maven project into eclipse. How can I locate the specific changes that eclipse has made to the app? I would like to be able to use eclipse as my IDE, but I cannot do so unless it can compile the code.
answer count: 1

http://stackoverflow.com/q/21564478
has answer: http://stackoverflow.com/a/21564546
has title: Can I call a set Method inside a Constructor
tagged with: encapsulation
score: 4
has answer: http://stackoverflow.com/a/21564525
has answer: http://stackoverflow.com/a/21567593
upvote count: 4
possible better answer: http://stackoverflow.com/a/21564503
has body: I have a number of set methods setup and using a constructor to initiate their value as follows. It is working but I am concerned as to whether it is a normal Java convention to do so (is it normal to call a set method inside a constructor?). The alternative way I can think of is to call an empty constructor and call the set methods one by one in the main method to set the value. I find this second method tedious. Please advice if what I have done is fine/ within Java convention or if there is a better way to do it. Do tell if I need to post more code to make my question more clearer. I can post it all if it would make better sense. Thank you. public Person(String foreName,String surName, int age, double height, String gender){ personCount++; setForeName(foreName); setSurName(surName); setAge(age); setHeight(height); setGender(gender); }
has comment: http://stackoverflow.com/comment/32570570
has answer: http://stackoverflow.com/a/21564519
has answer: http://stackoverflow.com/a/21564503
downvote count: 0
answer count: 7
accepted answer: http://stackoverflow.com/a/21564506
favorite count: 0
tagged with: constructor
has answer: http://stackoverflow.com/a/29827373
has comment: http://stackoverflow.com/comment/32570571
linked to: http://stackoverflow.com/q/15805028
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32570580
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21564506

http://stackoverflow.com/q/21641849
tagged with: arrays
downvote count: 0
has answer: http://stackoverflow.com/a/21642109
tagged with: multiple-columns
has answer: http://stackoverflow.com/a/21641908
upvote count: 1
answer count: 7
has body: /* * Programmer: Olawale Onafowokan * Date: February 6, 2014 * Purpose: Prints the row and column averages */ class Lab4 { public static void main(String[] args) { int [][] scores = {{ 20, 18, 23, 20, 16 }, { 30, 20, 18, 21, 20 }, { 16, 19, 16, 53, 24 }, { 25, 24, 22, 24, 25 }}; outputArray(scores); } public static void outputArray(int[][] array) { int sum= 0; int rowSize = array.length; int columnSize = array[0].length; System.out.println("rows=" + rowSize + "cols=" + columnSize); for (int i = 0; i &lt; array.length; i++) { for (int j = 0; j &lt; array[0].length; j++) { sum += array[i][j]; } System.out.println("Print the sum of rows = " + sum); } for (int i = 0; i &lt; array.length; i++) { sum = 0; sum = sum + array[i][j]; // It is telling me the j can't be resolved } } } The program prints out: rows=4cols=5 Print the sum of rows = 612 Print the sum of rows = 20358 Print the sum of rows = 652058 Print the sum of rows = 20866609 I don’t understand why it isn't adding up the numbers correctly. I am trying to add up each row and column. I am not even sure where these numbers are coming from.
favorite count: 0
possible better answer: http://stackoverflow.com/a/43027231
has answer: http://stackoverflow.com/a/21641864
accepted answer: http://stackoverflow.com/a/21641864
has answer: http://stackoverflow.com/a/21642475
type: AnsweredQuestion
has title: Summing up each row and column in Java
tagged with: row
has answer: http://stackoverflow.com/a/21642406
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/43027231
type: Question
has answer: http://stackoverflow.com/a/21641903

bouncycastle
tags question: http://stackoverflow.com/q/21630458
tags question: http://stackoverflow.com/q/21570972
tags question: http://stackoverflow.com/q/21565369
tags question: http://stackoverflow.com/q/21589523
type: Tag
tag name: bouncycastle

http://stackoverflow.com/a/21592877
downvote count: 0
score: 1
type: Answer
accepted answer of: http://stackoverflow.com/q/21592809
has comment: http://stackoverflow.com/comment/32622273
answers question: http://stackoverflow.com/q/21592809
has body: I'm guessing he/she wants a method that looks like public double theSum(int n) { ... } where n is the number of terms (so that the last term is n/(n+1)). Then the main method will call theSum(??) with some value as the parameter that will be used for n. Of course that will mean you're doing extra computation to print the table, but don't worry about that. (Maybe you should call it m instead of theSum since that what they called the function. I just don't like one-letter function names.)
has comment: http://stackoverflow.com/comment/32623980
has comment: http://stackoverflow.com/comment/32622253
upvote count: 1
type: AcceptedAnswer

http://stackoverflow.com/comment/32725956
type: Comment
comment on: http://stackoverflow.com/a/21615751
type: AnswerComment
score: 0
has text: You meant `quantifier`, not `quantifer`. You should create an issue no GitHub so we can fix this behavior (with a better error message) for the next release: https://github.com/antlr/antlr4/issues

service
tags question: http://stackoverflow.com/q/21577526
tags question: http://stackoverflow.com/q/21658956
tag name: service
tags question: http://stackoverflow.com/q/21597531
tags question: http://stackoverflow.com/q/21561942
type: Tag
tags question: http://stackoverflow.com/q/21675201
tags question: http://stackoverflow.com/q/21555178
tags question: http://stackoverflow.com/q/21536339
tags question: http://stackoverflow.com/q/21517099

http://stackoverflow.com/q/21634410
has body: First off, apologies, I'm new to all this and I'm struggling with Android / Java. Ive spent days looking stuff up and I KNOW I'm doing something stupid but would appreciate someone to tell me why / where I'm going wrong. The app is a simple quiz, puts a picture up, use a spinner to select the answer, press a button to submit, get a toast message to verify and add a score. I know the code is horrendous and a hack but I lack the knowledge to do it more elegantly (part of the reason I'm here). I am trying to place a while loop, using the variable sflags that will be counting up from 0 to 26. When I place it, I can never seem to place it correctly so it works. I suspect some of the code gets broken when I try and wrap it. Here's the (terrible) code : public class MainActivity extends Activity implements TextWatcher { private static final String TAG = "MainActivity"; private EditText mName; private EditText mEmail; private ListView countrieslist; private String comments; private int score = 0; private int sflags = 0; private String emailok; private String answer; private String flags; private Spinner spinnerct; private Object countries; // private AdapterView&lt;ListAdapter&gt; spinnerct; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); countries = getResources().getStringArray(R.array.flagnames); mName = (EditText) findViewById(R.id.name); mEmail = (EditText) findViewById(R.id.email); mEmail.addTextChangedListener(this); } @Override public void afterTextChanged(Editable s) { emailok = s.toString(); String sub_but = getString(R.string.sub_but); boolean valid = emailok.length() &gt; 0 &amp;&amp; emailok.toLowerCase().indexOf(sub_but) == -1; View view = findViewById(R.id.imageButton1); boolean isVisible = view.getVisibility() == View.VISIBLE; if (isVisible == valid) { // No animation required if both values are true or both values are // false return; } Animation anim; if (valid) { vi…
has title: Can't seem to place While loop in the right place - noob Java Android
type: Question
has comment: http://stackoverflow.com/comment/32698540
tagged with: java
tagged with: eclipse
upvote count: 2
has comment: http://stackoverflow.com/comment/32693410
favorite count: 0
tagged with: while-loop
tagged with: android
has comment: http://stackoverflow.com/comment/32695608
score: 2
downvote count: 0
answer count: 0
type: UnansweredQuestion
tagged with: loops

http://stackoverflow.com/comment/32680439
comment on: http://stackoverflow.com/a/21581804
has text: Thanks for your update, when the user entered wrong word it shows the number of trials remaining but it doesn't decrement. I tried to change the outermost if into a `while`statement. Unfortunately, it still doesn't work.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/21519089
type: Answer
answers question: http://stackoverflow.com/q/21519037
has comment: http://stackoverflow.com/comment/32490905
downvote count: 0
score: 1
upvote count: 1
has body: First, constants should only be specified that manner if they do need to be part of the public API, and you should always consider whether an enum would make more sense. However, if it really does make sense to have public constants (intent names for Android, the HTTP status codes), then they should go on the type they belong to. In the case of HTTP status codes, they're most closely associated with HttpServletResponse, which is an interface, and so they go there. If the constants are associated with a class (and it's not a better design to pull an interface out of that class), they should go there.

http://stackoverflow.com/comment/32728208
type: Comment
has text: What if I wanted to make this a JButton. I can only extend one class at a time. Would I have to create another class and then extend that class and so forth.
type: AnswerComment
comment on: http://stackoverflow.com/a/21654196
score: 0

http://stackoverflow.com/comment/32503514
type: AnswerComment
score: 0
type: Comment
has text: He is talking about UTF-8 in the code itself, not about supporting UTF-8 data.
comment on: http://stackoverflow.com/a/21526916

http://stackoverflow.com/q/21514512
score: 0
accepted answer: http://stackoverflow.com/a/21514703
tagged with: socket.io
type: Question
tagged with: java
has body: I am having trouble sending a JSONArray through socket.io in JAVA. With the function below i am trying to authorize the user with his username and token. public static void authorize() { HashMap&lt;String, String&gt; user = Database.getUser(); JSONArray req = new JSONArray(); try { JSONObject reqObj = new JSONObject(); reqObj.put("username", user.get("username")); req.put( reqObj ); reqObj = new JSONObject(); reqObj.put("usertoken", user.get("usertoken")); req.put( reqObj ); } catch (JSONException e) { e.printStackTrace(); } Log.d("WebsocketFunctions", "Authorize: " + req.toString()); Socket.emit("authorize", req); } This is the Log.d("WebsocketFunctions") output: Authorize: [{"username":"admin"},{"usertoken":"45345980983450983"}] But on my node server i only get: debug - websocket writing 1:: {username : 'admin'} What i need is not only the username, but also the usertoken. Somehow the usertoken is not send to the server. This is my node authorize function: authorize: function(socket, data) { console.log('Authorize'); console.log(data); },
answer count: 1
tagged with: websocket
has answer: http://stackoverflow.com/a/21514703
tagged with: android
has title: Java Websocket Emit Array
tagged with: node.js
type: AnsweredQuestion

http://stackoverflow.com/a/21592690
answers question: http://stackoverflow.com/q/21592605
score: -1
upvote count: 0
has body: since complexArray is declared in try block, once execution inside the try block is completed complexArray is out of scope. public static Complex[] parseFromFile(String fileName) { int numOfComplex = 0; try { Scanner sc = new Scanner(new File(fileName)); String firstLine = sc.nextLine(); firstLine = firstLine.trim(); numOfComplex = Integer.parseInt(firstLine); Complex[] complexArray = new Complex[numOfComplex]; for (int i = 0; i &lt; numOfComplex; i++) { String nextLine = sc.nextLine(); nextLine = nextLine.trim(); complexArray[i] = parseComplex(nextLine); } } //&lt;&lt;&lt;=== scope of `complexArray` ends here catch(Exception e) { } return complexArray; } try this public static Complex[] parseFromFile(String fileName) { int numOfComplex = 0; Complex[] complexArray; try { Scanner sc = new Scanner(new File(fileName)); String firstLine = sc.nextLine(); firstLine = firstLine.trim(); numOfComplex = Integer.parseInt(firstLine); complexArray = new Complex[numOfComplex]; for (int i = 0; i &lt; numOfComplex; i++) { String nextLine = sc.nextLine(); nextLine = nextLine.trim(); complexArray[i] = parseComplex(nextLine); } } catch(Exception e) { } return complexArray; } //&lt;&lt;&lt;=== scope of `complexArray` ends here
type: Answer
downvote count: 1
has comment: http://stackoverflow.com/comment/32621026

http://stackoverflow.com/comment/32608683
score: 0
type: AnswerComment
has text: Well, I tried to connect to 10.0.0.2:25555, but if I do, it waits for a few seconds and then gives me this error:`Exception in thread "main" java.net.ConnectException: Connection timed out: connect`
type: Comment
comment on: http://stackoverflow.com/a/21583710

http://stackoverflow.com/comment/32529580
comment on: http://stackoverflow.com/q/21540900
type: Comment
type: QuestionComment
has text: What is `HibernateUtils`? Please add the code to the original post
score: 0

http://stackoverflow.com/q/21621291
possible better answer: http://stackoverflow.com/a/21621320
has title: Count occurence of string in Arraylist
tagged with: arraylist
has answer: http://stackoverflow.com/a/21621320
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/21621408
has comment: http://stackoverflow.com/comment/32670561
accepted answer: http://stackoverflow.com/a/21621382
type: AnsweredQuestion
tagged with: java
linked to: http://stackoverflow.com/q/505928
has body: Let us assume I have the following list . List&lt;String&gt; list=new ArrayList&lt;String&gt;(); list.add("sultan"); list.add("Masum"); list.add("sultan"); list.add("Sorry"); list.add("sultan"); list.add("Masum"); list.add("sultan"); list.add("Tarek"); list.add("sultan"); I want to know the count of occurrence of each string in Arraylist . How can I do that ? And I also want to know the string that is occurred in this Arraylist at highest times. For this particular example, the answer is "Sultan" .
has answer: http://stackoverflow.com/a/21621382
type: Question

http://stackoverflow.com/q/21590567
has comment: http://stackoverflow.com/comment/32618267
type: Question
has title: Methods of custom-implementation of TargetDataLine aren't invoked
has answer: http://stackoverflow.com/a/21591461
has body: I tried to get to work with the javax.sound.sampled-package. I tried implementing my own version of TargetDataLine (for test purposes at this point). To my very dismay, however, when I was done and tried to "play" it, neither one of it's methods were invoked (nor any exceptions raised), but instead, the program froze. The code segment in question looks like this: try { // create stream. AssembledDataLine line = new AssembledDataLine(); AudioInputStream stream = new AudioInputStream(line); // create content. int size = 65536; byte[] array = new byte[size]; byte inc = 1; byte pos = (byte) 0; for (int i = 0; i &lt; size; ++i) { array[i] = (pos += inc); if (pos == 127) { inc = -1; } else if (pos == -128) { inc = 1; } } line.writeArray(array); // play. System.out.println("starting to play."); Clip clip = AudioSystem.getClip(); clip.loop(Clip.LOOP_CONTINUOUSLY); System.out.println("got clip"); clip.open(stream); System.out.println("opened"); clip.start(); Thread.sleep(5000); System.out.println("started"); clip.close(); System.out.println("end."); } catch (Exception e) { e.printStackTrace(); System.out.println("error"); } The above mentioned code will never reach the "opened" statement, or throw an exception. I tried inserting a printout into every single method implemented in AssembledDataLine, but neither of them is ever invoked (with the exception of writeArray, which is called before opening the stream). So at this point i think the Clip.open(stream) method freezes up even before reaching the point of gaining input from the stream. I tried to open a file the same way and it worked, so I figure this is related to the way I instantiate the AudioInputStream.
has comment: http://stackoverflow.com/comment/32618514
tagged with: javax.sound.sampled
score: 0
answer count: 1
has comment: http://stackoverflow.com/comment/32618061
has comment: http://stackoverflow.com/comment/32618550
has comment: http://stackoverflow.com/comment/32618424
tagged with: audio
type: AnsweredQuestion
tagged with: audio-processing
accepted answer: http://stackoverflow.com/a/21591461
tagged with: java

http://stackoverflow.com/comment/32529216
score: 1
comment on: http://stackoverflow.com/q/21540642
has text: The city name is in column 0, so when you find a maximum, remember also the associated city from array[row][0].
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32715525
score: 0
type: Comment
comment on: http://stackoverflow.com/q/21646996
type: QuestionComment
has text: check your credentials again. You should be 100% that it they are right. Also see if the user has permissions to access this database - make sure you use the `GRANT` command to give permissions to this user.

http://stackoverflow.com/comment/32536260
type: AnswerComment
type: Comment
score: 0
comment on: http://stackoverflow.com/a/21545263
has text: Ok i will explain.I have many questions,each question has 9 options(some might be filled some might not be filled.in the above case 3 are filled).optionlist1 is a list,so is optionlist2.....optionlist9,all are lists.optionlist1.get(i)) gets the option1 of the first question(assuming i=1),similarly optionlist2.get(i) gets the option2 of the first question and so on...

http://stackoverflow.com/q/21611037
score: 0
has comment: http://stackoverflow.com/comment/32866872
tagged with: android
has answer: http://stackoverflow.com/a/21628430
has comment: http://stackoverflow.com/comment/32652442
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32655888
has body: Below is the code for my submenu buttons and I'm trying to make it delete the note and return to the main list view. The delete option is called "Red" for now. I copied my delete code from my main activity thinking it would work, but it does not. I'm very new to android coding, so help would be appreciated. This is how I delete in my Main Activity.java @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; currentNoteId = (int)info.id; menu.add(0, MENU_DELETE_ID, 0, "Delete"); } @Override public boolean onContextItemSelected(MenuItem item) { if (item.getItemId() == MENU_DELETE_ID) { Noteitem note = notesList.get(currentNoteId); datasource.remove(note); refreshDisplay(); } return super.onContextItemSelected(item); } Here is my code for my NoteEditorActivity.java Again I'm trying to delete, but I can't seem to figure out how to delete the note from the submenu. @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_exit: EditText et = (EditText)findViewById(R.id.noteText); if (et.length() &gt; 0) { saveAndFinish(); } else { finish(); } case R.id.menu_red: currentNoteId = (int) MENU_DELETE_ID; datasource.remove(note); return true; default: return super.onOptionsItemSelected(item); }
has title: How do I delete an item through the menu?
has comment: http://stackoverflow.com/comment/32652315
tagged with: java
has comment: http://stackoverflow.com/comment/32652140
has comment: http://stackoverflow.com/comment/32938626
has comment: http://stackoverflow.com/comment/32652209
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/32652269
linked to: http://stackoverflow.com/q/2710300
has answer: http://stackoverflow.com/a/21612340
has comment: http://stackoverflow.com/comment/57686371
has comment: http://stackoverflow.com/comment/32652931
has comment: http://stackoverflow.com/comment/32653026
has comment: http://stackoverflow.com/comment/32653385

http://stackoverflow.com/comment/32667349
has text: I've posted my reply as an answer below, since it seems like the root of your problem was in fact that you're pressing the back key instead of actually finishing the Activity.
comment on: http://stackoverflow.com/q/21618628
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32585838
comment on: http://stackoverflow.com/q/21529667
score: 0
type: Comment
type: QuestionComment
has text: OK, accepted answers that were really helpful.

http://stackoverflow.com/a/21634484
has comment: http://stackoverflow.com/comment/32722001
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32731797
has comment: http://stackoverflow.com/comment/32732375
answers question: http://stackoverflow.com/q/21610114
accepted answer of: http://stackoverflow.com/q/21610114
type: Answer
has comment: http://stackoverflow.com/comment/33235613
has comment: http://stackoverflow.com/comment/32743180
has body: Nice question...This problem taken me back to basics of java.. Here we go for the solution.. Car.java package com.sof.test; public class Car { private String model; private String version; public String getModel() { return model; } public void setModel(String model) { this.model = model; } public String getVersion() { return version; } public void setVersion(String version) { this.version = version; } @Override public boolean equals(Object obj) { if(this.model.equals(((Car)obj).getModel())&&this.version.equals(((Car)obj).getVersion())){ return true; } return false; } @Override public int hashCode() { return this.model.length()+this.version.length(); } @Override public String toString() { return this.model+"\t "+this.version; } } cars.xml <?xml version="1.0" encoding="UTF-8"?> maruthi alto maruthi verna maruthi verna maruthi alto maruthi alto honda city Audi Q7 honda city Tester.java package com.sof.test; import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Tester { public static void main(String[] args) { List<Car> carsList=new ArrayList<Car>(); Set<Car> carsset=new HashSet<Car>(); try { File fXmlFile = new File( "D:\\StackOverFlow\\DomParserTest\\src\\com\\sof\\test\\cars.xml"); DocumentBuilderFactory dbFactory = DocumentBuilderFactory .newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(fXmlFile); doc.getDocumentElement().normalize(); NodeList nList = doc.getElementsByTagName("cars"); Car tempCar=null; for (int temp = 0; temp < nList.getLength(); temp++) { Node nNode = nList.item(temp); if (nNode.getNodeType() == Node.ELEMENT_NODE) { tempCar=new Car(); Element eElement = (Element) nNode; tempCar.setModel(eE…
has comment: http://stackoverflow.com/comment/33236295
has comment: http://stackoverflow.com/comment/32729684
has comment: http://stackoverflow.com/comment/32722624
has comment: http://stackoverflow.com/comment/33247030
score: 0

http://stackoverflow.com/q/21529219
has title: mongo query to get chidren when only parent element is known
type: Question
has comment: http://stackoverflow.com/comment/32523785
tagged with: spring-data-mongodb
has answer: http://stackoverflow.com/a/21679720
has comment: http://stackoverflow.com/comment/32507852
score: 0
tagged with: java
accepted answer: http://stackoverflow.com/a/21679720
answer count: 1
has body: EDITED I would like to find the children element when only the parent element is known. I can'f ding the equest (I am using mongodb) Here is the structure: collection: parent2 parent1 id: idParent1 name : parentName1 //no ref to the children elements parent2 id: idParent2 name : parentName2 //no ref to the children elements parent3 id: idParent3 name : parentName3 //no ref to the children elements collection: children child1 id: idChild1 refParent: parent1 id: idChild2 refParent: parent2 id: idChild3 refParent: parent3 id: idChild4 refParent: parent3 id: idChild5 refParent: parent1 The request would be something like Query query = new Query(); query.addCriteria(Criteria.where("child.refParent").is("parent1")); //not working return mongoTemplate.find(query, Chidren.class); The java classes I use to create the collection are: public Parent{ String id; String name; } public Child { String id; String name; Parent parent; }
tagged with: mongodb
type: AnsweredQuestion

http://stackoverflow.com/comment/32642552
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21605480
score: 0
has text: Your method must be static if you want to use it in the main.

http://stackoverflow.com/comment/32676390
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21624937
has text: Thx for your answer! Now my compiler give me back: `The method clone() from the type Object is not visible`

http://stackoverflow.com/comment/32754670
has text: Learn how java packages and import work. That has the solution for your problem.
comment on: http://stackoverflow.com/q/21669272
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/32526700
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21539316
type: AnswerComment
has text: `revalidate` I believe has being around since at least 1.4, probably 1.3. `revalidate` (which simply calls `invalidate` and `validate`) deals with the layout manager API

http://stackoverflow.com/a/21592711
answers question: http://stackoverflow.com/q/21585121
upvote count: 11
has comment: http://stackoverflow.com/comment/32651539
score: 11
type: AcceptedAnswer
downvote count: 0
has body: Basically, what I did was take the PointerInfo and subtract the GraphicsDevice bounds from it, if the result was less the 0 (because the screen was left of the main screen), I multiplied the result by -1 The heart of the solution looks like this... // Pointer info PointerInfo pi = MouseInfo.getPointerInfo(); Point mp = pi.getLocation(); // The devices bounds Rectangle bounds = getDeviceBounds(pi.getDevice()); // Create new "virtual" point based on the mouse point virtualPoint = new Point(mp); // Subtract the x/y position of the device virtualPoint.x -= bounds.x; virtualPoint.y -= bounds.y; // Clip negative values... if (virtualPoint.x &lt; 0) { virtualPoint.x *= -1; } if (virtualPoint.y &lt; 0) { virtualPoint.y *= -1; } The following example shows the actual desktop mouse position (as reported by MouseInfo) on the first line and the second line shows the "screen" position within the context of the GraphicsDevice import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.MouseInfo; import java.awt.Point; import java.awt.PointerInfo; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.Timer; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; public class WheresMyMouse { public static void main(String[] args) { new WheresMyMouse(); } public WheresMyMouse() { EventQueue.invokeLater(new Runnable() { @Override public void run() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) …
has comment: http://stackoverflow.com/comment/35669024
accepted answer of: http://stackoverflow.com/q/21585121
type: Answer

http://stackoverflow.com/comment/32748523
score: 0
type: AnswerComment
has text: Continuing. Event hough `final private int red; final private int green; final private int blue; final private String name;`@Luiggi if I just make the whole class final `final public class Fraction` would this achieve immutability?
type: Comment
comment on: http://stackoverflow.com/a/21572000

http://stackoverflow.com/a/21578938
type: Answer
answers question: http://stackoverflow.com/q/21578853
upvote count: 1
has body: Wrap the double into a BigDecimal first: BigDecimal result = yourBigDecimal.multiply(new BigDecimal(yourDouble));
downvote count: 0
score: 1

http://stackoverflow.com/a/21673358
score: 0
type: AcceptedAnswer
has body: exec takes a String[] not a varargs list so you need to run: Process proc = rt.exec(new String[] {"zsh", "source ./myenv/bin/activate", "python runner.py"}, null, new File("parentdirectoryofmyenv")); As shown you also need to include the working directory for the process or it won't be able to find "./myenv". EDIT: Simplifying this further. I am assuming that "source ./myenv/bin/activate" is setting the environment for the process. This can be done as follows: Process proc = rt.exec( new String[] {"python", "runner.py"}, new String[] {"ENV1=VAL1", "ENV2=VAL2"}, new File("parentdirectoryofrunnerpy"));
has comment: http://stackoverflow.com/comment/32764697
has comment: http://stackoverflow.com/comment/32764069
has comment: http://stackoverflow.com/comment/32761544
accepted answer of: http://stackoverflow.com/q/21672602
has comment: http://stackoverflow.com/comment/32764322
type: Answer
has comment: http://stackoverflow.com/comment/32762353
has comment: http://stackoverflow.com/comment/32769990
answers question: http://stackoverflow.com/q/21672602
has comment: http://stackoverflow.com/comment/32761678
has comment: http://stackoverflow.com/comment/32764219

http://stackoverflow.com/comment/32524165
score: 0
type: Comment
type: QuestionComment
has text: but `add` and `remove` AFAIK are coming from the same place, so shouldn't they both end up with either Object or Activity? in my implementing class
comment on: http://stackoverflow.com/q/21538003

http://stackoverflow.com/a/21518612
has body: The sbt-assembly plugin is the answer. It'll produce a fat jar that includes all your dependencies.
score: 5
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21518341
answers question: http://stackoverflow.com/q/21518341
upvote count: 5
type: Answer
downvote count: 0

http://stackoverflow.com/q/21553779
answer count: 1
tagged with: eclipse
has body: I found that one of my Eclipse installations has org.apache.log4j plugin installed. The provider of this plug-in is labeled as "Eclipse Orbit". Probably it was installed as dependency by some other software I don't know. I see no "orbit" sites among available installation sites in Eclipse preferences. Also I don't see conventional download URL on Orbit page. So how to find and install log4j bundle?
type: AnsweredQuestion
has title: How to install log4j bundle into Eclipse?
downvote count: 0
score: 1
tagged with: log4j
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/21554089
accepted answer: http://stackoverflow.com/a/21554089
tagged with: java
upvote count: 1

http://stackoverflow.com/a/21665267
score: 0
has body: For the first part of your question, I think this answer covers it pretty much. In short, yes you can point both to the same file, no, it is not best practice. As far as the error you are getting, there are many reasons that could happen, but you could try to add the CA to the cacerts file from JAVA_HOME/jre/lib/security. This makes it available to all JAVA applications.
answers question: http://stackoverflow.com/q/21633274
has comment: http://stackoverflow.com/comment/32748406
type: Answer
has comment: http://stackoverflow.com/comment/32761177

http://stackoverflow.com/a/21554298
accepted answer of: http://stackoverflow.com/q/21539307
type: Answer
answers question: http://stackoverflow.com/q/21539307
score: 1
upvote count: 1
type: AcceptedAnswer
downvote count: 0
has body: Java: run as administrator helped to solve my problem. Just make sure to add the Elevate.exe into the folder of your source (where the .class and .java files are), afterwards all administrator commands can be executed by using this code... Runtime.getRuntime().exec("Elevate.exe yourcommand"); Thanks to user mathd for posting that... The elevate program can be found at http://jpassing.com/2007/12/08/launch-elevated-processes-from-the-command-line/ . Thanks to all who helped :)

http://stackoverflow.com/comment/32570647
has text: @user102817 By "print out only the unique numbers" do you mean you need to print out only the numbers that appear once in the file, or you need to print one of every character in the file? (i.e. in a file with {1, 2, 3, 4, 1, 2} do you need to print {3, 4} or {1, 2, 3, 4}?)
comment on: http://stackoverflow.com/q/21564331
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21575488
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
has body: I am trying to fetch the current date with Calender class. I am running my web application on tomcat. But I don't understand why it is displaying the month day as 36. Below is my code. SimpleDateFormat df = new SimpleDateFormat("YYYY/MM/DD hh:mm:ss"); Calendar cal = Calendar.getInstance(); System.out.println("Current Date Time : " + df.format(cal.getTime())); Output Current Date Time : 2014/02/36 04:30:14 Can anyone please explain how can a day be 36? Does the Calender class shows the system time or the tomcat server runs its own time?
has answer: http://stackoverflow.com/a/21577366
type: Question
answer count: 2
has title: Java Calender class showing incorrect date
upvote count: 1
tagged with: datetime
accepted answer: http://stackoverflow.com/a/21575542
possible better answer: http://stackoverflow.com/a/21577366
favorite count: 0
tagged with: time
has answer: http://stackoverflow.com/a/21575542
tagged with: calendar
has comment: http://stackoverflow.com/comment/32592571

http://stackoverflow.com/q/21574040
has comment: http://stackoverflow.com/comment/32611420
has answer: http://stackoverflow.com/a/21581117
type: Question
has body: My application is in struts2. I have requirement that I am storing my application details in session. I cannot remove those attributes from session. After I log-in I have to choose an object to work on. Now I open a new tab and choose another object for working. Due to which my first object values are over written. Hence if in my first tab I do some work wrong information is updated for that action. This is how I am planning to solve the issue. I am trying to set a value in setter method in interceptor class but I cannot access that value in my index.jsp. This interceptor is called on all the actions and index.jsp is also included in every jsp. I will maintain a hashtable which will store the userid and a random string of 40 characters. This id will be unique and I will update the userid after comparing the value present in jsp to value stored against the value stored in hastable. If I find that value matches then I will generate another value and store in jsp and hastable. If value does not matches I will destroy the session. Kindly advice how can I proceed or is there any other work around to achieve the same. code Interceptor class String strFrom = (String)aContext.get(ServletActionContext.ACTION_NAME); HttpServletRequest httpReq = (HttpServletRequest)aContext.get(ServletActionContext.HTTP_REQUEST); HttpSession session = httpReq.getSession(); String sessionValue = (String)httpReq.getSession().getAttribute("sessionValue"); String test = httpReq.getParameter("sessionValue"); if(strFrom.equals("ValidateUser")){ // Do nothing }else if(sessionValue == null &amp;&amp; strFrom.equals("HomePage")){ session.setAttribute("sessionValue", getRandomString(20)); }else if (sessionValue.equals(session.getAttribute("sessionValue"))){ session.setAttribute("sessionValue", getRandomString(20)); }else{ httpReq.setAttribute("message","Session Expired. Please Login Again"); return "loginAgain"; } index.jsp &lt;body&gt; &lt;s:hidden id="hidBidType" value="%{#session.tenderBidType}"/&gt;…
tagged with: session
tagged with: java
tagged with: struts2
score: 0
has title: expiring the session of user if new tab is opened in browser using struts2 interceptors
answer count: 1
tagged with: jsp
type: UnansweredQuestion

http://stackoverflow.com/comment/32537410
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21545822
has text: asdfghjk awesome explanation! A recursion is like a loop! And is ended by the base case. I understand now. Thank you so much Mikescher :D

http://stackoverflow.com/q/21557326
has comment: http://stackoverflow.com/comment/32557686
has comment: http://stackoverflow.com/comment/32557273
answer count: 3
has comment: http://stackoverflow.com/comment/32557433
upvote count: 1
has answer: http://stackoverflow.com/a/21558797
has comment: http://stackoverflow.com/comment/32557492
has body: this code should be calculating the progressive tax by reading the brackets and the tax rates from a file, but it shows an mismatch input error. EDIT: Example that can be compiled and run (but still broken) import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.Scanner; /** &lt;P&gt;{@code java CalculateProgressiveXmpl R:\\jeffy\\programming\\sandbox\\xbnjava\\xbn\\z\\xmpl\\lang\\Taxes.txt}&lt;/P&gt; **/ public class CalculateProgressiveXmpl { private static double baseSalary = 0.0; private static double tax = 0.0; public static final void main(String[] as_1RqdPathToInput) { try { calculateProgressive(as_1RqdPathToInput[0]); } catch(RuntimeException rtx) { if(as_1RqdPathToInput.length == 0) { throw new IllegalArgumentException("One required parameter missing: Path to Taxes.txt"); } throw rtx; } catch(IOException iox) { throw new RuntimeException(iox); } } public static final void calculateProgressive(String s_inputFile) throws FileNotFoundException, IOException { try { Scanner readtax = new Scanner(new FileReader(s_inputFile)); String taxType = readtax.next(); String brackets = readtax.next(); int ammount = readtax.nextInt() - 1; double tax1[] = new double[ammount + 1]; while (readtax.hasNext()) { for (int i = 0; i &lt;= ammount - 1; i++) { double bottombracket = readtax.nextDouble(); double topbracket = readtax.nextDouble(); double ptax = readtax.nextDouble(); if ((bottombracket &lt;= baseSalary) &amp;&amp; (baseSalary &gt;= topbracket)) { tax1[i] = (topbracket - bottombracket) * ptax; } else if ((baseSalary &gt;= bottombracket) &amp;&amp; (baseSalary &lt;= topbracket)) { tax1[i] = (baseSalary - bottombracket) * ptax; } else { if (i == ammount - 1) { double fbottombracket = readtax.nextDouble(); double fptax = readtax.nextDouble(); tax1[i] = (baseSalary - fbottombracket) * ptax; } } tax = tax + tax1[i]; } } } catch (FileNotFoundException e) { e.printStackTrace(); } } } Stack trace: Exception in thread "main" ja…
has comment: http://stackoverflow.com/comment/32557219
favorite count: 0
has comment: http://stackoverflow.com/comment/32557323
has comment: http://stackoverflow.com/comment/32557961
has comment: http://stackoverflow.com/comment/32557451
has answer: http://stackoverflow.com/a/21558238
has title: reading data from file to calculate it when the program runs
has comment: http://stackoverflow.com/comment/32557308
downvote count: 0
has answer: http://stackoverflow.com/a/21557611
accepted answer: http://stackoverflow.com/a/21557611
has comment: http://stackoverflow.com/comment/32557539
has comment: http://stackoverflow.com/comment/32557317
has comment: http://stackoverflow.com/comment/32557289
possible better answer: http://stackoverflow.com/a/21558238
type: Question
has comment: http://stackoverflow.com/comment/32557262
type: AnsweredQuestion
score: 1
tagged with: java

http://stackoverflow.com/comment/32607780
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21585058
has text: Hey thanks, I got it all working. I really appreciate the help.

http://stackoverflow.com/comment/32503424
type: QuestionComment
comment on: http://stackoverflow.com/q/21526132
score: 0
has text: Is the `UserDetailsService` class, in `CrmUserService` and `SecurityConfig` from the same package (`UserDetailsService` is such a common name, that you maybe imported them from two different pacakges.)
type: Comment

http://stackoverflow.com/comment/32783965
score: 0
comment on: http://stackoverflow.com/a/21570620
type: Comment
has text: Thanks! I tried implementing this, but I get the error "tomcat7 at localhost failed to start" when calling openSession() in the doGet() because it seems that the SessionFactory initialization code in the HibernateUtil class is not being called. What am I doing wrong?
type: AnswerComment

http://stackoverflow.com/comment/32632108
score: 0
type: AnswerComment
has text: @Sand No, just Google this. You will find lots of links.
type: Comment
comment on: http://stackoverflow.com/a/21599229

http://stackoverflow.com/q/21627631
possible better answer: http://stackoverflow.com/a/21627713
has comment: http://stackoverflow.com/comment/32764159
accepted answer: http://stackoverflow.com/a/21675865
has comment: http://stackoverflow.com/comment/32682996
type: AnsweredQuestion
has body: Hello I've reduced the code to this simple one: Code from Server byte[] data=new byte[1024]; try { providerSocket=new ServerSocket(port); while(true) { connection=providerSocket.accept(); in=connection.getInputStream(); StringBuffer sb=new StringBuffer(); while((len=in.available())&gt;0) { in.read(data,0,len); sb.append(new String(data,0,len)); reset(data); //writes -1 value to all bytes... len=0; } System.out.println("Get "+sb.toString()); //does the same if I close() in, connection or do not close anything } } catch(IOException ioException){ } The client does somethig like: Socket socket = new Socket(ip, port); OutputStream out = socket.getOutputStream(); String s="Sample text"; out.write(s.getBytes()); out.flush(); out.close(); socket.close(); //closes cliente program When I run Server and then I run client output is "Get Sample text", if I run again client output is "Get " whitout anything more, sure the error is very simple but I've tried everything I'm not viewing where it fails!!! Why am I receiving ok the first transmission but not the next transmissions sent? Sure my sample code has failures like not closing inputstream etc, but it does not change result if after the System.out.println() I write in.close() and/or connection.close() Regards.
has title: Java network server/client, cant find where is the failure
tagged with: java
has comment: http://stackoverflow.com/comment/32683096
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/21627713
score: 0
has answer: http://stackoverflow.com/a/21675865
has comment: http://stackoverflow.com/comment/32681513

http://stackoverflow.com/q/21648123
answer count: 1
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/21648174
has body: I have been able to create a grid using an image file (serves as the empty circles), a loop, and GridLayout, but I am well aware that there's more functionality needed (like for dropping the token, though no animation is necessary yet) so I scrapped it and now I'm back to an empty grid. I am stuck and I'm not really sure how I can accomplish this. My code is a mess at the moment so I'm not sure if it'd even make sense for me to post it. My main problem is how to build a grid, which will then just be filled with a solid color (I'm cancelling using an image file, it seems a little more complicated as far as I'm concerned) with empty circles, that I will be able to fill up with an image file of a token once the player clicks on a button that corresponds to the column he chose (and then reset everything after the game is over). In other words, a rectangle of solid color and with empty circles to be filled up by tokens, but not with solid color, but an image file. I have been trying to familiarize myself with paint() but I only started learning GUI last week so there are still likely some more things I'll have to learn to probably understand it in a considerable degree. I am running out of options tantamount to my knowledge of GUI (Swing in particular) and I have been trying to work on this for a week now. Any hints?
tagged with: paint
upvote count: 1
tagged with: swing
accepted answer: http://stackoverflow.com/a/21648174
type: AnsweredQuestion
has title: Grid building for Connect Four gui
score: 1
tagged with: java
type: Question
tagged with: grid-layout

http://stackoverflow.com/comment/82664041
has text: I down voted because this question is not finished and does not make sense, interesting how normal questions gets closed so easily but this one survived without correction.
comment on: http://stackoverflow.com/q/21578432
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/32701263
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21516540
has text: it is still discouraged to create custom application threads, but there are other ways. If you give more details on the use case we might be able to propose an alternative. Can you tell us what is the custom thread used for, why is it needed? and what technology stack do you use (Spring/Hibernate, EJB3...)?
type: Comment

http://stackoverflow.com/comment/32679562
type: Comment
has text: Out of interest how where you using contains?
comment on: http://stackoverflow.com/a/21626751
score: 0
type: AnswerComment

http://stackoverflow.com/q/21564331
has answer: http://stackoverflow.com/a/21564442
has comment: http://stackoverflow.com/comment/32570373
accepted answer: http://stackoverflow.com/a/21564430
possible better answer: http://stackoverflow.com/a/21564442
upvote count: 3
has comment: http://stackoverflow.com/comment/32570691
answer count: 2
downvote count: 1
has comment: http://stackoverflow.com/comment/32570253
has comment: http://stackoverflow.com/comment/32570390
tagged with: if-statement
has title: Java Program: Where am I going wrong?
tagged with: java
has comment: http://stackoverflow.com/comment/32570647
has comment: http://stackoverflow.com/comment/32570324
has comment: http://stackoverflow.com/comment/32570391
has comment: http://stackoverflow.com/comment/32570307
score: 2
has answer: http://stackoverflow.com/a/21564430
type: AnsweredQuestion
tagged with: arrays
has comment: http://stackoverflow.com/comment/32570815
has body: Problem: Write a program that reads a list of real numbers. After the program ends it should print out only the unique numbers. That is, only numbers that appear once in the list. If there are more than 50 unique numbers on the list, then you should only print the first 50. import java.util.*; import java.io.*; import java.util.Arrays; public class Hmwk { public static void main(String[] args) throws FileNotFoundException { Scanner input=new Scanner (new File ("input.txt")); int n = 0; final int MAX_SIZE = 50; double[] numbersArray = new double[MAX_SIZE]; while (input.hasNextDouble() &amp;&amp; n&lt;MAX_SIZE){ double in = input.nextDouble(); if (!inList(in,numbersArray)){ numbersArray[n]=in; n++; } } double[] uniqueArray = Arrays.copyOfRange(numbersArray, 0, n); printReport(uniqueArray); } public static boolean inList(double number, double[] list){ for (double i : list) { if (Math.abs(i-number) &lt;0.00000000001){ return true; } } return false; } public static void printReport(double[] list) { System.out.println("The unique numbers were"); System.out.println(Arrays.toString(list)); } } It's running well but I can't seem to figure out where my logic is going wrong. I'm running it against the input.txt of 5 6 7 8 9 0 9 8 0 and my output is The unique numbers were [5.0, 6.0, 7.0, 8.0, 9.0] My roommate and I can't seem to pinpoint my problem. I THINK i've accounted for every mistake that could be made, but then again computers are better at doing what you tell them to do instead of what you want them to do. If anyone could pinpoint my problem and show me how to fix it i'd be forever grateful. Thanks for your time.
favorite count: 0
has comment: http://stackoverflow.com/comment/32570320
tagged with: while-loop
type: Question

http://stackoverflow.com/a/21585991
has body: The code is not equivalent, and relies on python's ability to assign multiple primitives in one line a,b=b,a+b; you need a temporary variable - public static int fib2(int n){ int a = 0; int b =1; while(n-- &gt;0){ int t = b; // &lt;-- to hold the original value of b. b = a + b; a = t; } return a; }
score: 5
answers question: http://stackoverflow.com/q/21585932
has comment: http://stackoverflow.com/comment/32609229
upvote count: 5
has comment: http://stackoverflow.com/comment/32609117
type: Answer
downvote count: 0

http://stackoverflow.com/comment/32712359
type: QuestionComment
has text: `lMas[10 - i] = bMas[10];` should be give array out-of index at i= 0
comment on: http://stackoverflow.com/q/21645265
score: 0
type: Comment

http://stackoverflow.com/comment/32717595
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21648120
has text: @Hichamov I don't think that is possible. You've to create an instance to check the instance, as you can't use `instanceof` with `Class<MyType>`.
type: AnswerComment

http://stackoverflow.com/a/21561280
answers question: http://stackoverflow.com/q/21561018
has comment: http://stackoverflow.com/comment/32570251
has comment: http://stackoverflow.com/comment/32571357
score: 0
has comment: http://stackoverflow.com/comment/32570148
has comment: http://stackoverflow.com/comment/32569849
has comment: http://stackoverflow.com/comment/32569516
has body: Corrected your compilation problems, and looks like it works just fine, with the expected behaviour. Also, follow Java naming conventions - functions start with lower case. Pet.java public interface Pet { public String talk(); } Dog.java public class Dog implements Pet{ public String talk() { return "Woof!"; } } Person.java import java.util.ArrayList; public class Person { ArrayList&lt;Pet&gt; pets = new ArrayList&lt;Pet&gt;(); public Person() { pets.add(new Dog()); } public void makePetsSpeak() { for(int i=0; i &lt; pets.size(); i++) { System.out.println(pets.get(i).talk()); } } } Main.java public class Main { public static void main(String [] args) { Person p = new Person(); p.makePetsSpeak(); } } Output: Woof!
has comment: http://stackoverflow.com/comment/32569643
type: Answer
has comment: http://stackoverflow.com/comment/32569931
has comment: http://stackoverflow.com/comment/32570347

http://stackoverflow.com/q/21565231
type: AnsweredQuestion
upvote count: 3
tagged with: java
has comment: http://stackoverflow.com/comment/32572144
type: Question
has answer: http://stackoverflow.com/a/21565398
score: 3
tagged with: casting
tagged with: type-conversion
has title: Dont understand the result of conversion of type double to type byte
downvote count: 0
answer count: 1
favorite count: 0
has body: Hello i had task from my book to write this code public class EkspKonverzija { public static void main(String args[]) { byte b; int i=257; double d= 323.142; b=(byte) i; System.out.println("i and b "+i+" "+b); i=(int) d; System.out.println("d and i "+d+" "+i); b=(byte) d; System.out.println("b and d "+b+" "+d); } } And result is: i and b 257 1 d and i 323.142 323 d and b 323.142 67 I understand why the result of first conversion is 1, and i also understand the second conversion, but i dont undetsand why is result 67 at last conversion, i cant figure it out so i need your help. Thanks
accepted answer: http://stackoverflow.com/a/21565398
has comment: http://stackoverflow.com/comment/32572381

http://stackoverflow.com/comment/32639810
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21604009
has text: If I'm not mistaken (from what I remember also on other languages), this "0x" is just to indicate the base of the number you put after. "0x20" would mean "20 in base 16" which is equal to 32 in base 10

http://stackoverflow.com/q/21540645
has comment: http://stackoverflow.com/comment/32528839
type: Question
type: AnsweredQuestion
tagged with: android-fragments
tagged with: java
has comment: http://stackoverflow.com/comment/32529616
score: 0
has answer: http://stackoverflow.com/a/21558184
answer count: 1
has comment: http://stackoverflow.com/comment/32541975
has title: addView() Framelayout in fragment
tagged with: android
has body: I tried to view the camera in my FrameLayout fragment. However, i got java.lang.NullPointerException. This is the fragment code: public class ScanFragment extends Fragment { public ScanFragment(){} private Camera mCamera; private CameraPreview mPreview; private Handler autoFocusHandler; private static final String TAG_PID = "pid"; TextView scanText; ImageScanner scanner; private boolean barcodeScanned = false; private boolean previewing = true; static { System.loadLibrary("iconv"); } public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_home, container, false); autoFocusHandler = new Handler(); mCamera = getCameraInstance(); /* Instance barcode scanner */ scanner = new ImageScanner(); scanner.setConfig(0, Config.X_DENSITY, 3); scanner.setConfig(0, Config.Y_DENSITY, 3); mPreview = new CameraPreview(this.getActivity(), mCamera, previewCb, autoFocusCB); FrameLayout preview = (FrameLayout) rootView.findViewById(R.id.cameraPreview); preview.addView(mPreview); scanText = (TextView) rootView.findViewById(R.id.scanText); return rootView; } // create object CameraPriew mPreview = new CameraPreview(this.getActivity(), mCamera, previewCb, autoFocusCB); FrameLayout preview = (FrameLayout) rootView.findViewById(R.id.cameraPreview); // View Camera in FrameLayout of the fragment preview.addView(mPreview); This is the layout for the fragment: &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="match_parent" android:layout_height="match_parent"&gt; &lt;FrameLayout android:id="@+id/cameraPreview" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" /&gt; &lt;TextView android:id="@+id/scanText" android:text="" android:layout_heig…
accepted answer: http://stackoverflow.com/a/21558184

http://stackoverflow.com/comment/32700867
type: QuestionComment
has text: 3 3 3 x would output 3 rows and 3 columns of 3 by 3 squares, I included it in my original post editted
score: 0
comment on: http://stackoverflow.com/q/21637986
type: Comment

http://stackoverflow.com/q/21610834
has comment: http://stackoverflow.com/comment/32652132
has title: Link to another java class
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32652687
has answer: http://stackoverflow.com/a/21610961
has comment: http://stackoverflow.com/comment/32676794
score: 0
has answer: http://stackoverflow.com/a/21610916
upvote count: 1
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/32652288
has body: I have three classes in one folder: Waehrung same as currency in Englisch! public abstract class Waehrung { public abstract double dollarBetrag(); } USDollar public class UsDollar extends Waehrung { private double wert; public UsDollar(double wert){ this.wert = wert; } public double dollarBetrag(){ return wert; } } Yen public class Yen extends Waehrung{ double wert; private static double kurs; public Yen(double wert){ this.wert = wert; } public void setKurs(double kurs){ this.kurs = kurs; } public double dollarBetrag(){ return wert * kurs; } } Now i worte another java Class that should make use of the others: Bank public class Bank { public static void main(String[] args){ Yen yen = new Yen(34); Yen.setKurse = (1.0/130); System.out.println(yen.dollarBetrag); } } My problem is that i do not understand how to link against the other classes! I made some tries with import package but it never compiled correctly! What do i wrong or how can i fix this!
possible better answer: http://stackoverflow.com/a/21610886
tagged with: java
has comment: http://stackoverflow.com/comment/32651849
has answer: http://stackoverflow.com/a/21610886
accepted answer: http://stackoverflow.com/a/21610961
answer count: 3
favorite count: 0

http://stackoverflow.com/comment/32658566
type: Comment
has text: I passed connectionSocket to a new thread, but I couldn't move all the process inside run method, it will throw a lot of errors.
score: 0
comment on: http://stackoverflow.com/a/21613863
type: AnswerComment

http://stackoverflow.com/comment/32574608
type: Comment
type: QuestionComment
has text: The `while` part of a `do`..`while` statement (or a `while` statement without `do`) can test any boolean expression you want, and the expression can use as many variables as you wish.
comment on: http://stackoverflow.com/q/21566446
score: 0

http://stackoverflow.com/q/21633630
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/21634994
has body: How can I move a sprite left or right, if there is a slope? If it was only a straight line, there will be something like if(Pressed(Keys.Left)) position.x-=5; if(Pressed(Keys.Right)) position.x+=5; But what if i have something like this How i do to tell the sprite to go up or down while going left or right? I'm using libGDX.
possible better answer: http://stackoverflow.com/a/21634117
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/21634994
has answer: http://stackoverflow.com/a/21634117
has comment: http://stackoverflow.com/comment/32692015
has answer: http://stackoverflow.com/a/21634256
has comment: http://stackoverflow.com/comment/32691879
has title: Move a sprite left or right on straight line or a slope
has comment: http://stackoverflow.com/comment/32691929
type: AnsweredQuestion
tagged with: libgdx

http://stackoverflow.com/comment/32543646
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21549302
has text: It's probably close to the same, hmm. But what do you want more than no collisions?

http://stackoverflow.com/comment/32740998
score: 0
has text: My output is at the top.
type: QuestionComment
comment on: http://stackoverflow.com/q/21661111
type: Comment

http://stackoverflow.com/a/21590481
has comment: http://stackoverflow.com/comment/32621287
type: Answer
has body: This can be done in a million different ways. If you can make use of Angular, here's an example HTML markup for the dropdown menu Click me for a dropdown, yo! {{choice}} Setting up the initial values for the dropdown. Typically, you would be retrieving this from the Backend application with an ajax/rest call. function DropdownCtrl($scope) { $scope.items = [ "The first choice!", "And another choice for you.", "but wait! A third!" ]; $scope.newItem={}; } Next step is to create a form to let users add to the menus. Some like.. Name: Description: RESET SAVE form = master = and then, write a controller to add it to the existing item list and also send the updates to the backend. Something like this function Controller($scope) { function addToDropdown(){ $scope.items.push(angular.copy(newItem)); $scope.newItem={}; } } You can post this data back to the backend using $http service or angular or a module called Restangular. This is a basic guide to get started. Hope it helps.
score: 2
downvote count: 0
upvote count: 2
answers question: http://stackoverflow.com/q/21588789

http://stackoverflow.com/a/21547905
has comment: http://stackoverflow.com/comment/32544713
has comment: http://stackoverflow.com/comment/32542984
upvote count: 6
has comment: http://stackoverflow.com/comment/123654549
type: AcceptedAnswer
type: Answer
has body: Full-screen can be somewhat problematic on different platforms, so the implementation of full-screen is left to a strategy implementation that you can choose or implement yourself. As it happens, Windows is the most problematic platform for full-screen. With vlcj 3.0.0+ there is a new full-screen strategy implementation that uses the Win32 native API. This is the most reliable and therefore recommended way to achieve full-screen on Windows. You choose the strategy implementation when you create your media player: EmbeddedMediaPlayer mediaPlayer = mediaPlayerFactory.newEmbeddedMediaPlayer(new Win32FullScreenStrategy(frame)); Later when you want to toggle full-screen: mediaPlayer.toggleFullScreen(); Or: mediaPlayer.setFullScreen(boolean fullScreen); If you want to listen to mouse-clicks, then in principle all you do is add a MouseListener as you would usually do to your Canvas object. However, with Windows it's not so simple to detect mouse-clicks, you must do this when you create your media player: mediaPlayer.setEnableMouseInputHandling(false); mediaPlayer.setEnableKeyInputHandling(false); Then in your MouseListener implementation you can invoke one of the full-screen methods described above. Note also that you must prevent your mediaPlayer reference from being garbage collected. Usually it is enough to declare it as a class field rather than a heap variable (as you have in your posted code). You should also look here for examples: https://github.com/caprica/vlcj/blob/vlcj-3.0.1/src/test/java/uk/co/caprica/vlcj/test/fullscreen https://github.com/caprica/vlcj/blob/vlcj-3.0.1/src/test/java/uk/co/caprica/vlcj/test/fullscreen/Win32FullScreenPlayerTest.java
has comment: http://stackoverflow.com/comment/123656662
downvote count: 0
score: 6
accepted answer of: http://stackoverflow.com/q/21546540
answers question: http://stackoverflow.com/q/21546540

http://stackoverflow.com/q/21631378
tagged with: java
upvote count: 1
type: Question
tagged with: jakarta-ee
has comment: http://stackoverflow.com/comment/32691738
has comment: http://stackoverflow.com/comment/32697647
tagged with: jndi
tagged with: serializable
tagged with: apache-tomee
downvote count: 0
score: 1
favorite count: 0
has title: Using JNDI to share objects beetween differends Java programs
type: UnansweredQuestion
has body: I'm trying to run the following example but I did not succeed. The intention is sharing objects through JNDI between two Java programs running on different virtual machines. I'm using TomEE 1.5.1 and TomEE 1.6 The JNDI parameters that I'm using are: Hashtable&lt;String, String&gt; ctxProps = new Hashtable&lt;String, String&gt;(); ctxProps.put("java.naming.factory.initial","org.apache.openejb.client.RemoteInitialContextFactory"); ctxProps.put("java.naming.provider.url", "http://myjndihost.com:8080/tomee/ejb"); ctxProps.put("java.naming.security.principal", "tomee"); ctxProps.put("java.naming.security.credentials", "tomee"); The Sharing class provide 3 methods: connect (called within the constructor), set and get, and It's source code is here: public class Sharing { private Context context=null; public Sharing() throws Exception { connect(); } private void connect() throws Exception { Hashtable&lt;String, String&gt; ctxProps = new Hashtable&lt;String, String&gt;(); ctxProps.put("java.naming.factory.initial","org.apache.openejb.client.RemoteInitialContextFactory"); ctxProps.put("java.naming.provider.url", "http://localhost:8080/tomee/ejb"); ctxProps.put("java.naming.security.principal", "tomee"); ctxProps.put("java.naming.security.credentials", "tomee"); context=new InitialContext(ctxProps); context=context.createSubcontext("DEMO"); } public void set(String key, Serializable value) throws Exception { try { context.bind(key,value); } catch(NameAlreadyBoundException ex) { context.rebind(key,value); } } public Object get(String key) throws Exception { try { return context.lookup(key); } catch(NameNotFoundException e) { return null; } } } Then, I run this TestSet.java public class TestSet { public static void main(String[] args) throws Exception { Sharing share = new Sharing(); share.put("fecha", new Date()); } } It's throught an javax.naming.OperationNotSupportedException: Exception in thread "main" javax.naming.OperationNotSupportedException at org.apache.openejb.client.…
has comment: http://stackoverflow.com/comment/32687858
has comment: http://stackoverflow.com/comment/32688487
answer count: 0

http://stackoverflow.com/comment/32770382
has text: @CommonsWare i have a logcat application on my phone. it gives me a line with an error on it. and thats what i go look at, im not sure what a java stack trace is.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21677961
score: 0

http://stackoverflow.com/comment/32610116
score: 0
has text: I did change it to public void setVideos(List<Cmd> videos) { this.videos = videos; } as you suggested... which resulted in a new error: "The method setVideos(List<Cmd>) in the type Cmd is not applicable for the arguments (String) SAXXMLHandler.java"
type: Comment
comment on: http://stackoverflow.com/a/21583916
type: AnswerComment

http://stackoverflow.com/comment/32603490
comment on: http://stackoverflow.com/a/21583045
type: AnswerComment
score: 0
type: Comment
has text: In fact, the explanation is that `String`s are zero based arrays, and the exception raises when `i` is greater or equal than `theCode.length`, noted in `theCode.charAt(i)` inside the loop.

http://stackoverflow.com/q/21642905
has comment: http://stackoverflow.com/comment/32708649
has comment: http://stackoverflow.com/comment/32708763
has body: I have made the jar file with .class files. Now, i want include classes from but it's giving me an error, How to resolve this issue?
has comment: http://stackoverflow.com/comment/32708894
tagged with: java
has answer: http://stackoverflow.com/a/21643120
type: Question
has comment: http://stackoverflow.com/comment/32708588
has comment: http://stackoverflow.com/comment/32708570
has comment: http://stackoverflow.com/comment/32708960
answer count: 1
has comment: http://stackoverflow.com/comment/32709083
has comment: http://stackoverflow.com/comment/32708601
score: 0
tagged with: netbeans
has comment: http://stackoverflow.com/comment/32708849
has title: After adding a .jar file to a project in netbeans, how do I import classes in it to my project in netbeans?
type: UnansweredQuestion

http://stackoverflow.com/comment/32672500
has text: Yes It is possible but you need to use AsyncTask class. You shouldnt run network operation in MainActivity Directly.
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/21622574

http://stackoverflow.com/comment/32561438
type: Comment
comment on: http://stackoverflow.com/a/21559186
score: 0
has text: can you post host name (input by user)?
type: AnswerComment

http://stackoverflow.com/comment/32759363
comment on: http://stackoverflow.com/q/21672177
score: 0
has text: I dont know anything about caching at the moment, I've left learning this for a later stage. I need this object to be accessible during the lyfecicle of the app until the user logs out (they may not want to log out for days or even weeks)
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21618596
favorite count: 0
tagged with: maven
has body: I have a JavaFX program that uses Maven, with a standard maven file tree: How do I reference logo.png from within layout.fxml, assuming that layout is being inflated by a call to Parent root = FXMLLoader.load(getClass().getResource("/fxml/layout.fxml")); in MainApp. I've trying to do so using &lt;image&gt; &lt;Image url="@/graphics/logo.png" /&gt; &lt;/image&gt; and have tried many variations on that file path (with and without the @), but keep throwing a java.lang.reflect.InvocationTargetException ... Caused by: java.lang.IllegalArgumentException: URL must not be empty on the line where the URL is created
type: AnsweredQuestion
score: 2
has title: Referencing class resource in FXML
downvote count: 0
tagged with: java
tagged with: javafx
accepted answer: http://stackoverflow.com/a/21620168
type: Question
has answer: http://stackoverflow.com/a/21620168
upvote count: 2
answer count: 1

http://stackoverflow.com/a/21599727
upvote count: 2
answers question: http://stackoverflow.com/q/21598320
type: Answer
score: 2
accepted answer of: http://stackoverflow.com/q/21598320
has body: I think I have a crude example. Say you have to work with 2 APIs - one of them is related to mobiles and the other to books. Say the mobile API developer gives you this API: public class MobileList { private Mobile[] mobiles; //other fields public void addMobileToList(Mobile mobile) { //some code to add mobile } public void getMobileAtIndex(int index) { return mobiles[index]; } //maybe other methods } And say the books API developer gives you this API: public class BookList { private Book[] books; //other fields public void addBook(Book book) { //some code to add book } public Book[] getAllBooks() { return books; } } Now if your piece of code works only on the following 'products' interface: interface Products { void add(Product product); Product get(int index); } you'd have to write following 'adapter' objects that implement your required interface: class MobileListAdapter implements Products { private MobileList mobileList; public void add(Product mobile) { mobileList.addMobileToList(mobile); } public Product get(int index) { return mobileList.getMobileAtIndex(index); } } class BookListAdapter implements Products { private BookList bookList; public void add(Product book) { bookList.add(book); } public Product get(int index) { return bookList.getAllBooks()[index]; } } Note that each such Product API can have various methods and various method names as well. If your code is expecting to work only on the Products interface, you'd have to write such 'adapters' for every new Product that came in. That's where Java collections help (java.util.List for this specific example). With Java's List interface, the developers can simply give out List&lt;Mobile&gt; and List&lt;Book&gt; and you can simply call get(index) or add(product) on these Lists without requiring any adapter classes. This is because now the MobileList and BookList have common set of method names and behaviors. I think this is what is meant in the documentation where it says By facilitating interoperability a…
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/21552984
answers question: http://stackoverflow.com/q/21552901
upvote count: 2
type: Answer
has body: I haven't try this but this seems appropriate: http://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html#normalize%28%29
score: 2
downvote count: 0

http://stackoverflow.com/tag/csv
type: Tag
tags question: http://stackoverflow.com/q/21642548
tags question: http://stackoverflow.com/q/21609839
tags question: http://stackoverflow.com/q/21637293
tag name: csv
tags question: http://stackoverflow.com/q/21592097
tags question: http://stackoverflow.com/q/21524282
tags question: http://stackoverflow.com/q/21644388
tags question: http://stackoverflow.com/q/21653323
tags question: http://stackoverflow.com/q/21673667
tags question: http://stackoverflow.com/q/21567497
tags question: http://stackoverflow.com/q/21523050
tags question: http://stackoverflow.com/q/21658579
tags question: http://stackoverflow.com/q/21642837
tags question: http://stackoverflow.com/q/21587566
tags question: http://stackoverflow.com/q/21622660

http://stackoverflow.com/comment/32657917
type: QuestionComment
comment on: http://stackoverflow.com/q/21613416
score: 0
has text: @Pedantic, the isse happens because "allSupportedTypes" contains application/json and it is added to setAccept. I need to figure out why json is set and how to change it. Thanks a lot
type: Comment

http://stackoverflow.com/a/21669472
answers question: http://stackoverflow.com/q/21669459
type: Answer
upvote count: 6
score: 6
has body: 'b' and 'c' are not Strings, they are chars. You should use double quotes "..." instead: System.out.println("b" + "c"); You are getting an int because you are adding the unicode values of those characters: System.out.println((int) 'b'); // 98 System.out.println((int) 'c'); // 99 System.out.println('b' + 'c'); // 98 + 99 = 197
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32755001
accepted answer of: http://stackoverflow.com/q/21669459

http://stackoverflow.com/q/21579247
has answer: http://stackoverflow.com/a/65455650
answer count: 7
has answer: http://stackoverflow.com/a/65839810
has body: I'm having some issues to configure properly my eclipse to work with maven. I create a new project, this one is correctly build with maven in command line (mvn install), but in Eclipse I got this error: CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:3.1 (): ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-settings:jar:2.2.1: ArtifactResolutionException: Failure to transfer org.apache.maven:maven-settings:pom:2.2.1 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-settings:pom:2.2.1 from/to central : NullPointerException pom.xml /test line 9 Maven Project Build Lifecycle Mapping Problem Here is my settings.xml conf : true http myuser $mymdp myhost 8080 some.host.com .... central central repo m2 http://central.maven.org/maven2 I choose the correct maven installation (in Preference -> Maven -> Install) I also direct my user settings on the correct settings.xml (Preferences -> Maven -> User Settings) But I still got this error in Eclipse and everything goes well with maven command line. Do you have and idea?
linked to: http://stackoverflow.com/q/21909466
favorite count: 0
has answer: http://stackoverflow.com/a/39147471
possible better answer: http://stackoverflow.com/a/42263843
has answer: http://stackoverflow.com/a/48815383
has answer: http://stackoverflow.com/a/42263843
tagged with: maven-compiler-plugin
has answer: http://stackoverflow.com/a/70773134
accepted answer: http://stackoverflow.com/a/22372773
linked to: http://stackoverflow.com/q/32050244
tagged with: java
score: 16
tagged with: maven
downvote count: 1
upvote count: 17
type: Question
type: AnsweredQuestion
tagged with: eclipse
has answer: http://stackoverflow.com/a/22372773
has title: Plugin org.apache.maven.plugins:maven-compiler-plugin or one of its dependencies could not be resolved

http://stackoverflow.com/comment/32760920
type: QuestionComment
score: 0
has text: @ rocketboy I have added it in the question.
type: Comment
comment on: http://stackoverflow.com/q/21673034

http://stackoverflow.com/q/21537357
score: -1
favorite count: 0
tagged with: swing
downvote count: 1
tagged with: jbutton
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21537673
tagged with: java
type: Question
linked to: http://stackoverflow.com/q/776180
answer count: 2
upvote count: 0
possible better answer: http://stackoverflow.com/a/21537755
has comment: http://stackoverflow.com/comment/32523266
accepted answer: http://stackoverflow.com/a/21537673
has answer: http://stackoverflow.com/a/21537755
has body: i'd like this button to (on click) draw an Oval. Problem is that eclipse says something about missing semicolons (in the action listener definition) and i dont understand why. Whats the proper way of passing methods (bulid in or custom) to the action listeners? public class figury implements ActionListener { public figury() { frame(); } public void frame() { JFrame f = new JFrame(); f.setVisible(true); f.setSize(480, 480); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel p = new JPanel(); JButton kolo = new JButton("Rysuj kolo"); JButton kolo = new JButton("Rysuj kwadrat"); kwadrat.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { public void paintComponent(Graphics g){ g.fillOval(50,50,100,100); g.setColor(Color.RED); } } }); p.add(kolo); f.add(p); } public static void main(String[] args) { new figury(); } }
has title: Jbutton that draws on a new Jpanel
tagged with: paintcomponent

http://stackoverflow.com/q/21546770
has answer: http://stackoverflow.com/a/21548864
favorite count: 0
upvote count: 2
type: UnansweredQuestion
score: 2
has title: Gabor wavelets in 2d image
tagged with: java
has body: I use lire, java for image retrieval project and I want to calculate the amplitude of gabor wavelet for every pixel of my input image ref here. The default function in lire library return a downsampled feature vector. What I want the computed amplitude of the gabor wavelets. I am trying to create a function getMagnitude: public double[][] getMagnitude(BufferedImage image) { image = ImageUtils.scaleImage(image, MAX_IMG_HEIGHT); Raster imageRaster = image.getRaster(); System.out.println(imageRaster); int[][] grayLevel = new int[imageRaster.getWidth()][imageRaster.getHeight()]; int[] tmp = new int[3]; for (int i = 0; i &lt; imageRaster.getWidth(); i++) { for (int j = 0; j &lt; imageRaster.getHeight(); j++) { grayLevel[i][j] = imageRaster.getPixel(i, j, tmp)[0]; } } double[][] magnitudes = computeMagnitudes(grayLevel); return magnitudes; } The gabor features are class gabor private variables: private static final double U_H = .4; private static final double U_L = .05; private static final int S = 1, T = 1; // filter mask size private static final int M = 4, N = 5; // scale &amp; orientation private static final int MAX_IMG_HEIGHT = 64; Moreover, it seems that the size of the final magnitude array is affected from the size of M, N scale and orientation. What I ve got to do in order to get the case I want? COmpute magnitude function: private double[][] computeMagnitudes(int[][] image) { double[][] magnitudes = new double[M][N]; for (int i = 0; i &lt; magnitudes.length; i++) { for (int j = 0; j &lt; magnitudes[0].length; j++) { magnitudes[i][j] = 0.; } } if (this.gaborWavelet == null) { precomputeGaborWavelet(image); } for (int m = 0; m &lt; M; m++) { for (int n = 0; n &lt; N; n++) { for (int x = S; x &lt; image.length; x++) { for (int y = T; y &lt; image[0].length; y++) { magnitudes[m][n] += Math.sqrt(Math.pow(this.gaborWavelet[x - S][y - T][m][n][0], 2) + Math.pow(this.gaborWavelet[x - S][y - T][m][n][1], 2)); } } } } return magnitudes; }
tagged with: information-retrieval
tagged with: image
type: Question
downvote count: 0
answer count: 1

http://stackoverflow.com/comment/32606366
score: 0
comment on: http://stackoverflow.com/q/21583749
type: Comment
type: QuestionComment
has text: You have your input in a String, so you should use a StreamSource(Reader reader) with a StringReader from that inputXML.

http://stackoverflow.com/comment/32667625
type: AnswerComment
type: Comment
has text: now I am getting this error "HTTP method GET is not supported by this URL"
comment on: http://stackoverflow.com/a/21603547
score: 0

http://stackoverflow.com/a/33664507
answers question: http://stackoverflow.com/q/21519021
type: Answer
has body: import java.util.Scanner; public class CountNumOccurences { public static void main(String[] args){ Scanner input = new Scanner(System.in); int[] frequency = new int[100]; System.out.println("Enter the first integer: "); int number = input.nextInt(); //Enter up to 100 integers, 0 to terminate while (number != 0){ ++frequency[number]; //read the next integer System.out.print( "Enter the next int value (zero to exit): "); number = input.nextInt(); } input.close(); System.out.println("Value\tFrequency"); for (int i = 0; i &lt; frequency.length; i++) { if (frequency[i] &gt; 0){ if (frequency[i] &gt; 1) System.out.println(i + " occurs " + frequency[i] + " times"); else System.out.println(i + " occurs " + frequency[i] + " time"); } } } }
score: 0

http://stackoverflow.com/comment/32687339
type: Comment
type: QuestionComment
has text: Your question can be summarised in *I click a button and nothing happens.* Hard to help you with that. Provide more information, please. You said you've tried the *wait* methods. I would like to see that. Is the same I've proposed in many [similar questions](http://stackoverflow.com/questions/17843521)? How have you implemented it?
comment on: http://stackoverflow.com/q/21628614
score: 0

http://stackoverflow.com/q/21667890
has title: Mangled nested class namein the Java Language Specification
type: AnsweredQuestion
tagged with: identifier
has comment: http://stackoverflow.com/comment/32752469
score: 0
tagged with: java
accepted answer: http://stackoverflow.com/a/21667999
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/32752521
has comment: http://stackoverflow.com/comment/32753570
type: Question
tagged with: nested-class
has body: Consider the following two classes: // a.java public class a { public static class $b { } } // a$.java public class a$ { public static class b { } } Obviously, due to inner/nested class name mangling, a$.b and a.$b will both be compiled to a class file named a$$b.class. When the command javac a.java a$.java is executed, the Oracle Java compiler (javac 1.7.0_45) produces the following output: a$.java:3: error: duplicate class: a.$b public static class b ^ 1 error Where does it say in the Java Language Specification that these class names (a$.b and a.$b ) clash, or is this just an established convention due to the output files having the same name?
answer count: 1
has answer: http://stackoverflow.com/a/21667999
favorite count: 0

http://stackoverflow.com/q/21560082
answer count: 1
has comment: http://stackoverflow.com/comment/32562389
type: UnansweredQuestion
tagged with: spring
has comment: http://stackoverflow.com/comment/32562445
has answer: http://stackoverflow.com/a/21560367
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32562339
has title: Unable to instantiate bean
has body: I am trying to implement a simple web service using spring. Following bean declaration has been added to app-ctx.xml: &lt;bean class="com.user.services.MessageService_BindingImpl" scope="request"/&gt; Everything works perfectly. After that i decide to try to use injection through a constructor - i've added a simple constructor with one argument (String type) and i've modified bean confoguration: &lt;bean class="com.user.services.MessageService_BindingImpl" scope="request"&gt; &lt;constructor-arg type="java.lang.String" value="Hello world"/&gt;&lt;/bean&gt; And after that i got following exception: java.lang.InstantiationException: com.user.services.MessageService_BindingImpl Looks like there is something with my constructor. After adding default non-arg constructor, exception disappears. How to use overloaded constructor? Thanks. MessageService_BindingImpl - public class MessageService_BindingImpl implements com.user.service.MessageService_PortType { public MessageService_BindingImpl (String hello) { } public ReadMessagesResponse readMessages(ReadMessagesRequest readMessagesRequest) throws RemoteException { MessageService mService = new MessageService(); return mService.readmessages(); } }
score: 0
has comment: http://stackoverflow.com/comment/32562722

http://stackoverflow.com/comment/32658366
type: AnswerComment
type: Comment
has text: Yeap, this is the answer to the question, in addition BL.set(i,false) should be BL.set(k,false).
score: 0
comment on: http://stackoverflow.com/a/21614233

http://stackoverflow.com/q/21643868
tagged with: spring-transactions
has comment: http://stackoverflow.com/comment/32711269
has comment: http://stackoverflow.com/comment/32711855
downvote count: 0
favorite count: 0
has title: dynamic datasource for jdbctemplate with no transaction manager
has body: I have a scenario, wherein I need to dynamically switch the data source during application run time. For this I have JDBCManager class which maintains a map of pooled datasources (C3P0), on request of a particular spring jdbctemplate, I looked at key and return appropriate jdbctemplate with data source. as below public JdbcTemplate getJdbcTemplate(long targetId) throws DataAccessDeniedException { return new JdbcTemplate(this.map.get(targetId)); } I have not configured any transaction manager in my config, nor I have attached any transaction manager while I pragmatically creating a Datasourec as below DriverManagerDataSource dataSource = null; dataSource = new DriverManagerDataSource(); // DataSource dataSource = DataSources.unpooledDataSource(); dataSource.setDriverClassName(driverClassName); dataSource.setUrl(url); dataSource.setUsername(userId); dataSource.setPassword(userPassword); DataSource pooledDataSource; try { Map&lt;String, Object&gt; overrides = new HashMap&lt;String, Object&gt;(); overrides.put("minPoolSize", minPoolSize); overrides.put("maxPoolSize", maxPoolSize); overrides.put("acquireIncrement", acquireIncrement); overrides.put("maxIdleTime", maxIdleTime); overrides.put("idleConnectionTestPeriod", idleConnectionTestPeriod); overrides.put("maxIdleTimeExcessConnections", maxIdleTimeExcessConnections); overrides.put("numHelperThreads", numHelperThreads); overrides.put("unreturnedConnectionTimeout", unreturnedConnectionTimeout); overrides.put("checkoutTimeout", checkoutTimeout); // create the PooledDataSource with overrides pooledDataSource = DataSources.pooledDataSource(dataSource, overrides); } catch (SQLException e) { logger.error("Could not create pooled datasource for target: " + targetId); throw new RuntimeException(e); } // cache the pooledDataSource this.map.put(targetId, pooledDataSource); return pooledDataSource; } Currently I am facing issue wherein After few minutes of processing my c3p0 connection pool runs out of connections and everything s…
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32732886
upvote count: 1
tagged with: spring
has comment: http://stackoverflow.com/comment/32726047
answer count: 0
tagged with: transactions
score: 1
tagged with: java
type: Question
tagged with: c3p0

http://stackoverflow.com/q/21551142
has comment: http://stackoverflow.com/comment/32545961
has answer: http://stackoverflow.com/a/21551307
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32545962
has body: I am working on an API which calls the server through the REST method and I wrote this getResponse function for that but I am getting some error. public static JSONObject getResponse(String url, Map&lt;String, String&gt; params, JSONObject object , String method) { JSONObject retObject = new JSONObject(); params.put("organization_id", organizationId); params.put("authtoken", authtoken); Iterator&lt;Entry&lt;String, String&gt;&gt; paramsItr = params.entrySet().iterator(); List&lt;NameValuePair&gt; nvpList = new ArrayList&lt;NameValuePair&gt;(); while(paramsItr.hasNext()) { Entry&lt;String, String&gt; param = paramsItr.next(); nvpList.add(new NameValuePair(param.getKey(),param.getValue())); } NameValuePair[] nvpArray = nvpList.toArray(new NameValuePair[nvpList.size()]); if(method.equalsIgnoreCase("GET")) retObject = getRequest(url, nvpArray); else if(method.equalsIgnoreCase("POST")) retObject = postRequest(url, nvpArray, object); else retObject = deleteRequest(url, nvpArray); return retObject; } The code is giving some error in this line : nvpList.add(new NameValuePair(param.getKey(),param.getValue())); The error is: The constructor NameValuePair(String, String) is undefined i have imported import org.omg.CORBA.NameValuePair;
has comment: http://stackoverflow.com/comment/32546016
tagged with: java
has answer: http://stackoverflow.com/a/21551301
type: Question
upvote count: 2
has title: NameValuePair error in Java
answer count: 2
downvote count: 2
favorite count: 0
score: 0

http://stackoverflow.com/a/21515574
upvote count: 2
answers question: http://stackoverflow.com/q/21515540
type: Answer
score: 2
downvote count: 0
has body: You have to initialize the array and the default value of boolean will be set to all the indexs element which is false. boolean planeArray[][] = new boolean[row_size][column_size];

http://stackoverflow.com/a/21662274
downvote count: 1
has comment: http://stackoverflow.com/comment/32742536
accepted answer of: http://stackoverflow.com/q/21662078
answers question: http://stackoverflow.com/q/21662078
type: AcceptedAnswer
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/32742468
score: 1
has body: Highlight the block you want to enwrap, go to the top menu under Source. Choose Surround with Try / Catch Block. It will automatically indent the code and list the found exceptions. I think the NumberFormatException will be listed automatically. This is basically the same as with UncheckedExceptions, except that with UncheckedExceptions Eclipse will automatically highlight the line as it is a Java Error to ignore (not catch nor rethrow) a checked exception. You probably have used the QuickFix Menu (usually STRG+1 as hotkey, or mouse hover over the error). The menu item above will work even without an error (and thus no error you could use QuickFix for)

http://stackoverflow.com/comment/71989623
comment on: http://stackoverflow.com/a/32845575
type: AnswerComment
score: 0
type: Comment
has text: I think it's better to use `.round` instead of `.truncate`, in cases where the two dates are off by a few milliseconds they can get truncated to different seconds. This results in a occasionally failing test. With a rounding approach, this is not an issue. `assertEquals(DateUtils.round(date1,Calendar.SECOND), DateUtils.round(date2,Calendar.SECOND));`

http://stackoverflow.com/a/21659971
type: AcceptedAnswer
downvote count: 0
type: Answer
has body: The JavaScript build process scans all files, folders, projects and libraries that are on the project's JavaScript Build Path. It seems like Eclipse consumes a lot of CPU and RAM when trying to perform the build process. I had the same issue and I couldn't found which files form extjs should be added to my projects. So, I excluded my extjs files from javascript build path and It is worked fine. Try to do this by going to the project properties -- JavaScript -- Include Path -- Source tab, then click on the excluded icon and add extjs folder. Source
upvote count: 3
score: 3
answers question: http://stackoverflow.com/q/21608566
accepted answer of: http://stackoverflow.com/q/21608566

http://stackoverflow.com/a/21558112
type: Answer
accepted answer of: http://stackoverflow.com/q/21558045
answers question: http://stackoverflow.com/q/21558045
has body: NumberFormat format = NumberFormat.getDecimalFormat().overrideFractionDigits(2); Column&lt;dateiles, Number&gt; column = new Column&lt;dateiles, Number&gt;(new NumberCell(format)) { @Override public Number getValue(dateiles object) { return object.sum; } };
type: AcceptedAnswer
score: 0

http://stackoverflow.com/q/21569507
type: UnansweredQuestion
tagged with: java
type: Question
tagged with: fullscreen
has title: How to build camera app to match vary size of device?
tagged with: camera
has answer: http://stackoverflow.com/a/21569808
has body: I have built camera android application. Also have to draw a rectangle and circle on surface view. My test device is Tablet Samsung Galaxy Note 10.1. I have try to run application on my friend's mobile, that is Samsung Galaxy S3. So, it was so different. The rectangle and circle is not located in right position. how I will fix that the rectangle and circle will locate in the same position on Galaxy Note 10.1?. Here is my code building camera app. import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.List; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.DashPathEffect; import android.graphics.Paint; import android.graphics.Paint.Style; import android.graphics.Point; import android.hardware.Camera; import android.hardware.Camera.PictureCallback; import android.hardware.Camera.Size; import android.os.Bundle; import android.os.Environment; import android.util.Log; import android.view.Display; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.view.ViewGroup.LayoutParams; import android.view.Window; import android.widget.Button; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.Toast; public class CaptureCamera extends Activity { //** Called when the activity is first created. */ Camera mCamera = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.layout_start); mCamera = getCameraInstance(); Preview mPreview = new Preview(this, mCamera); FrameLayout preview = (FrameLayout) findViewById(R.id.cam_preview); preview.addView(mPreview); Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int scree…
score: 0
answer count: 1
tagged with: android

http://stackoverflow.com/q/21644895
tagged with: concurrency
type: Question
answer count: 1
score: 0
has body: I am developing an application which performs allows the user to adjust several parameters and then performs a computation which can take up to a minute, after which it displays the result to the user. I would like the user to be able to adjust the parameters and restart the calculation, terminating the progress of the current calculation. Additionally, from the programming perspective, I would like to be able to block until the calculation is completed or interrupted, and be able to know which. In pseudo code, this is roughly what I am looking for: method performCalculation: interrupt current calculation if necessary asynchronously perform calculation with current parameters method performCalculationBlock: interrupt current calculation if necessary perform calculation with current parameters if calculation completes: return true if calculation is interrupted: return false What I have so far satisfies the first method, but I am not sure how to modify it to add the blocking functionality: private Thread computationThread; private Object computationLock = new Object(); private boolean pendingComputation = false; ... public MyClass() { ... computationThread = new Thread() { public void run() { while (true) { synchronized (computationLock) { try { computationLock.wait(); pendingComputation = false; calculate(); } catch (InterruptedException e) { } } } } private void checkForPending() throws InterruptedException { if (pendingComputation) throw new InterruptedException(); } private void calculate() { ... checkForPending(); ... checkForPending(); ... // etc. } }; computationThread.start(); } private void requestComputation() { pendingComputation = true; synchronized (computationLock) { computationLock.notify(); } } What is the best way to go about adding this functionality? Or is there a better way to design the program to accomplish all of these things?
has answer: http://stackoverflow.com/a/21645651
tagged with: locks
type: UnansweredQuestion
tagged with: multithreading
has title: Concurrent algorithm for interrupting and restarting a calculation
tagged with: java

http://stackoverflow.com/q/21632981
has body: I've the following code which connects to Google Cloud Taskqueue and lease some Task: List&lt;String&gt; scopes=new ArrayList&lt;String&gt;(); scopes.addAll(DatastoreOptions.SCOPES); scopes.add(STORAGE_SCOPE); scopes.add(TaskqueueScopes.TASKQUEUE); Credential credential = new GoogleCredential.Builder() .setTransport(HTTP_TRANSPORT) .setJsonFactory(JSON_FACTORY) .setServiceAccountId(System.getenv("DATASTORE_SERVICE_ACCOUNT")) .setServiceAccountScopes(scopes) .setServiceAccountPrivateKeyFromP12File(new File(System.getenv("DATASTORE_PRIVATE_KEY_FILE"))) .build(); taskqueue = new Taskqueue.Builder( HTTP_TRANSPORT, JSON_FACTORY, credential).setApplicationName(APPLICATION_NAME) .setTaskqueueRequestInitializer(new TaskqueueRequestInitializer() { @Override public void initializeTaskqueueRequest(TaskqueueRequest&lt;?&gt; request) { request.setPrettyPrint(true); } }) .build(); Taskqueue.Tasks.Lease leaseRequest = taskQueue.tasks().lease(APPLICATION_ID, TASK_QUEUE_NAME, 5, 30); Tasks tasks=leaseRequest.execute(); /*... and I'm doing something with the leased tasks ....*/ The code uses service account configured in my project. The code is standalone java application which will be running in the Google Compute Engine instance and will perform some background processing tasks. Maybe you noticed Datastore and Storage scopes in the credentials. It's because my code communicates with the Storage and Datastore as well, but I put there only code snippet related to the Taskqueue for simplicity. The code works perfectly, it connects to the Taskqueue running in the Google cloud. The Taskqueue is pull queue and is configured in my another application, the GAE web application which is creating tasks and storing them into the queue. Now I'd like to debug my code locally so I need that my code connects to the local Taskqueue, running in the local debug server (localhost:8888) instead of the Taskqueue hosted in the google cloud. How to modify the code so it will connect to the local taskqueue…
tagged with: google-app-engine
has comment: http://stackoverflow.com/comment/32694577
answer count: 0
has comment: http://stackoverflow.com/comment/49710575
type: UnansweredQuestion
has title: Howto connect to the local Google Cloud Taskqueue with Java?
tagged with: java
type: Question
score: 0
tagged with: google-cloud-platform
has comment: http://stackoverflow.com/comment/32690880

http://stackoverflow.com/q/21588619
answer count: 2
has answer: http://stackoverflow.com/a/21664151
downvote count: 0
has body: I am trying to parse an XML file which is 1.23 GB using SAX parser in Java. I am using Mac OS and JDK 1.7.0.51. Unfortunately, I am getting the following error: The pasrser has encountered more than "64000" entity expansions in this document; this is the limit imposed by the JDK. I have been recommended to get the entity expansion extended but do not know how to do this. Could anyone please help me in this issue. Your help would be very much appreciated.
score: 3
favorite count: 0
tagged with: parsing
tagged with: http://stackoverflow.com/tag/xml
type: UnansweredQuestion
tagged with: sax
has title: How to increase entityExpansionLimit for parsing XML files using SAX
upvote count: 3
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21592633

http://stackoverflow.com/q/21648052
favorite count: 0
type: UnansweredQuestion
has title: Android Instant Messaging/Chat XMPP dont receive message on mobile
tagged with: android
has comment: http://stackoverflow.com/comment/34331301
has body: Hi I'm starting android development and trying to do an instant messaging/chat app. I downloaded this source code here and trying to understand how it works. My problem is on 2 mobile devices, 1 user cannot receive the message of the other user, and vice versa, but I can see those chat message on gmail accounts. And if i type a message from gmail account browser the user who use the mobile device received the message(which made me think the problem is in "connection.sendPacket(msg);"). public class XMPPChatDemoActivity extends Activity { public static final String HOST = "talk.google.com"; public static final int PORT = 5222; public static final String SERVICE = "gmail.com"; public static final String USERNAME = "xxxxxxxx@gmail.com"; public static final String PASSWORD = "xxxxxxx"; private XMPPConnection connection; private ArrayList&lt;String&gt; messages = new ArrayList&lt;String&gt;(); private Handler mHandler = new Handler(); private EditText recipient; private EditText textMessage; private ListView listview; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); recipient = (EditText) this.findViewById(R.id.toET); textMessage = (EditText) this.findViewById(R.id.chatET); listview = (ListView) this.findViewById(R.id.listMessages); setListAdapter(); // Set a listener to send a chat text message Button send = (Button) this.findViewById(R.id.sendBtn); send.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { String to = recipient.getText().toString(); String text = textMessage.getText().toString(); Message msg = new Message(to, Message.Type.groupchat); msg.setBody(text); if (connection != null) { connection.sendPacket(msg); messages.add(connection.getUser() + ":"); messages.add(text); setListAdapter(); } } }); connect(); } /** * Called by Settings dialog when a connection is establised with the XMPP * server * * @param…
answer count: 0
downvote count: 0
score: 1
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32727282
has comment: http://stackoverflow.com/comment/32728747
upvote count: 1
has comment: http://stackoverflow.com/comment/32717293

http://stackoverflow.com/a/21595419
downvote count: 0
has body: As I can see in your xsd all elements are expected. Choice Indicator The indicator specifies that either one child element or another can occur: Sequence Indicator The indicator specifies that the child elements must appear in a specific order: try this:- &lt;xs:complexType name="BankType"&gt; &lt;xs:sequence&gt; &lt;xs:element name="Code" type="codeType" minOccurs="1" maxOccurs="1" /&gt; &lt;xs:element name="NewCode" type="codeType" minOccurs="0" maxOccurs="1" /&gt; &lt;xs:element name="SWIFTBIC" type="swiftType" minOccurs="0" maxOccurs="1" /&gt; &lt;xs:element name="Name" type="nameType" minOccurs="0" maxOccurs="1" /&gt; &lt;xs:element name="CorAccount" type="accountType" minOccurs="0" maxOccurs="1" /&gt; &lt;xs:element name="SubCorAccount" type="accountType" minOccurs="0" maxOccurs="1" /&gt; &lt;xs:element name="TaxNumber" type="taxNumberType" minOccurs="0" maxOccurs="1" /&gt; &lt;xs:element name="Address" type="addressType" minOccurs="0" maxOccurs="1" /&gt; &lt;xs:element name="PhoneNumber" type="phoneNoType" minOccurs="0" maxOccurs="unbounded" /&gt; &lt;xs:element name="FaxNumber" type="faxNumberType" minOccurs="0" maxOccurs="unbounded" /&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt;
score: 1
has comment: http://stackoverflow.com/comment/32626832
has comment: http://stackoverflow.com/comment/32625902
upvote count: 1
has comment: http://stackoverflow.com/comment/32626428
has comment: http://stackoverflow.com/comment/32626086
has comment: http://stackoverflow.com/comment/32626887
type: Answer
has comment: http://stackoverflow.com/comment/32626755
answers question: http://stackoverflow.com/q/21595049

android-listview
tags question: http://stackoverflow.com/q/21533529
tags question: http://stackoverflow.com/q/21570709
tags question: http://stackoverflow.com/q/21622574
tags question: http://stackoverflow.com/q/21542621
tags question: http://stackoverflow.com/q/21675620
tags question: http://stackoverflow.com/q/21536382
tags question: http://stackoverflow.com/q/21565391
tags question: http://stackoverflow.com/q/21653000
tags question: http://stackoverflow.com/q/21618628
tags question: http://stackoverflow.com/q/21542473
tags question: http://stackoverflow.com/q/21566442
tags question: http://stackoverflow.com/q/21544401
tag name: android-listview
tags question: http://stackoverflow.com/q/21636017
type: Tag
tags question: http://stackoverflow.com/q/21667058
tags question: http://stackoverflow.com/q/21609224
tags question: http://stackoverflow.com/q/21636822
tags question: http://stackoverflow.com/q/21662535

http://stackoverflow.com/comment/32781326
has text: This won't event compile due to accessing `i` out of scope.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21669307

http://stackoverflow.com/comment/32713398
comment on: http://stackoverflow.com/q/21645426
type: QuestionComment
score: 0
has text: yes which is why you need to say how exactly you intend to convert hyperlinks. For example "2.1 Defining User Requirements" is plain text of part of your text, but "2.1" should be a hyperlink to a page called `ANG 2.1`. How is this information supposed to be formatted as plain text?
type: Comment

http://stackoverflow.com/comment/32615340
has text: @JamesHobson - The question is why does Person handle marrying? Is there a divorce method as well? How about emailing folks to let them know the divorce has been finalized (now your Person class knows about emails)? The list of methods can get infinitely long as you add new functionality. That is why there should be MarriageService which handles marry and divorce operations, so that POJO doesn't have to know about every scenario in which it gets used. Separation of concern would be the guiding OOP principal here. As far as handling different marriage types, check out the Strategy pattern.
type: AnswerComment
comment on: http://stackoverflow.com/a/21588852
score: 0
type: Comment

http://stackoverflow.com/a/21533444
has comment: http://stackoverflow.com/comment/32516113
has comment: http://stackoverflow.com/comment/32517730
has comment: http://stackoverflow.com/comment/32519696
has comment: http://stackoverflow.com/comment/32518740
has comment: http://stackoverflow.com/comment/32517290
has comment: http://stackoverflow.com/comment/32518375
has comment: http://stackoverflow.com/comment/32516460
has comment: http://stackoverflow.com/comment/32516228
upvote count: 1
has comment: http://stackoverflow.com/comment/32524701
has comment: http://stackoverflow.com/comment/32516876
type: Answer
has comment: http://stackoverflow.com/comment/32518437
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/21533206
has body: The text in the QR code is in the local variable contents. This has to be set as the text of your TextView with id result; In code, not in XML. To do so, you should declare a member in your Activity: TextView mResult; In onCreate(), after setContentView(), bind it to the TextView: mResult = (TextView) findViewById(R.id.result); And finally in onActivityResult(): if (resultCode == RESULT_OK) { String contents = data.getStringExtra("SCAN_RESULT"); mResult.setText(contents); }
has comment: http://stackoverflow.com/comment/32516980

http://stackoverflow.com/a/21564442
score: 2
has comment: http://stackoverflow.com/comment/32570454
answers question: http://stackoverflow.com/q/21564331
downvote count: 0
has body: (only part of the problem, sorry. see the other answers for the rest) The array is filled with zeroes when it is created, thus zero will always be inList. You could change that function to only check the values that were actually set by adding a parameter for the length of the list: public static boolean inList(double number, double[] list, int n){ for (int i = 0; i &lt; n; i++) if (Math.abs(line[i] - number) &lt; 0.00000000001) return true; return false; } BTW: you could also use an ArrayList&lt;Double&gt; or HashSet&lt;Double&gt; which take care of the variable array size.
upvote count: 2
type: Answer

http://stackoverflow.com/q/21585119
tagged with: vector
tagged with: sorting
has answer: http://stackoverflow.com/a/21585636
has answer: http://stackoverflow.com/a/21585289
score: 0
answer count: 2
has body: I really need some help with this problem. I'm trying to write a function in Java code, but I'm stuck and I don't know how to continue. I have this data containing 1 row (area) and 7 columns (hospitals). For the area there is a percent that this person will end up at hospital 1, another percent it will end up at h2 etc. The data looks something like this: hospital h1 h2 h3 ... area a1 11 45 3 ... I have saved the data in a double array containing 7 values. I have this random generator fcn that randomly selects an index value of where in the array we are. If this random generator selects e.g. index=0 that would mean 11%, if it randomly selects index=2 that would mean 3% etc. The problem is that after I have done this I want to check whether or not this hospital is idle or not. If it is idle then I want to return the randomly chosen integer index value. If it's not idle I want to choose the next hospital with the second highest percent and if that hospital is idle then return this int index value, otherwise continue and check the third highest percent and do another check and so on. If all hospitals are not idle then return the randomly chosen value. This is what I've done so far: double vector[] = new double[distrToEachHosp.length](); //start by setting the contents to index for(int index=0; index&lt;vector.length; index++){ vector[index] = index; } for(int i=0; i &lt;= vector.length; i++){ for(int x=1; x &lt;= vector.length; x++){ if (distrToEachHosp[vektor[x]] &gt; distrToEachHosp[vektor[x+1]]){ //compare content that corresponds to index //move index int temp = vector[x]; vector[x] = vector[x+1]; vector[x+1] = temp; } } } return vektor; int rndValue = randomGenerator(distrToEachHosp); for(int i=0; i&lt;vector.length; i++){ if(hospital.get(i).namn == hospitalNameVariable[rndValue] ){ //hospitalNameVariable is a variable containing the names of the hospitals if(hospital.get(i).idle()&gt;0){ return rndValue; } else { if(vector[0] &gt;= rndValue) { return vector[0]; }…
has comment: http://stackoverflow.com/comment/32607497
type: UnansweredQuestion
has title: How to get the second highest value from an array, the third highest value etc
tagged with: java
type: Question

http://stackoverflow.com/comment/32727713
comment on: http://stackoverflow.com/q/21653979
has text: Something to get you started create a variable called sum and set it to zero. Create a for loop from i =0 to i =5 and call the two lines you have up in your question. check if a is not equal to 1 3 or 5 then sum+= a. After the for loop display and reset sum to 0.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32682846
comment on: http://stackoverflow.com/q/21624137
type: QuestionComment
has text: If you look at the documentation it is possible: http://msdn.microsoft.com/en-us/library/system.servicemodel.wsdualhttpbinding(v=vs.110).aspx and here: https://weblogs.java.net/blog/haroldcarr/archive/2009/04/metro_interoper.html But how?
score: 1
type: Comment

http://stackoverflow.com/q/21558054
has answer: http://stackoverflow.com/a/22021981
has comment: http://stackoverflow.com/comment/32577662
has comment: http://stackoverflow.com/comment/32563101
tagged with: testng
accepted answer: http://stackoverflow.com/a/22021981
type: AnsweredQuestion
tagged with: java
has title: TestNG Annotations in a Superclass
has body: I am having some trouble with TestNG annotations, and I haven't found a good answer either on stackoverflow or in the testng documentation. What I'm trying to do is add a testng listener as well as parameters from a testng.xml file to a "test base" superclass. All testng tests will inherit the superclass. This will alleviate a lot of code redundancy in the testng test class files. But when I have the @Listeners and @Parameters annotation in the superclass, and not the class that contains the @Test method(s), the annotations do not work. In other words, the listener does not seem to "see" the tests, and the parameters from testng.xml do not get pulled in to the superclass during runtime. My "test base" (the superclass) has a testng listener from the Sauce Labs api that will listen for tests and update the success/failure of the test to Sauce Labs during remote execution. It also uses the @Parameters annotation to pull parameters from the current test run's testng.xml. TestBase superclass: @Listeners(SauceOnDemandTestListener.class) public class TestBase implements SauceOnDemandSessionIdProvider, SauceOnDemandAuthenticationProvider { private SauceOnDemandAuthentication authentication; private DesiredCapabilities capabilities; protected ParallelWebDriver parallelWebDriver; @Parameters({"sauce_username", "sauce_accesskey", "platform", "browser", "version"}) @BeforeClass(alwaysRun = true) public void setUp(String userName, String accessKey, String platform, String browser, String version) { // Set up Sauce Auth if (userName != null &amp;&amp; accessKey != null) { this.authentication = new SauceOnDemandAuthentication(userName, accessKey); } else { this.authentication = new SauceOnDemandAuthentication(); } // Set up the DesiredCapabilities if (platform != null) { this.capabilities.setCapability("platform", platform); } else { throw new NullArgumentException("[Parameter] platform does not exist or is not a valid value in testng.xml:"); } if (browser != null) { this.capabili…
tagged with: saucelabs
type: Question
score: 0
answer count: 1
has comment: http://stackoverflow.com/comment/32564239

http://stackoverflow.com/comment/32500896
score: 0
type: QuestionComment
has text: I guess sending GCM is a task for server instead of android application. You can create some API on a server side and send some special info/data using that API and then server should do all the rest according to received data.
type: Comment
comment on: http://stackoverflow.com/q/21525198

http://stackoverflow.com/q/21642617
has title: File Icon Like JPanel
has body: Hi I want to create an JPanel which is very similar to the File Icon in Windows. It should have a image on the top, small indicator left bottom if it is a shortcut or some properties and file filename in the bottom. It should display only 10 characters by default after we selected it should display all the characters. right click on it should show some menu. This file icon panel should be fit into the given size (100 x 100 or 70 x 70) Please show me some light how to make it.
has comment: http://stackoverflow.com/comment/32708499
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32708091
has comment: http://stackoverflow.com/comment/32708136
tagged with: swing
has comment: http://stackoverflow.com/comment/32708100
answer count: 0
has comment: http://stackoverflow.com/comment/32708106
tagged with: java
tagged with: file
tagged with: jpanel
has comment: http://stackoverflow.com/comment/32708813
type: Question
tagged with: icons
score: 0

http://stackoverflow.com/comment/32682102
type: Comment
has text: I used local Maven installation.
score: 1
comment on: http://stackoverflow.com/q/21628129
type: QuestionComment

http://stackoverflow.com/a/21620278
has comment: http://stackoverflow.com/comment/32669339
has body: Type multimaps in Google, and you will find what you are looking for. Another way of doing it would be doing a simulated multimap the following way: Map&lt;String, List&lt;String&gt;&gt; multimap=new Map&lt;String, List&lt;String&gt;&gt;(); if (multimap.contains("Tom Hanks"){ multimap.get("Tom Hanks").add("value2"); } else { List&lt;String&gt; values=new ArrayList&lt;String&gt;(); values.add("value1"); multimap.put("Tom Hanks", values); } But finding a multimaps implementation will save you all the trouble.
type: Answer
answers question: http://stackoverflow.com/q/21620155
score: 2
downvote count: 0
upvote count: 2
has comment: http://stackoverflow.com/comment/32669101

http://stackoverflow.com/comment/32623566
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21593171
has text: Ohhh 100k nice...congrats

http://stackoverflow.com/a/21662374
has body: You should understand what happen when you "open" your jar. I believe that you mean that you perform double click on it. If my assumption is correct your jar is "executed", i.e. command line like the following is executed: java -jar yourjar.jar. What is really happening in this case? JVM opens your jar and tries to access file META-INF/MANIFEST.MF that should contain line like the following: Main-Class: com.company.MyClass JVM extracts the fully qualified class name and try to perform action that is equivalent to: java -cp yourjar.jar com.company.MyClass If class com.company.MyClass cannot be found in jar the error message like one that you sent will be printed. Now you have all tools to discover your problem. First, try to run your program using command like the java -cp yourjar.jar com.company.MyClass. If error remains check the jar: it does not have the main class. If problem disappears check your manifest. It contains mistake. If everything looks OK, check compatibility of versions of your compiler and JVM. Probably you compiled your code using compiler of higher version than the JVM you are using to run your program. Good luck.
type: Answer
has comment: http://stackoverflow.com/comment/32743842
has comment: http://stackoverflow.com/comment/32757420
score: 0
answers question: http://stackoverflow.com/q/21662256

http://stackoverflow.com/a/21634882
has body: I dont have access to validate all inputs. and time range. but this one runs O(N) for sure. and have improved. run and let me know your feedback.i will provide details if necessary public static int solution(int[]A,int K){ int minIndex=0; int maxIndex=0; int end=A.length; int slize = end; int startIndex = 0; int diff = 0; int minMaxIndexDiff = 0; for(int currIndex=1;currIndex&lt;end;currIndex++){ if(A[currIndex]&gt;A[maxIndex]){ maxIndex=currIndex; }else if(A[currIndex]&lt;A[minIndex]){ minIndex=currIndex; } if( (A[maxIndex]-A[minIndex]) &gt;K){ minMaxIndexDiff= currIndex- startIndex; if (minMaxIndexDiff &gt; 1){ slize+= ((minMaxIndexDiff*(minMaxIndexDiff-1)) &gt;&gt; 1); if (diff &gt; 0 ) { slize = slize + (diff * minMaxIndexDiff); } } if (minIndex == currIndex){ diff = currIndex - (maxIndex + 1); }else{ diff = currIndex - (minIndex + 1); } if (slize &gt; 1000000000) { return 1000000000; } minIndex = currIndex; maxIndex = currIndex; startIndex = currIndex; } } if ( (startIndex +1) == end){ return slize; } if (slize &gt; 1000000000) { return 1000000000; } minMaxIndexDiff= end- startIndex; if (minMaxIndexDiff &gt; 1){ slize+= ((minMaxIndexDiff*(minMaxIndexDiff-1)) &gt;&gt; 1); if (diff &gt; 0 ) { slize = slize + (diff * minMaxIndexDiff); } } return slize; }
upvote count: 1
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32694767
has comment: http://stackoverflow.com/comment/32694995
type: Answer
accepted answer of: http://stackoverflow.com/q/21610045
answers question: http://stackoverflow.com/q/21610045
score: 1
has comment: http://stackoverflow.com/comment/32694875

http://stackoverflow.com/a/21614233
upvote count: 4
has body: You have neverending for loop here: for(int k = i*2; k &lt; maxNum; k = k + i) i is 0 and k is 0 so every step k=0+0
has comment: http://stackoverflow.com/comment/32658448
downvote count: 0
has comment: http://stackoverflow.com/comment/32658366
type: Answer
score: 4
answers question: http://stackoverflow.com/q/21614108

http://stackoverflow.com/comment/32658075
has text: You've got a tight loop in there reading a byte at a time from a blocking IO call. UI will never be refreshed as long as there is data coming down the pipe. All of that crap in the open() method should be put in a SwingWorker thread as @user1676075 suggested yesterday.
score: 0
comment on: http://stackoverflow.com/a/21584721
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/116120687
type: Comment
has text: How do you re-attach the entity to the session?
comment on: http://stackoverflow.com/a/39372379
score: 0
type: AnswerComment

http://stackoverflow.com/a/33089002
answers question: http://stackoverflow.com/q/21594457
type: Answer
has body: yo could instantiate a object of the other class and call the method you need, or follow the singleton pattern to call the method you need without create the mentioned object.
score: 0

http://stackoverflow.com/comment/32683688
type: Comment
comment on: http://stackoverflow.com/a/21628439
has text: Unfortunately it does have to be `ObjectProperty<ObservableList<String>>`, as behind my question I'm attempting to bind something to [`javafx.scene.chart.XYChart.dataProperty`](http://docs.oracle.com/javafx/2/api/javafx/scene/chart/XYChart.html#dataProperty) without exposing some other underlying application specific properties.
type: AnswerComment
score: 0

http://stackoverflow.com/a/21595274
type: Answer
has comment: http://stackoverflow.com/comment/32626283
has comment: http://stackoverflow.com/comment/32626075
answers question: http://stackoverflow.com/q/21595253
has comment: http://stackoverflow.com/comment/32626209
has body: Try this - for(getArrayList s : arrayList) System.out.println(s + "\n");//This print the tostring of getArrayList class Again override the toString method of getArrayList class, to print actual field value of the object. Example - public class getArrayList { public String toString(){ return name +"||" +seconds+"||"+ speed1+"||"+speed2; } } Note : Follow java nomenclature standard, first later of you class name would be capital And also give a relevent name to the Class.
score: 0
has comment: http://stackoverflow.com/comment/32627270

http://stackoverflow.com/comment/32541203
has text: Modify your server to only return the file name, then URLEncode it, then build the full URL.
score: 0
comment on: http://stackoverflow.com/a/21548161
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32712387
has text: I just don't get you what you really want to do?
type: AnswerComment
comment on: http://stackoverflow.com/a/21634620
type: Comment
score: 0

http://stackoverflow.com/comment/32640304
has text: Essentially the table is a list of people, I need to select a person based on their name and then select that table row and then be able to .click it. I'm just really confused. Maybe everything I've done for this table is the wrong approach. All I know is there is no attribute = name, it's just sort of floating there in the .
comment on: http://stackoverflow.com/q/21591027
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21573368
has title: How to perform a submit action automatically in an external site
type: Question
has body: that's my problem: Everyday I visit a website (with login of course) and upload the same image. I'd like to know if there is a way to automatize this process. I hope someone cane help me :) Thanks for your help!
has answer: http://stackoverflow.com/a/21573457
tagged with: javascript
score: 0
answer count: 2
type: UnansweredQuestion
tagged with: http://stackoverflow.com/tag/html
tagged with: php
has answer: http://stackoverflow.com/a/21573390
tagged with: java

http://stackoverflow.com/comment/32682918
type: QuestionComment
has text: If you're putting a thread to perform a task, then there is nothing to prevent this thread from being finalized, unless any extra condition. This extra condition could be some program state that your thread ends up finding within step1 (), preventing it from returning (preventing proceed to the next method). My guess is that your thread is blocked on a possible dead-lock, maybe caused by an infinite loop (do not know), or call for any block of code that never returns. Even if your code is clean and well built, you may be making a call to some unknown routine for you.
comment on: http://stackoverflow.com/q/21608732
score: 0
type: Comment

http://stackoverflow.com/a/21669526
has comment: http://stackoverflow.com/comment/32755315
downvote count: 0
has comment: http://stackoverflow.com/comment/32755282
has comment: http://stackoverflow.com/comment/32755044
has comment: http://stackoverflow.com/comment/32755294
has comment: http://stackoverflow.com/comment/32755240
has comment: http://stackoverflow.com/comment/32755178
type: Answer
has body: In Java, Strings literals are represented with double quotes - "" What you have done is added two char values together. What you want is: System.out.println("b" + "c"); // bc What happened with your code is that it added the ASCII values of the chars to come up with 197. The ASCII value of 'b' is 98 and the ASCII value of 'c' is 99. So it went like this: System.out.println('b' + 'c'); // 98 + 99 = 197 As a note with my reference to the ASCII value of the chars: The char data type is a single 16-bit Unicode character. From the Docs. However, for one byte (0-255), as far as I'm aware, chars can also be represented by their ASCII value because the ASCII values directly correspond to the Unicode code point values - see here. The reason I referenced ASCII values in my answer above is because the 256 ASCII values cover all letter (uppercase and lowercase) and punctuation - so it covers all of the main stuff. Technically what I said is correct - it did add the ASCII values (because they are the same as the Unicode values). However, technically it adds the Unicode codepoint decimal values.
has comment: http://stackoverflow.com/comment/32755080
has comment: http://stackoverflow.com/comment/32755027
score: 1
has comment: http://stackoverflow.com/comment/32755217
upvote count: 1
answers question: http://stackoverflow.com/q/21669459

http://stackoverflow.com/comment/32732095
type: Comment
score: 0
comment on: http://stackoverflow.com/q/21653000
type: QuestionComment
has text: As per my knowledge, as there is only addTextChangedListener will work. But how can I decide user has done with typing?

http://stackoverflow.com/a/21669385
score: 1
has comment: http://stackoverflow.com/comment/32754906
has comment: http://stackoverflow.com/comment/32755016
downvote count: 0
answers question: http://stackoverflow.com/q/21669087
has body: you can try below. This should work List&lt;WebElements&gt; elements = driver.findElements(By.xpath("//div[@pagesequence='46']")); elements.get(0).getAttribute("pagename");
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/32775092

rpc
tag name: rpc
tags question: http://stackoverflow.com/q/21537793
type: Tag
tags question: http://stackoverflow.com/q/21530527

http://stackoverflow.com/comment/32686649
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/21630678
has text: You can't import classes from the default package.
type: Comment

http://stackoverflow.com/comment/32712177
has text: I find this method too unobvious - the calculation of `'D' - grade + 1` requires hard thinking to know it's right. Also, if you enter a string like 'DONE', won't it add a 'D' to your GPA?
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21644762
type: AnswerComment

http://stackoverflow.com/q/21532234
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32513393
has answer: http://stackoverflow.com/a/21532383
has body: simple beginner Java question. I just learned how to use arrays and it's still a little confusing to me. My goal is to simply roll a number of dice a number of times and then project it as a sum, frequency, and percentage. I'm sure I'm doing something dumb, but I'm overlooking it! import javax.swing.JOptionPane; import java.util.Random; public class Lab1 { private static int N = 0; private static int M = 0; private static int total = 0; private static Random rnd = new Random(); public Lab1(){ } public static void main(String[] args) { N = Integer.parseInt(JOptionPane.showInputDialog("How many dice would you like to roll?")); System.out.println("Dice: "+N); M = Integer.parseInt(JOptionPane.showInputDialog("How many times would you like to roll?")); System.out.println("Rolls: "+M); int total[] = new int[(6*Lab1.N)+1]; for (int i=0; i&lt;=total.length; i++) total[i] = 0; for (int roll=1; roll&lt;=M; roll++){ N = 1+rnd.nextInt(6); total[N]++; } System.out.printf("%3s%12s%12s\n", "Sum","Frequency", "Percentage " ); for(int k=2; k&lt;total.length; k++);{ int percent = total[k]/(360); System.out.printf("%3s%12s%12s\n", k, total[k], percent); } } }
has title: rolling dice using arrays
score: -5
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21532370
has comment: http://stackoverflow.com/comment/32513375
has answer: http://stackoverflow.com/a/21532353
downvote count: 5
has comment: http://stackoverflow.com/comment/32513477
answer count: 3
upvote count: 0
tagged with: arrays
favorite count: 0

http://stackoverflow.com/comment/32590745
has text: for checking equality look here [http://stackoverflow.com/questions/10189963/jstl-if-tag-for-equal-strings] link
type: Comment
comment on: http://stackoverflow.com/q/21574770
type: QuestionComment
score: 1

http://stackoverflow.com/comment/32677230
type: QuestionComment
score: 1
has text: Do you want to continue over to the next element's processing or just want to break completely out of it?
comment on: http://stackoverflow.com/q/21625387
type: Comment

http://stackoverflow.com/a/21530930
answers question: http://stackoverflow.com/q/21530724
score: 1
has comment: http://stackoverflow.com/comment/32511228
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32510992
has body: Your WAR may not be deployed correctly. Check catalina.out log file for errors. Also to debug clean the folder work then call startup.bat and see if you war is exploded in the work directory. Edit: Try killing all Tomcat instances, you should have one still running.
type: Answer
accepted answer of: http://stackoverflow.com/q/21530724
downvote count: 0

http://stackoverflow.com/comment/32743903
comment on: http://stackoverflow.com/q/21663225
has text: @AbhinavKumar my money's on `forestOwnerCtr`.
type: Comment
type: QuestionComment
score: 1

http://stackoverflow.com/q/21592185
type: AnsweredQuestion
tagged with: android-webview
tagged with: java
has title: How to turn Website into Android App
type: Question
tagged with: mobile-website
possible better answer: http://stackoverflow.com/a/21592271
has answer: http://stackoverflow.com/a/21592271
score: 0
has answer: http://stackoverflow.com/a/21592295
answer count: 3
tagged with: web
has answer: http://stackoverflow.com/a/21592319
has body: I have developed one website and now I want to create an android app for it. App should be in sync with web site automatically. I know there are many online free tools for it. But I want to learn Android programming from basic. I just don't want to link or view the webpages from Smartphone but I must be able to add some android features. You may assume I am newbie in an Andriod developing field. So I want any, good tutorial or book for this. Any suggestion? For e.g. suraj.com ---> Suraj (android​ app) Thank you in advance.
tagged with: android
accepted answer: http://stackoverflow.com/a/21592295

http://stackoverflow.com/comment/32510446
has text: `using reflection in Java is tricky becuase I want to run this code on android aswell` why? there is nothing preventing you from using reflection in android.
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21530689

http://stackoverflow.com/a/21597793
has comment: http://stackoverflow.com/comment/32629507
score: 4
has comment: http://stackoverflow.com/comment/32629457
has comment: http://stackoverflow.com/comment/32629431
has comment: http://stackoverflow.com/comment/32629541
has comment: http://stackoverflow.com/comment/32630627
type: Answer
upvote count: 4
downvote count: 0
answers question: http://stackoverflow.com/q/21597735
has body: I have formatted your code and added brackets, it should now be fairly obvious what is happening: public static void main(String[] args) { String sentence; Scanner keyboard = new Scanner(System.in); System.out.println("Please enter a sentence."); sentence = keyboard.nextLine(); if (sentence.charAt(sentence.length() - 1) == '?') { if (sentence.length() % 2 == 0) { System.out.println("Yes."); } else if (sentence.charAt(sentence.length() - 1) == '?') { if (sentence.length() % 1 == 0) { System.out.println("No."); } else if (sentence.charAt(sentence.length() - 1) == '!') { System.out.println("Wow."); } else { System.out.println("You always say \"" + sentence + "\"."); } } } } i.e. you have one big if that checks for the ? at the end - if there isn't one nothing happens. A lesson to take away from this; always use {} (when you get to know Java a little better there are exceptions to this rule, but right now always).

http://stackoverflow.com/q/21610516
has answer: http://stackoverflow.com/a/21610559
tagged with: java
has body: First, to be clear, I KNOW WHAT IS AN INTERFACE. What I mean is, can I require the class which implement the interface to have a constructor mentioned in the interface? As follows: public interface IA { /*constructor requirement*/ public IA(int, int, int, int, int, int, int); } public class A implements IA { /* Because I implements IA, I have to make this contructor */ public A(int, int, int, int, int, int, int) { .... } }
type: Question
has answer: http://stackoverflow.com/a/21610535
has title: Requirements for constructor in interface
score: 0
answer count: 3
has comment: http://stackoverflow.com/comment/32651258
has comment: http://stackoverflow.com/comment/32652041
has answer: http://stackoverflow.com/a/21610577
tagged with: constructor
type: UnansweredQuestion
tagged with: interface
tagged with: android
tagged with: enums

pls-file
tags question: http://stackoverflow.com/q/21544746
tag name: pls-file
type: Tag

http://stackoverflow.com/comment/32634202
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21573927
has text: i use JSF 1.2, so that option doesn´t work

http://stackoverflow.com/a/21626782
downvote count: 0
type: Answer
upvote count: 4
accepted answer of: http://stackoverflow.com/q/21626688
answers question: http://stackoverflow.com/q/21626688
has body: To be as secure as possible then your user should enter the password again. However really you need to look at the use-case and decide what you are defending against. For example if they have to enter the password again then they are more vulnerably to someone shoulder surfing or key loggers, etc but the increased risk is pretty small. The password kept in memory is only vulnerable to processes already running on the machine the software is running on. That again is a pretty small risk as it would probably be easier just for them to put a key logger on. So really in this sort of scenario the main risk factors are the people. Can someone trick the person entering the password into revealing it (i.e. spear fishing, fake login prompts, key loggers, shoulder surfing). Mitigating most of those risks is about training, not about technical issues at all. Far too many people think that a technical silver bullet can solve all their security woes. It really can't, a system is only as secure as its weakest link and you need to think about the big picture as well as the small one.
score: 4
type: AcceptedAnswer

http://stackoverflow.com/comment/32761017
comment on: http://stackoverflow.com/a/21672146
score: 0
has text: As far as I can tell no swapping is taking place. Based on your answer, I can only infer that the problem lies somewhere in my code. I will have to investigate further. Thanks!
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32708139
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21642557
has text: You surely need to follow naming convention see [here](http://www.oracle.com/technetwork/java/codeconventions-135099.html#367)

http://stackoverflow.com/comment/32696343
score: 0
comment on: http://stackoverflow.com/q/21635991
has text: I would like to see what he tried to do and how he's approaching the operation.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32487803
comment on: http://stackoverflow.com/a/21516417
score: 0
type: Comment
has text: @MarkusA. Well as far as the *real* reason, I think that's just "it doesn't exist". It's just not in the spec for an interface to be local.
type: AnswerComment

http://stackoverflow.com/q/21569868
has comment: http://stackoverflow.com/comment/32580938
upvote count: 4
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/21570276
has title: Try to do typecast but getting CAP#1 error
accepted answer: http://stackoverflow.com/a/21570276
type: Question
downvote count: 0
score: 4
has body: Playing around with type casting for a project I am about to start I found this error unexpectedly: incompatible types: Class&lt;CAP#1&gt; cannot be converted to myObj where CAP#1 is a fresh type-variable: CAP#1 extends ImyObj from capture of ? extends ImyObj The code that caused this error: ImyObj testObj = new myObj(); System.out.println(testObj.sayHi()); myObj testObj2 = (testObj.getClass()) testObj; System.out.println(testObj2.sayBye()); However this works fine: ImyObj testObj = new myObj(); System.out.println(testObj.sayHi()); myObj testObj2 = (myObj) testObj; System.out.println(testObj2.sayBye()); Shouldn't they both do the same thing or am I missing something? I currently have Java 1.7_51 installed. It has been a while since I touched Java(before 1.7), as I got immersed in Python 2.7. EDIT: Louis Wasserman's answer also raises the same error.
answer count: 1
has comment: http://stackoverflow.com/comment/32580726
has comment: http://stackoverflow.com/comment/32580656
favorite count: 0

http://stackoverflow.com/comment/32698371
type: QuestionComment
has text: possible duplicate of [MySQL high CPU usage](http://stackoverflow.com/questions/1282232/mysql-high-cpu-usage)
score: 0
comment on: http://stackoverflow.com/q/21634411
type: Comment

http://stackoverflow.com/comment/32713602
type: QuestionComment
type: Comment
has text: did you add the derby jars to your eclipse project build path?
score: 0
comment on: http://stackoverflow.com/q/21645978

http://stackoverflow.com/a/21621244
score: 1
has body: The new keyword signifies the instantiation/creation of a StudentForm object. So new StudentForm() gives you an instance of StudentForm or simply a StudentForm object. The only difference between StudentForm studentform = new StudentForm(); and new StudentForm(); is that the former give you a reference to the new StudentForm object. The reference being studentForm
upvote count: 1
answers question: http://stackoverflow.com/q/21621096
type: Answer
downvote count: 0

http://stackoverflow.com/comment/32643474
type: Comment
type: QuestionComment
has text: old tutorials may still work... have you tried them? also, this is not really a question
score: 1
comment on: http://stackoverflow.com/q/21606060

http://stackoverflow.com/q/21578385
has answer: http://stackoverflow.com/a/21578513
has body: I want to iterate the value of entry for getting keys and values of entry, but don't know, how to iterate entry. Please guide me. Iterator&lt;Entry&lt;String, Vector&lt;PromoteTable&gt;&gt;&gt; hmIterate = linkedHashmp.entrySet().iterator(); while(hmIterate.hasNext()) { Entry&lt;String, Vector&lt;PromoteTable&gt;&gt; entry = hmIterate.next(); Object[] result = new Object[noOfRecords]; }
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/32845636
score: -2
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21578513
has title: iterate entry.getkey() using for loop
tagged with: java
downvote count: 3
upvote count: 1
type: Question
tagged with: iterator
has comment: http://stackoverflow.com/comment/32595000
has comment: http://stackoverflow.com/comment/32595026
has comment: http://stackoverflow.com/comment/32846486

http://stackoverflow.com/a/21631367
upvote count: 1
answers question: http://stackoverflow.com/q/21631167
has comment: http://stackoverflow.com/comment/32690221
score: 1
has body: It depends on your operating system, 32 bit versions of MacOS X and Linux have some ability to access more than 4GB in the kernel but still limit processes to 4GB. Other operating systems may restrict process memory further since they need part of the 4GB for themselves. In general you want to avoid swapping out your JVM to VM so you need to know how much free memory you system has.
downvote count: 0
type: Answer

http://stackoverflow.com/comment/32756146
type: Comment
comment on: http://stackoverflow.com/q/21648938
has text: I'm not sure how to set this arguments with java goal. Anyway how can I kill that process later?
score: 0
type: QuestionComment

http://stackoverflow.com/q/21555968
has answer: http://stackoverflow.com/a/21557361
has answer: http://stackoverflow.com/a/21556463
tagged with: java
tagged with: jpanel
has title: Java: How can I modify the size of a JPanel in runtime?
type: Question
tagged with: contentpane
answer count: 2
has body: I want to modify the size of the JPanel while the program is running, for example with a menu item. How can I reach it? Or how should I modify my program to get acces to the live JPanel in the content pane? Edit: If I make a contentpane for a gamefield that's 400x400 in the start as default. But what if I want to ad an option in the menu to change the size to 500x500, but without losing all of the content already in progress by the player. JFrame class: package me.test; import javax.swing.JFrame; public class Main extends JFrame { private static final long serialVersionUID = 1L; public static void main(String[] args) { // TODO Auto-generated method stub new Main(); } public Main() { setContentPane(new MyJPanel()); pack(); setDefaultCloseOperation(EXIT_ON_CLOSE); setLocation(100,50); setResizable(false); setVisible(true); } } My modified JPanel: package me.test; import java.awt.Dimension; import javax.swing.JPanel; public class MyJPanel extends JPanel { public MyJPanel() { setPreferredSize(new Dimension(400,400)); } }
score: 0
linked to: http://stackoverflow.com/q/7143287
has comment: http://stackoverflow.com/comment/32555394
tagged with: jframe
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32554757
tagged with: swing

http://stackoverflow.com/comment/32549583
has text: So you want to display html tags instead of their html entities replacement? You can set is using setEscapeModelStrings(false), remeber, set it on the label (override the factory method newLabel() as well as newEditor() in my example); see http://stackoverflow.com/questions/1804220/how-to-display-html-text-within-a-wicket-element
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21539860
score: 0

http://stackoverflow.com/a/21658140
has body: When calling @Transactional execute() from non transactional test(), the @Transactional in execute() will NOT be applied. This is because it's a direct call from one method of the object directly to the other, which bypasses the transactional proxy. See this answer for more details on how proxies work and why @Transactional does not work when calling the transactional function using this. Have a look also at the Spring RetryTemplate, which is a spring-based solution for this problem. Concerning the retry mechanism, it won't work for cases when a versioned entity (with a @Version column) is being used, which is the case given that StaleObjectStateException is being thrown. The reason is that there was another thread updating the entity on the database, incrementing the version column. The solution is to refresh() the entity (loading the latest version), reapply the modifications and try again. Retrying several times the same modification will only work in case of non versioned entities, and it's probably not what you want because the changes made by one thread are silently overwritten by another thread.
has comment: http://stackoverflow.com/comment/32778289
score: 0
answers question: http://stackoverflow.com/q/21657428
has comment: http://stackoverflow.com/comment/32736134
has comment: http://stackoverflow.com/comment/32778977
type: Answer

http://stackoverflow.com/q/21558977
score: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21559189
tagged with: declaration
upvote count: 2
tagged with: java
has comment: http://stackoverflow.com/comment/32560216
possible better answer: http://stackoverflow.com/a/21559089
type: Question
answer count: 3
tagged with: bulk
downvote count: 0
has answer: http://stackoverflow.com/a/21559089
tagged with: variables
favorite count: 0
linked to: http://stackoverflow.com/q/6250114
accepted answer: http://stackoverflow.com/a/21559189
has body: The one main thing I want to avoid while Java programming is excessive boolean variable declarations like this: public static boolean mytruebool = true, myfalsebool = false, myothertruebool = true, myotherfalsebool = false; Is there an efficient way (perhaps w/ array usage) of declaring and assigning variables? Any help is greatly appreciated!
has answer: http://stackoverflow.com/a/21559245
has title: Is there a way to "bulk assign" boolean variables in Java?
has comment: http://stackoverflow.com/comment/32560240

http://stackoverflow.com/a/21625412
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/32678103
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21625020
has body: Maybe to use for cycle to be shorter: for (int i = 0; i &lt; 7; i++) { for (String lines : MyArray()) { // Changes depended by values. if (i &gt; 3) { lines = MyValx; } System.out.println(lines); // to have `\n` effect } System.out.println(); } And BTW variables will start in lower case and not end withenter (\n). So use: String myValues[] = {"MyValue1", "MyValue2", "MyValue3", "MyValue4"}; instead of: String MyValues[] = { "MyValue1", "MyValue2", "MyValue3", "MyValue4\n" }; and add System.out.println(); after eache inside cycle instead of this:
accepted answer of: http://stackoverflow.com/q/21625020
type: Answer

http://stackoverflow.com/q/21539167
has comment: http://stackoverflow.com/comment/32526240
has title: drawing pixels in java
has comment: http://stackoverflow.com/comment/32526258
has body: I have tried again and again to master basic java programming but the phenomenal amount of errors from all of the programs I write has resigned me. This time I am trying to set one pixel and then a series more by adding line after line or a loop. import java.awt.image.BufferedImage; import javax.swing.JFrame; import javax.swing.JPanel; public class Points extends JPanel { BufferedImage image = new BufferedImage(300, 200, BufferedImage.TYPE_INT_ARGB); rgb = 0xFF00FF00; // green image.setRGB(1, 1, rgb); public static void main(String[] args) { Points points = new Points(); JFrame frame = new JFrame("Points"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(points); frame.setSize(250, 200); frame.setLocationRelativeTo(null); frame.setVisible(true); } } Points.java:7: error: &lt;identifier&gt; expected rgb = 0xFF00FF00; // green ^ Points.java:8: error: &lt;identifier&gt; expected image.setRGB(1, 1, rgb); ^ Points.java:8: error: illegal start of type image.setRGB(1, 1, rgb); ^ Points.java:8: error: illegal start of type image.setRGB(1, 1, rgb); ^ Points.java:8: error: &lt;identifier&gt; expected image.setRGB(1, 1, rgb); ^ 5 errors In the code section is the error that I get underneath.
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/32526176
has comment: http://stackoverflow.com/comment/32526209
has comment: http://stackoverflow.com/comment/32526164
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32526231
has answer: http://stackoverflow.com/a/21539299
tagged with: pixel
tagged with: java
tagged with: bufferedimage
type: Question
has answer: http://stackoverflow.com/a/21539259

http://stackoverflow.com/q/21516402
has body: Screen command in OS X does not detect any connected USB devices except Bluetooth ports. Finally I need to create serial communication between 2 Java applications on OS X and first create 2 virtual serial ports with socat: ./socat -d -d tty tty The output is: N PTY is /dev/ttys000 N PTY is /dev/ttys001 N starting data transfer loop with FDs [3,3] and [5,5] then I create two symbolic links with ln -s /dev/ttys000 /dev/ttyUSB01 ln -s /dev/ttys001 /dev/ttyUSB02 The problem is when I try to make Java detect the serial ports to start communication, none of these is detected. Moreover when I connect a USB device and try to get all serial ports with the command screen it shows only Bluetooth ports.
tagged with: serial-port
upvote count: 1
tagged with: java
answer count: 0
type: UnansweredQuestion
downvote count: 0
score: 1
tagged with: macos
has title: OS X can't detect serial ports in Terminal with screen command
favorite count: 0
type: Question

http://stackoverflow.com/a/21671676
has comment: http://stackoverflow.com/comment/32758432
accepted answer of: http://stackoverflow.com/q/21671582
has comment: http://stackoverflow.com/comment/32770708
answers question: http://stackoverflow.com/q/21671582
has comment: http://stackoverflow.com/comment/32770225
has comment: http://stackoverflow.com/comment/32758379
score: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32758485
has body: Your Question is already answered in SO Click Here answered by dacwe public static void main(String[] args) throws Exception { final BufferedImage image = ImageIO.read(new URL( "http://upload.wikimedia.org/wikipedia/en/2/24/Lenna.png")); Graphics g = image.getGraphics(); g.setFont(g.getFont().deriveFont(30f)); g.drawString("Hello World!", 100, 100); g.dispose(); ImageIO.write(image, "png", new File("test.png")); } make use of graphic Option Output
type: Answer

http://stackoverflow.com/a/21576441
type: Answer
has comment: http://stackoverflow.com/comment/32592170
has comment: http://stackoverflow.com/comment/32669580
score: 1
upvote count: 1
has body: Otherwise i can give you the following advice : There's no need for a whole class (JSONParser) for just one method. Just add the method and variables to MainActivity. EDIT: Actually are you using an android device or an emulator? If you're using an emulator you can access your host computer by using 10.0.2.2 . You would change your url to http://10.0.2.2.146:8888/Lera.Template.Services.WCF/UserService/GetName
downvote count: 0
answers question: http://stackoverflow.com/q/21575959
has comment: http://stackoverflow.com/comment/32591557

http://stackoverflow.com/q/21586431
score: 3
has title: Why do I see this pattern of enumerating many methods for 1,2,3, etc arguments followed by a general arbitrary size list of arguments?
linked to: http://stackoverflow.com/q/21555040
downvote count: 0
linked to: http://stackoverflow.com/q/4314883
has comment: http://stackoverflow.com/comment/32610012
favorite count: 0
has body: ImmutableList is one example of what I'm talking about. There's a series of methods accepting a fixed number of arguments followed by a general catch all signature public static &lt;E&gt; ImmutableList&lt;E&gt; of(E element) { return new RegularImmutableList&lt;E&gt;(copyIntoArray(element)); } public static &lt;E&gt; ImmutableList&lt;E&gt; of(E e1, E e2) { return new RegularImmutableList&lt;E&gt;(copyIntoArray(e1, e2)); } public static &lt;E&gt; ImmutableList&lt;E&gt; of(E e1, E e2, E e3) { return new RegularImmutableList&lt;E&gt;(copyIntoArray(e1, e2, e3)); } public static &lt;E&gt; ImmutableList&lt;E&gt; of(E e1, E e2, E e3, E e4) { return new RegularImmutableList&lt;E&gt;(copyIntoArray(e1, e2, e3, e4)); } public static &lt;E&gt; ImmutableList&lt;E&gt; of(E e1, E e2, E e3, E e4, E e5) { return new RegularImmutableList&lt;E&gt;(copyIntoArray(e1, e2, e3, e4, e5)); } public static &lt;E&gt; ImmutableList&lt;E&gt; of(E... elements) { return (elements.length == 0) ? ImmutableList.&lt;E&gt;of() : new RegularImmutableList&lt;E&gt;(copyIntoArray(elements)); } (Comments removed for brevity). Why not include just the final catch all (E... elements). I'm guessing the answer is something along the lines of "optimization" but I'm not really clear why. Is the check and branch for elements.length==0 really considered that costly? Why stop at just 5 argument signatures, why not 10 or 50? Is the reasoning something specific to Java or something that would apply to other compiled languages as well?
type: UnansweredQuestion
tagged with: design-patterns
answer count: 0
upvote count: 3
tagged with: java
duplicate of: http://stackoverflow.com/q/21555040
duplicate of: http://stackoverflow.com/q/4314883
type: Question

http://stackoverflow.com/a/21551296
score: 3
type: Answer
upvote count: 3
answers question: http://stackoverflow.com/q/21550677
accepted answer of: http://stackoverflow.com/q/21550677
has comment: http://stackoverflow.com/comment/32547061
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32547151
has body: protobuf-net, in v1, made a "zero defaults" assumption. Probably not a decision I would make again, if I was starting from scratch, and indeed this behaviour can be disabled in v2. But as it stands, in many cases it assumes zero as an implicit default. I'm guessing that your command is a non-nullable enum, in which case it will apply this logic (as a side-note: if it was nullable, it would not do this - it would use the null check for the include/exclude decision). Because of this, it has decided that the second field (field number 2, encoded as varint) doesn't need to be serialized. Hence no [16, 0]. Options: use a nullable member (equivalent to optional) - i.e. public SomeEnum? Command {get;set;} mark the member as required (IsRequired=true on the ProtoMemberAttribute) turn off implicit zero default behaviour (UseImplicitZeroDefaults on a RuntimeTypeModel instance)

http://stackoverflow.com/comment/32829087
type: QuestionComment
has text: what do you mean with "does not work out"? your image looks like a smoothed surface, what part do you believe does not conform to what the bezier patch should be doing?
comment on: http://stackoverflow.com/q/21651837
score: 0
type: Comment

http://stackoverflow.com/comment/32536302
type: Comment
score: 0
has text: Ok i did it.check for not null or empty..thnkx
type: AnswerComment
comment on: http://stackoverflow.com/a/21545263

http://stackoverflow.com/a/21552314
type: Answer
has body: The above configuration is actually correct and the underlying legacy functions is being called inside the created spring transaction. What I miss is that on the upper layer I needed to flush the underlying session to the datastore. When I did that the legacy transaction begins to aware of the changed data and everything works perfect and also the transactions can be rolled back. I flush my session to the datastore with this : @Autowired PlatformTransactionManager pt; TransactionDefinition td = new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_MANDATORY); pt.getTransaction(td).flush();
accepted answer of: http://stackoverflow.com/q/21537211
score: 0
answers question: http://stackoverflow.com/q/21537211
type: AcceptedAnswer

http://stackoverflow.com/a/21614903
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21614675
type: Answer
upvote count: 1
has body: Below is a sample, getErrors() and getWarnings() return List&lt;T&gt; public interface ErrorHolder&lt;T&gt; { public void addError(T t); public int totalErrors(); public boolean hasErrors(); public void addWarning(T t); public int totalWarnings(); public boolean hasWarnings(); public List&lt;T&gt; getErrors(); public List&lt;T&gt; getWarnings(); } and in the implementing class - private List&lt;T&gt; errors = new ArrayList&lt;T&gt;(); public void addError(T t) { errors.add(t); } public List&lt;T&gt; getErrors() { return errors; }
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/21614675

http://stackoverflow.com/a/21556253
has comment: http://stackoverflow.com/comment/32555998
upvote count: 2
has comment: http://stackoverflow.com/comment/32623605
has comment: http://stackoverflow.com/comment/32555917
type: Answer
has comment: http://stackoverflow.com/comment/32556004
has comment: http://stackoverflow.com/comment/32624328
score: 1
has comment: http://stackoverflow.com/comment/32555782
has comment: http://stackoverflow.com/comment/32555274
has body: This adds 1,000,000 viewable objects in 196 nano-seconds. Like I said, it depends on the context, and is quite an arbitrary question. import java.awt.*; import java.util.Vector; import javax.swing.*; class ManyObjects { public static void main(String[] args) { Runnable r = new Runnable() { @Override public void run() { JPanel gui = new JPanel(new BorderLayout()); Vector&lt;Integer&gt; v = new Vector&lt;Integer&gt;(); long start = System.nanoTime(); for (int ii=0; ii&lt;=1000000; ii++) { v.add(ii); } long end = System.nanoTime(); int duration = (int)((end-start)/1000000); v.add(duration); JList&lt;Integer&gt; list = new JList&lt;Integer&gt;(v); System.out.println("Duration in seconds: " + duration); JOptionPane.showMessageDialog(null, new JScrollPane(list)); } }; // Swing GUIs should be created and updated on the EDT // http://docs.oracle.com/javase/tutorial/uiswing/concurrency SwingUtilities.invokeLater(r); } }
downvote count: 1
has comment: http://stackoverflow.com/comment/32555614
has comment: http://stackoverflow.com/comment/32555122
answers question: http://stackoverflow.com/q/21555711
has comment: http://stackoverflow.com/comment/32555519
has comment: http://stackoverflow.com/comment/32555724

http://stackoverflow.com/comment/32727149
type: QuestionComment
score: 0
has text: Can you provide more details than "the worse it gets"? As to what the problem is? Stop moving? Moves too much? Gets real slow?
type: Comment
comment on: http://stackoverflow.com/q/21653599

http://stackoverflow.com/comment/32713916
has text: clean install - no change (
type: Comment
comment on: http://stackoverflow.com/q/21645350
type: QuestionComment
score: 0

http://stackoverflow.com/comment/32761295
comment on: http://stackoverflow.com/q/21648974
has text: When I say sdk 19 I mean launch the sdk manager and install the component "SDK Platform" for API 19. Phonegap 3.3 configures target sdk 19. If you had not sdk 19 installed when you first launched "phonegap run android", try removing the platforms/android folder before retesting.
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/32592255
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21576475
has text: You might be looking for [this](http://stackoverflow.com/a/16652683/1066946)
type: Comment

http://stackoverflow.com/comment/32525672
comment on: http://stackoverflow.com/q/21537402
has text: Questions about overall understanding of a concept can be tricky, I tried to provide as detailed an answer as I could. In Java's case people getting started with UIs should really stick to Swing (or JavaFX), so a commonly excepted answer (I think) is possible. I could be wrong though. If the question was "How to create a button in C++" then I would admit there are just to many ways to accomplish this to make a discussion meaningful.
type: Comment
type: QuestionComment
score: 1

http://stackoverflow.com/q/21571893
tagged with: java
tagged with: cluster-computing
type: Question
tagged with: frameworks
possible better answer: http://stackoverflow.com/a/21572121
has answer: http://stackoverflow.com/a/21572121
accepted answer: http://stackoverflow.com/a/21573133
has body: I need to share some jobs between different machines in a network. Is there any suitable framework in Java to use. In more details: consider you have some app, receiving some input data. As a result if its analysis you code decides to make some operations but based on some logic it can not afford to execute all necessary operations because of a lack of computational resources. So, it has to distribute the rest of task's parts among other machines. So, is there any framework which allows me to make such a distribution ? (I suppose it must provide some functions on registering machines, tasks creation, gathering the result...) Thank you!
score: 0
answer count: 3
favorite count: 0
upvote count: 1
downvote count: 1
has title: Recommend the best cluster framework to use in Java
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21573133
has answer: http://stackoverflow.com/a/21572557

http://stackoverflow.com/comment/32671261
comment on: http://stackoverflow.com/q/21621735
score: 0
type: Comment
type: QuestionComment
has text: @RamanSingh - I make wrong choice of words. It have a much more functionality than the standard Java Date API. See link, try and let us know.

http://stackoverflow.com/comment/32728653
has text: makes sense, but the loop starts at 0 though? so 5 ends up to be the max value?
comment on: http://stackoverflow.com/a/21654513
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/21622674
has body: Basically, from the MVC (Model-View-Controller) viewpoint, an Activity is a Controller, the view hierarchy is the View, and the View and Controller get re-created each time the orientation changes. Meanwhile, song playing belongs to the Model. Note that an activity has the methods onSaveInstanceState(Bundle) and onCreate(Bundle), and if the bundle passed to onCreate() is not null, it contains the information previously stored by onSaveInstanceState(). And there's also onRetainNonConfigurationInstance(). When the screen turns, the old activity is destroyed and a new activity is created, and these methods let the old activity pass important data to the new one. Even after you create a service, you have to keep this MVC stuff in mind.
type: Answer
answers question: http://stackoverflow.com/q/21622336
score: 0

http://stackoverflow.com/comment/32760942
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21672430
has text: Maybe something different in your code. Check this http://stackoverflow.com/questions/2481455/set-margins-in-a-linearlayout-programmatically and give a try: use the same approach and is working (according to SO user votes)

http://stackoverflow.com/q/21633997
has answer: http://stackoverflow.com/a/21635052
upvote count: 0
answer count: 1
favorite count: 0
accepted answer: http://stackoverflow.com/a/21635052
tagged with: quicksort
has comment: http://stackoverflow.com/comment/32693463
tagged with: java
has title: Arranging ArrayList of Strings with quicksort not working correctly
has body: I have an ArrayList composed of Strings all in lower case with no unique characters. I want to arrange this ArrayList in alphabetical order and I attempted so using "quicksort," however I noticed a problem in which my lo doesn't calculate correctly after the algorithm places the first pivot acquired in the correct location. For instance if my array is composed of a, d, e, c, a after my quicksort places the pivot a in its correct position and begins to sort the other side of array it begins at e instead of d causing the result to be a, d, a, c, e. Code: private ArrayList&lt;String&gt; sort(ArrayList&lt;String&gt; ar, int lo, int hi){ if (lo &lt; hi){ int splitPoint = partition(ar, lo, hi); sort(ar, lo, splitPoint); sort(ar, splitPoint +1, hi); } return ar; } private int partition(ArrayList&lt;String&gt; ar, int lo, int hi){ String pivot = ar.get(lo); lo--; hi++; while (true){ lo++; while (lo&lt;hi &amp;&amp; ar.get(lo).compareTo(pivot) &lt; 0){ lo++; } hi--; while (hi&gt;lo &amp;&amp; ar.get(hi).compareTo(pivot) &gt; 0){ hi--; } if (lo&lt;hi){ swap(ar, lo, hi); }else { return hi; } } } Method were algorithm is called: public Document(String fName){ ArrayList xa = loadFile(fName); sort(xa, 0, xa.size() - 1); } I tried debugging this numerous times but I keep getting lost at the part were the compiler starts going up the stack tree. Why is my lo one value higher than needed? What is causing this? Swap method: private ArrayList&lt;String&gt; swap(ArrayList&lt;String&gt; ar, int a, int b){ String temp = ar.get(a); ar.set(a, ar.get(b)); ar.set(b, temp); return ar; } Note: I start with pivot at position 0
downvote count: 1
type: Question
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32694107
tagged with: algorithm
score: -1
has comment: http://stackoverflow.com/comment/32694046
tagged with: arraylist

http://stackoverflow.com/q/21621000
type: Question
has answer: http://stackoverflow.com/a/21697317
accepted answer: http://stackoverflow.com/a/21697317
linked to: http://stackoverflow.com/q/9568612
has title: How to create executable (.exe) file for any platform using Sikuli-script + Java + Eclips IDE
answer count: 1
tagged with: sikuli
has body: I have create java application using sikuli-script(latest version 1.0.1). I added the sikuli-script.jar to the Referenced Libraries (I configured using this answer Answer Link) java code folder structure --> Java code --> package com.example.sikuli; import org.sikuli.script.*; import java.util.concurrent.TimeUnit; public class TestSikuli { public static void main(String[] args) { Screen s = new Screen(); App app = new App("C:/Program Files/Mozilla Firefox/firefox.exe");//firefox path try{ app.focus(); TimeUnit.SECONDS.sleep(2); s.click("imgs/1391152193781.png", 0);//url bar image s.type(null, "http://www.google.lk", 0); s.click("imgs/1391152289812.png", 0);//click search image } catch(FindFailed e){ e.printStackTrace(); } } } After that i set the the Run Configutrtion such as PATH and SIKULI_HOME Next I run the code it's working properly. Then I create .exe using launch4j and according to this site instructions --> How to Create an Executable File from Eclipse After that i run the .exe file from command prompt then following errors occurred. Please help me. Error --> [error] ResourceLoaderBasic: check: libs dir is empty, has wrong content or is outdated [action] ResourceLoaderBasic: check: Please wait! Trying to extract libs to: C:\Documents and Settings\Dell\SikuliX\libs [error] ResourceLoaderBasic: loadLib: Fatal Error 109: not found: C:\Documents and Settings\Dell\SikuliX\libs\VisionProxy.dll [error] Terminating SikuliX after a fatal error(109)! Sorry, but it makes no sense to continue! If you do not have any idea about the error cause or solution, run againwith a Debug level of 3. You might paste the output to the Q&amp;A board.
upvote count: 1
favorite count: 0
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
tagged with: eclipse

http://stackoverflow.com/a/21596303
type: Answer
has body: sessionTarget = jsch.getSession(backupUser, backupHost, backupPort); Here in this line, getSession() method can throw an Exception, and hence the variables sessionTarget and channelTarget will be null, and in the finally block, you are accessing those variables, which may cause null pointer exception. To avoid this, in the finally block check for null before accessing the variable. finally { if (channelTarget != null) { channelTarget.exit(); channelTarget.disconnect(); } if (sessionTarget != null ) { sessionTarget.disconnect(); } }
upvote count: 23
score: 23
accepted answer of: http://stackoverflow.com/q/21596262
answers question: http://stackoverflow.com/q/21596262
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/21622845
upvote count: 1
answers question: http://stackoverflow.com/q/21622567
has body: try this sc.useDelimiter("\\D+"); int n1 = sc.nextInt(); int n2 = sc.nextInt();
downvote count: 0
type: Answer
score: 1

http://stackoverflow.com/a/21518789
type: Answer
answers question: http://stackoverflow.com/q/21518607
has body: Parsing XML correctly requires a much more flexible (and complicated) mechanism than the routine you have here. You would do better to make use of an existing parser. If you really want to write your own, this code is not the foundation of a workable approach. Remember that XML is not line based and there are no requirements for related tags to be contained on the same line. This makes parsing a file line by line a difficult and awkward way to get started, and trying to identify entities by pattern matching one line at a time is simply a broken technique (any entity may always span more than a single line).
score: 0

http://stackoverflow.com/a/21634327
has body: If the .bat file is in a different folder you should pass its full absolute path to cmd.exe. Also, to get the correct quoting you should use the method that takes an array as argument: String[] cmd = {"cmd", "/c", "start", path}; Runtime.getRuntime().exec(cmd); If you know the location of the .bat file relative to your .jar file, you can find it using the properties of the Class object. See for example How to get the path of a running JAR file?
upvote count: 1
score: 1
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21634273

http://stackoverflow.com/q/21531299
tagged with: intellij-idea
has body: I get somes module in Intellij. Let's assume that ProjectName is : ..One Project --> ModuleProjectNameOne --> src/main/MyMainClass -->ModuleProjectNameTwo --> src/main/java -->ModuleProjectNameThree -->folder/pom.txt --> src/main/MyMainClass I wan to open the pom.txt File file= new File("pom.txt"); if (file.exists()) { System.out.println("File"); } else if (fr.isDirectory()) { System.out.println("Directory!"); } Here the root of the project System.out.println(new File(".").getAbsolutePath()); // shows C:\user...\ModuleProjectNameOne\. How could i reach the specific file pomxt inside ModuleProjectNameThree ?
answer count: 1
has comment: http://stackoverflow.com/comment/32511849
score: 0
has title: Open a File of a specific module Intellij
type: UnansweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/21532066
type: Question

http://stackoverflow.com/comment/32724996
score: 0
type: Comment
comment on: http://stackoverflow.com/q/21652237
type: QuestionComment
has text: Is it "find the number" or "find the numbers" or "find the first number" or "find any number from the array"?

http://stackoverflow.com/a/21568732
answers question: http://stackoverflow.com/q/21568418
score: 0
type: Answer
has body: Foremost, why do you want to go for HashMap? No doubt, it will make retrieval logic bit easy if you probably can remember the key values you are inserting in the map for each continent. However, the logic which you can probably go for can be like, you need to parse the list given as an input, and put in each country placed below the name of the continent in a list and put in the HashMap. Now, during retrieval you just need to provide the key and retrieve the list of country for a particular continent. import java.util.ArrayList; import java.util.HashMap; import java.util.List; public class TestMaps { public void check(HashMap&lt;Integer,List&lt;String&gt;&gt; m) { System.out.println(m.get(1)); //System.out.println(m.get(2)); System.out.println(m); } public static void main(String[] args) { HashMap &lt;Integer,List&lt;String&gt;&gt; m = new HashMap&lt;Integer,List&lt;String&gt;&gt;(); List &lt;String&gt; ls =new ArrayList&lt;String&gt;(); ls.add("India"); ls.add("Indonesia"); m.put(1, ls); TestMaps test=new TestMaps(); test.check(m); } } Probably, you can also go for String value continent name as a key but an Integer is always a better choice for a key value. However, for a key value to be a String just replace the above code like: HashMap&lt;String, List&lt;String&gt;&gt; m = new HashMap&lt;String, List&lt;String&gt;&gt;(); List&lt;String&gt; ls = new ArrayList&lt;String&gt;(); ls.add("India"); ls.add("Indonesia"); m.put("Asia", ls); Apart from this, you can also use List of List and develop the functionality you need. Note: You need to have a parsing logic for the input text file. I haven't given the code for the same. I am expecting the input file to be of the type: Continent 1 Country 1 Country 2 Country 3 Country n Continent 2 Country n Continent n

http://stackoverflow.com/comment/32617042
has text: I want to export all the hours and minutes inputted by the user. so if numOfTimes = 1 -- and they input 16 as the hour and 29 as the minute; I want the text file to contain "1629".
score: 0
comment on: http://stackoverflow.com/q/21590117
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/32647559
score: 2
has text: because u are a new user. please read the FAQ.
comment on: http://stackoverflow.com/q/21608283
type: QuestionComment
type: Comment

http://stackoverflow.com/q/21572564
has answer: http://stackoverflow.com/a/21572652
linked to: http://stackoverflow.com/q/286007
linked to: http://stackoverflow.com/q/1565388
score: 0
answer count: 3
tagged with: apache
has answer: http://stackoverflow.com/a/21572619
tagged with: heap-memory
linked to: http://stackoverflow.com/q/5374455
has comment: http://stackoverflow.com/comment/32585062
has answer: http://stackoverflow.com/a/21572852
type: UnansweredQuestion
tagged with: java
has body: i got following error . exception org.apache.jasper.JasperException: Java heap space org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:433) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) root cause javax.servlet.ServletException: Java heap space org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774) org.apache.jsp.jsp.FileManagement.downloadOut_jsp._jspService(downloadOut_jsp.java:148) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) root cause java.lang.OutOfMemoryError: Java heap space How to resolve it ?
has comment: http://stackoverflow.com/comment/32585021
has comment: http://stackoverflow.com/comment/32585102
type: Question
has title: How to increase my heap size
tagged with: tomcat5.5

http://stackoverflow.com/comment/32494197
comment on: http://stackoverflow.com/q/21521520
score: 1
type: Comment
type: QuestionComment
has text: Have an array of these words and do some more things and you're done.

http://stackoverflow.com/q/21556425
type: Question
has answer: http://stackoverflow.com/a/21559351
has comment: http://stackoverflow.com/comment/32560052
has body: I have a table which can referance on itself. organisation(id,child_from_Org, ...) Hibernate Mapping @Entity @Table(name = "organisation") public class Organisation implements java.io.Serializable { private Integer id; private Organisation organisation; private ... @Id @GeneratedValue(strategy = IDENTITY) @Column(name = "id", unique = true, nullable = false) public Integer getId() { return this.id; } public void setId(Integer id) { this.id = id; } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "child_from_Org") public Organisation getOrganisation() { return this.organisation; } public void setOrganisation(Organisation organisation) { this.organisation = organisation; } ... } If i execute a a hibernate query like "from Organisation", then i'll get all organisations. from Organisation o where o.id = 1 Then i get the organisation with id 1 from Organisation o where o.id = 1 or o.organisation.id = 1 Returns organisation with id 1 and all child organisations from Organisation o where o.id = 1 or o.organisation.id = 1 or o.organisation.organisation.id = 1 Does not return the organisation with id 1!!!! Why? I tried all possible combinations with braclets (() or () or ()). I looks like a wrong SQL is getting generated from hibernate: select organisati0_.id as id470_, organisati0_.child_from_Org as ist21_470_,70_, ,... from organisation organisati0_ cross join organisation organisati1_ where organisati0_.child_from_Org=organisati1_.id and ( organisati0_.id=1 or organisati0_.child_from_Org=1 or organisati1_.child_from_Org=1 ) How can i resolve that problem?
tagged with: sql
has comment: http://stackoverflow.com/comment/32560498
downvote count: 0
answer count: 1
favorite count: 0
accepted answer: http://stackoverflow.com/a/21559351
has comment: http://stackoverflow.com/comment/32555638
has title: Hibernate returns wrong result set and generates wrong query
score: 2
type: AnsweredQuestion
upvote count: 2
tagged with: java
tagged with: hibernate

http://stackoverflow.com/comment/32562810
comment on: http://stackoverflow.com/a/21557717
score: 0
type: AnswerComment
has text: Is there a way for the %2b to be %2B? same for the %3d
type: Comment

http://stackoverflow.com/a/48603657
type: Answer
has body: The substring() method (which was changed in Java 7), will always return a new object. The only exception to this is if it is to return the whole string (substring(0)). Then, it will return it from the pool and the equality expression (==) will evaluate to true. This is the reason why statement 1 is true, but statement 2 false. An example.
answers question: http://stackoverflow.com/q/21606800
score: 0

http://stackoverflow.com/comment/32679004
score: 0
comment on: http://stackoverflow.com/q/21626485
type: Comment
has text: What error is coming when you run your project..
type: QuestionComment

http://stackoverflow.com/a/21701125
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32823955
has body: Use @Param annotation like this @Insert(CREATE) @Options(useGeneratedKeys = true, keyProperty = "object.id", flushCache = true) public int write(@Param("tablename") String tablename, @Param("object") Object object) throws Exception; and query INSERT INTO ${tablename} (column1, column2) VALUES (#{object.column1}, #{object.column2})
type: Answer
upvote count: 4
accepted answer of: http://stackoverflow.com/q/21651338
answers question: http://stackoverflow.com/q/21651338
score: 4

http://stackoverflow.com/q/21573863
accepted answer: http://stackoverflow.com/a/21574069
type: AnsweredQuestion
score: 0
has title: Crash on image upload
has body: Here is how I am getting an image from android camera: Bitmap photo = (Bitmap) data.getExtras().get("data"); ByteArrayOutputStream stream = new ByteArrayOutputStream(); byte[] byteArrayImage = stream.toByteArray(); File f; try { f = File.createTempFile("temp-file-name", ".png"); f.createNewFile(); FileOutputStream fos = new FileOutputStream(f); fos.write(byteArrayImage); fos.close(); } catch (IOException e) { e.printStackTrace(); } Then I am calling this function with the file I have created: public String multiPartExecute(String url, String keyOfString, String request, String keyForFile, File file) { HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost(url); MultipartEntityBuilder multipartEntity = MultipartEntityBuilder.create(); multipartEntity.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); multipartEntity.addPart(keyForFile, new FileBody(file)); //here is the crash multipartEntity.addTextBody(keyOfString, request); post.setEntity(multipartEntity.build()); HttpResponse response = null; String line = "", output = ""; try { response = client.execute(post); BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent()))); while ((line = br.readLine()) != null) { output += line; } } catch (ClientProtocolException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } if (response.getStatusLine().getStatusCode() != 200) { response.getStatusLine().getStatusCode(); return null; } HttpEntity entity = response.getEntity(); try { entity.consumeContent(); } catch (IOException e) { e.printStackTrace(); return null; } client.getConnectionManager().shutdown(); return output; } I have a crash on this line: multipartEntity.addPart(keyForFile, new FileBody(file));. Here is the log cat output: 02-05 11:46:40.359: E/WindowManager(9773): Activity com.evapp.activities.NewEventActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@a70e4b40 that was originally…
type: Question
has comment: http://stackoverflow.com/comment/32587438
tagged with: java
tagged with: image
has answer: http://stackoverflow.com/a/21574069
answer count: 1
tagged with: file-upload
tagged with: android

http://stackoverflow.com/comment/32648520
score: 0
has text: javap -c shows both use JVM instruction invokeinterface. So maybe the hotspot compiler might have nore work on interfaces than classes, there being several interfaces per class. Irreal.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21608240

http://stackoverflow.com/q/21633745
tagged with: java
tagged with: cygwin
tagged with: eclipse
upvote count: 2
tagged with: hadoop
answer count: 1
has answer: http://stackoverflow.com/a/21635670
favorite count: 0
has body: i am new to hadoop framework , currently i am working with big data projects, using cygwin , hadoop-0.19.1 ,eclipse-3.3.1 (Europa) in windows 7. now i am trying to change from hadoop -0.19.1 to hadoop-1.2.1 version.i configured hadoop-1.2.1 as follows core-site.xml: <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> fs.default.name hdfs://localhost:9100 hdfs.xml <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> dfs.replication 1 mapred-site.xml <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> mapred.job.tracker localhost:9101 but i got error in starting datanode as below $ bin/hadoop datanode 14/02/07 22:24:09 INFO datanode.DataNode: STARTUP_MSG: /************************************************************ STARTUP_MSG: Starting DataNode STARTUP_MSG: host = raj-PC/101.63.181.80 STARTUP_MSG: args = [] STARTUP_MSG: version = 1.2.1 STARTUP_MSG: build = https://svn.apache.org/repos/asf/hadoop/common/branches/b ranch-1.2 -r 1503152; compiled by 'mattf' on Mon Jul 22 15:23:09 PDT 2013 STARTUP_MSG: java = 1.7.0_45 ************************************************************/ 14/02/07 22:24:10 INFO impl.MetricsConfig: loaded properties from hadoop-metrics 2.properties 14/02/07 22:24:10 INFO impl.MetricsSourceAdapter: MBean for source MetricsSystem ,sub=Stats registered. 14/02/07 22:24:10 INFO impl.MetricsSystemImpl: Scheduled snapshot period at 10 s econd(s). 14/02/07 22:24:10 INFO impl.MetricsSystemImpl: DataNode metrics system started 14/02/07 22:24:11 INFO impl.MetricsSourceAdapter: MBean for source ugi registere d. 14/02/07 22:24:11 WARN impl.MetricsSystemImpl: Source name ugi already exists! 14/02/07 22:24:11 WARN util.NativeCodeLoader: Unable to load native-hadoop libra ry for your platform... using builtin-java classes where applicable 14/02/07 22:24:11 WARN datanode.DataNode: Invalid directory in dfs.data.dir: Fai led to set permissions of path: \tmp\hadoop-raj\dfs\data t…
type: UnansweredQuestion
score: 2
downvote count: 0
type: Question
has title: Invalid directory in dfs.data.dir: Failed to set permissions of path: \tmp\hadoop-user\dfs\data to 0755

http://stackoverflow.com/comment/32725948
comment on: http://stackoverflow.com/q/21652919
type: Comment
type: QuestionComment
has text: Can you post the code your using to get the data from your database and send it to the server?
score: 0

http://stackoverflow.com/a/21613903
has comment: http://stackoverflow.com/comment/33116755
has comment: http://stackoverflow.com/comment/33145823
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33214039
type: Answer
has body: It depends from the Application Server, number of nodes and application, but the follwing scenarios are ok for me: Weblogic or JBOSS support Unit of Order feature: Message Unit-of-Order is a WebLogic Server value-added feature that enables a stand alone message producer, or a group of producers acting as one, to group messages into a single unit with respect to the processing order. This single unit is called a Unit-of-Order and requires that all messages from that unit be processed sequentially in the order they were created. If you update the same record the first thread acquire the lock and the second thread wait the transaction commit, then the second thread should check the update (optimistic lock) and it could exit immediatly. eg. Thread 1: lastUpd = now() Thread 1: UPDATE MYTABLE SET LAST_UPDATE=${lastUpd} WHERE ID=${id} Thread 2: lastUpd = now() Thread 2: UPDATE MYTABLE SET LAST_UPDATE=${lastUpd} WHERE ID=${id} //remain locked Thread 1: a lot of work ... Thread 1 COMMIT Thread 2: a lot of work ... Thread 2: lastUpd2= SELECT LAST_UPDATE MYTABLE WHERE ID=${id} Thread 2: IF lastUpd2!= lastUpd ROLLBACK
accepted answer of: http://stackoverflow.com/q/21592912
score: 0
has comment: http://stackoverflow.com/comment/33101390
answers question: http://stackoverflow.com/q/21592912

http://stackoverflow.com/comment/32764081
comment on: http://stackoverflow.com/a/21666083
type: Comment
has text: @petrosKoutsolampros I don't why he edited that comment, I am pretty sure it said `java.lang.reflect.InvocationTargetException`
score: 0
type: AnswerComment

http://stackoverflow.com/q/21527866
has title: Android HTTP post with {"key" => JSON}
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has answer: http://stackoverflow.com/a/21528059
downvote count: 0
answer count: 1
favorite count: 0
type: UnansweredQuestion
tagged with: android
score: 1
upvote count: 1
has body: I've been using lots of HTTP posts in my apps recently and I've always been using this template: HttpPost httpPost = new HttpPost(server); List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(); nameValuePairs.add(new BasicNameValuePair("name","John")); nameValuePairs.add(new BasicNameValuePair("age",13+"")); ... httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); httpClient.execute(httpPost); And on the server's PHP script: $name = $_POST['name']; $age = $_POST['age']; ... This has always worked perfectly. However, recently I got a request that the data should actually be a JSON itself which would contain all those key-value pairs. To be more explicit, the PHP script has been written to do this: $json = $_POST['data']; $name = $json['name']; $age = $json['age']; ... While this is an awkwardly simple modification, I can't seem to make it work in the Android code, i.e. I can't find the correct way to add the JSON to the HTTP data. I'm doing this: JSONObject json = new JSONObject(); json.put("name", "John"); json.put("age", 13+""); ... But what to do next?? How can I add this JSON to the HTTP with the key "data"? I've tried this: List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(); nameValuePairs.add(new BasicNameValuePair("data", json.toString())); httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); But I'm not sure it's the right way to do it and also the server's response is signalling an error. How should I do it? How should I GENERALLY add a JSONObject with a key, or even a JSONArray? Thanks! EDIT: Please don't send me to other SO links, I've looked and none is answering straight to my point.
type: Question

http://stackoverflow.com/comment/32555135
type: Comment
score: 0
type: AnswerComment
has text: Where should I put the OnCLickListener that will link it to the button? Thanks for the help.
comment on: http://stackoverflow.com/a/21540563

http://stackoverflow.com/comment/32678958
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21625572
has text: Sure, just look carefully at paragraph 'Inter-prodedural null analysis' and the second example on method `getString` --- it declares, that it will never return `null` (on the other hand you can use `@Nullable` to tell it actually can return a `null`). And yes, it won't solve ALL problems you've mentioned, hence the word "partially". 8)

http://stackoverflow.com/comment/55810123
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21551289
has text: I've encountered the exact same problem, using JDK7 under Windows. Total runtime had only been several seconds when it occurred, but the default GC behaved exactly as you describe in your edit. Unfortunately, the JDK bug you mention says they're not going to bother fixing the bug because they're focusing on JRE signed jars and SSL startup.

http://stackoverflow.com/a/21668464
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21668016
has body: As seen in this answer, You can create a BufferedImage of the JPanel contents. The example has PanelOne (which is a JPanel) being passed to a method of another JPanel (PanelTwo), and this is the method in PanelTwo that creates a BufferedImage from the PanelOne passed to it. BufferedImage bi; .... private void setImage(PanelOne panel) { Dimension d = panel.getPreferredSize(); int w = (int)d.getWidth(); int h =(int)d.getHeight(); bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g = bi.createGraphics(); panel.paint(g); g.dispose(); } .... @Override protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(bi, 0, 0, 250, 250, 0, 0, 250, 250, this); } Here's the result. PanelOne is the left and passes itself to PanelTwo on the right
type: Answer
accepted answer of: http://stackoverflow.com/q/21668016
upvote count: 1
score: 1

http://stackoverflow.com/comment/32751470
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21564891
has text: Thank you so much for your time and help.The number of MySql database connections was not the issue. There was some environment issue on my side. Due to the tight schedule I switched to BoneCP. Now everything works fine with 1000 concurrent calls with the default number of MySql connections. The performance looks very good. I appreciate all your time and help. And we may do developer's talk another time. Thank you again for your time and help. All the best.

http://stackoverflow.com/q/21556647
has answer: http://stackoverflow.com/a/21573911
tagged with: cglib
accepted answer: http://stackoverflow.com/a/21559621
tagged with: proxy-classes
answer count: 3
downvote count: 0
has answer: http://stackoverflow.com/a/71201107
favorite count: 0
has body: I have a proxy (generated either as a JDKProxy or a CGLIB one) that is generated at runtime in the JVM. I wanted to know if there is a way to write the contents of this class (which looks like com.sun.proxy$Proxy123.class) to a file so that I may use a jd-eclipse like decompiler to see the kind of code generated. Since the class is present in the JVM, I wanted to know if there is a way we can ask the ClassLoader to provide an InputStream/URL to the actual class that can then be used to write contents to disk - and this file on the disk can be read using either jd-eclipse or javap. I know that this is not a production use case, but I was curious to see the contents of this dynamically generated class. Thanks!
has answer: http://stackoverflow.com/a/21559621
type: AnsweredQuestion
score: 7
tagged with: java
upvote count: 7
has title: Serializing a proxy class to file
possible better answer: http://stackoverflow.com/a/21573911
type: Question

http://stackoverflow.com/comment/32579019
score: 4
comment on: http://stackoverflow.com/a/21568647
type: AnswerComment
type: Comment
has text: @BrianRoach "It might run slightly longer because it reads the stale stop value N times, but eventually the cache will sync." That is totally wrong. Almost all modern caches are instantaneously coherent in hardware. This has nothing to do with caches.

http://stackoverflow.com/comment/32554141
score: 0
type: Comment
has text: If you are fetching user from db then why do you need `new`? And show code where are you fetching user.
type: QuestionComment
comment on: http://stackoverflow.com/q/21555392

http://stackoverflow.com/a/21649746
has comment: http://stackoverflow.com/comment/100470794
has comment: http://stackoverflow.com/comment/32720803
has comment: http://stackoverflow.com/comment/32722281
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/21648843
has body: It seems that dims[0]*dims[1]*dims[2] is to large for integers, it can't be larger than 2,147,483,647. Otherwise an integer can't store the index.
upvote count: 1

http://stackoverflow.com/q/21677969
linked to: http://stackoverflow.com/q/9554636
has answer: http://stackoverflow.com/a/21680953
has comment: http://stackoverflow.com/comment/32769324
tagged with: jdialog
has comment: http://stackoverflow.com/comment/32769420
score: 0
has comment: http://stackoverflow.com/comment/32769704
answer count: 1
has body: I have a JDialog where a Jtable is shown, a cell of the JTable is a JButton that open a new JFrame (CoveNew): public void birthstats(String stat) { //System.out.println(classeMain); String titolo=new String(); if ("nascite".equals(stat)){ titolo=lingua_corrente.getString("nascite_title"); elencojLabel.setText(titolo); } else{ titolo=lingua_corrente.getString("anella"); elencojLabel.setText(titolo); } Dimension dimensioni = new Dimension(500, 700); nascitejDialog.setSize(dimensioni); nascitejDialog.setTitle("GesAll 1.0 - " + titolo); nascitejDialog.setModal(true); hatchlistijTable.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null, null} }, new String [] { "Num", lingua_corrente.getString("coppiaLabel"), lingua_corrente.getString("annojLabel"), lingua_corrente.getString("jLabel8"), lingua_corrente.getString("NascitaLabel") } ) { Class[] types = new Class [] { java.lang.String.class, java.lang.String.class, java.lang.String.class, JButton.class, java.lang.String.class }; boolean[] canEdit = new boolean [] { false, false, false, false, false }; @Override public Class getColumnClass(int columnIndex) { return types [columnIndex]; } @Override public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); hatchlistijTable.setShowGrid(true); hatchlistijTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); hatchlistijTable.getColumnModel().getColumn(0).setHeaderValue("Num."); //Numero hatchlistijTable.getColumnModel().getColumn(0).setResizable(false); hatchlistijTable.getColumnModel().getColumn(0).setPreferredWidth(60); hatchlistijTable.getColumnModel().getColumn(1).setHeaderValue(lingua_corrente.getString("coppiaLabel")); //coppia hatchlistijTable.getColumnModel().getColumn(1).setResizable(false); hatchlistijTable.getColumnModel().getColumn(1).setPreferredWidth(50); hatchlistijTable.getColumnModel().getColumn(2).setHeaderValue(lingua_corrente.getString("annojLabel")); //anno hatchlistijTable…
tagged with: jframe
type: UnansweredQuestion
tagged with: swing
tagged with: jbutton
has comment: http://stackoverflow.com/comment/32769545
has title: Jbutton performing more action
tagged with: java
has comment: http://stackoverflow.com/comment/32769705
type: Question

http://stackoverflow.com/a/21549524
accepted answer of: http://stackoverflow.com/q/21548989
score: 6
answers question: http://stackoverflow.com/q/21548989
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/64135444
type: Answer
has comment: http://stackoverflow.com/comment/32546622
upvote count: 6
has body: The javadoc for Objects.equals(obj a, obj b) says: Returns true if the arguments are equal to each other and false otherwise. Consequently, if both arguments are null, true is returned and if exactly one argument is null, false is returned. Otherwise, equality is determined by using the equals method of the first argument. which is the equivalent to: if (a == null &amp;&amp; b == null) { return true; } else if (a == null || b == null) { return false; } else return a.equals(b);

http://stackoverflow.com/comment/32666416
has text: I know that a solution that would surely work is using an enum but enums aren't in what I have been taught since this day.
score: 0
comment on: http://stackoverflow.com/a/21618611
type: AnswerComment
type: Comment

http://stackoverflow.com/a/23561086
score: 1
answers question: http://stackoverflow.com/q/21544973
has body: Found out these problems can be addressed by using ObjectMapper#convertValue(Object fromValue, Class&lt;T&gt; toValueType) As a result, the origal quuestion can be solved in a 2-step converison: Demarshall the JSON back to an object - in which the Map&lt;String, Object&gt; is demarshalled as a HashMap&lt;String, LinkedHashMap&gt;, by using bjectMapper#readValue(). Convert inner LinkedHashMaps back to proper objects ObjectMapper mapper = new ObjectMapper(); Class clazz = (Class) Class.forName(classType); MyOwnObject value = mapper.convertValue(value, clazz); To prevent the 'classType' has to be known in advance, I enforced during marshalling an extra Map was added, containing &lt;key, classNameString&gt; pairs. So at unmarshalling time, the classType can be extracted dynamically.
upvote count: 1
type: Answer
downvote count: 0

http://stackoverflow.com/a/21650366
type: Answer
has body: The problem with this code is all your code is under the if statemente for Full-Size so the case 2 only executes when you select full-size , Yes to coupon and after showing the final message you press F again the code should look like this. public class CarRental { public static void main(String[] args){ for(int i=0; i&lt;4; i++){ System.out.println("Programmed by ."); double standardCompact = 30.50; double couponCompact = ((30.50)-(30.50 * 0.07)); double standardFullSize = 40.50; double couponFullSize = ((40.50)-(40.50 * 0.07)); //Scanner Input Scanner input = new Scanner(System.in); System.out.print("Rent a Car? [Y or N]: "); //Response String String response = input.next().toUpperCase(); if (response.equals("N")){ System.out.println("You entered no. Bye. "); }else if (response.equals("Y")) { System.out.print("Compact or Full-Size? [C or F]: "); //case1 response = input.next().toUpperCase(); if (response.equals("C")) { System.out.println("You selected Compact. "); System.out.print("Have coupon? [Y or N]: "); response = input.next().toUpperCase(); if (response.equals("N")) { System.out.println("Price is" + " " + standardCompact + " " + "per day."); } else if (response.equals("Y")) { System.out.println("Price is" + " " + couponCompact + " " + "per day."); } //case 2 }else if(response.equals("F")){ System.out.println("You have selected Full-Size. "); System.out.println("Have coupon? [Y or N]: "); response = input.next().toUpperCase(); if (response.equals("N")) { System.out.println("Price is" + " " + standardFullSize + " " + "per day."); } else if (response.equals("Y")) { System.out.println("Price is" + " " + couponFullSize + " " + "per day."); } } } } } As you can see in the code above is really important to correctly close conditional blocks so the code really does what you expect it to do. Using flow diagrams is a good support for learning how programming languages really work.
score: 0
answers question: http://stackoverflow.com/q/21650116

http://stackoverflow.com/comment/65276949
type: Comment
comment on: http://stackoverflow.com/a/21644977
score: 1
type: AnswerComment
has text: The order is changed because Android converts the `LinkedHashMap` to a `HashMap` when you call `putExtra()`, thereby discarding all the ordering.

http://stackoverflow.com/q/21545884
has title: When I create Intent, he created with value null
tagged with: android
tagged with: android-intent
accepted answer: http://stackoverflow.com/a/21546668
has comment: http://stackoverflow.com/comment/32537018
has body: I have the next code in my application, I try start Activity, but application force closed in emulator. public class LoginActivity extends Activity { static Button btnLogin; public static final String TAG="---------2-----"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.logining); btnLogin =(Button)findViewById(R.id.btnLogon); } public void onClickLogon(View view){ AscTaskLogin LoginTask = new AscTaskLogin(this); LoginTask.execute("1","1"); } public static void LOGV(final String tag, String message){ if(BuildConfig.DEBUG){ Log.v(tag, message); } } } function ResultAsync work after AsyncTask. this my AsynckTask public class AscTaskLogin extends AsyncTask&lt;String, Void, Boolean&gt; { LoginActivity mActivity; public AscTaskLogin(Activity activity) { this.mActivity = mActivity; } public static final String TAG="---------2-----"; protected void onPreExecute() { LoginActivity.LOGV(TAG, "PreExecite -------" ); } protected void onPostExecute(Boolean result) { LoginActivity.LOGV(TAG, "PostExecite -------" ); Intent i = new Intent(); i.setClass(mActivity, Copy.class); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mActivity .startActivity(i); } @Override protected Boolean doInBackground(String... sendData) { try { TimeUnit.SECONDS.sleep(1); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } // TODO Auto-generated method stub LoginActivity.LOGV(TAG, "doInBackground ------"); return true; } } in Manifest file i writed about activity. &lt;activity android:name="LoginActivity"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt;&lt;/activity&gt; &lt;activity android:name="MainActivity"&gt;&lt;/activity&gt; &lt;activity android:name="Copy"&gt;&lt;/activity&gt; application close with next errors 02-04 14:55:49.639: V/---------2-----(3065): doInBack…
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21546111
tagged with: java
has answer: http://stackoverflow.com/a/21546111
has answer: http://stackoverflow.com/a/21546518
type: Question
has answer: http://stackoverflow.com/a/21546668
score: 0
answer count: 3
has comment: http://stackoverflow.com/comment/32537259

http://stackoverflow.com/q/21561909
has answer: http://stackoverflow.com/a/21562385
linked to: http://stackoverflow.com/q/4361242
downvote count: 0
possible better answer: http://stackoverflow.com/a/21562385
favorite count: 0
has comment: http://stackoverflow.com/comment/32566836
has answer: http://stackoverflow.com/a/21565237
answer count: 4
score: 2
accepted answer: http://stackoverflow.com/a/21565237
upvote count: 2
has body: I have a transform matrix with values like this. Transform: xx, xy, yx, yy, tx, and ty respectively. How can I find the angle from the above set of gives values.
has answer: http://stackoverflow.com/a/60173057
has answer: http://stackoverflow.com/a/21563450
type: AnsweredQuestion
tagged with: math
tagged with: java
has comment: http://stackoverflow.com/comment/32566462
has comment: http://stackoverflow.com/comment/32572092
has title: Finding Angle from transform matrix
type: Question

http://stackoverflow.com/comment/32665593
has text: Your `drinkList` is a `List` of what?
comment on: http://stackoverflow.com/q/21618123
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/q/21526153
has comment: http://stackoverflow.com/comment/32504699
accepted answer: http://stackoverflow.com/a/21526892
upvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/32505479
type: AnsweredQuestion
score: 1
tagged with: java
has body: I am storing a Timestamp value in a sqlite database, but when I access the value in string format it gives me the right time, but when I try and access it in long, time and Timestamp format it gives me the wrong time. How can i get it right in Regular-time period format ? Creating Table String sql = "CREATE TABLE IF NOT EXISTS graphTable " + "(TIME TIMESTAMP NOT NULL DEFAULT current_timestamp) " ; /* Access the value from database using java code */ ResultStatement rs = stmt.executeQuery( "SELECT TIME FROM graphTable ;" ); while ( rs.next() ) { Date resultdate = new Date(rs.getLong()*1000); Millisecond ms_read = new Millisecond(resultdate); System.out.println( "TIME = " + ms_read ); }
answer count: 2
has answer: http://stackoverflow.com/a/21526391
downvote count: 0
has comment: http://stackoverflow.com/comment/32502394
has title: SQLite timestamp values in different types
has answer: http://stackoverflow.com/a/21526892
favorite count: 0
has comment: http://stackoverflow.com/comment/32504921
possible better answer: http://stackoverflow.com/a/21526391
has comment: http://stackoverflow.com/comment/32502264
tagged with: sqlite

http://stackoverflow.com/a/21588202
accepted answer of: http://stackoverflow.com/q/21585069
upvote count: 4
downvote count: 0
score: 4
type: AcceptedAnswer
has body: See https://www.opengl.org/sdk/docs/man/xhtml/glActiveTexture.xml texture must be one of GL_TEXTUREi In practice you can offset your unit with GL10.GL_TEXTURE0, e.g: Gdx.gl.glActiveTexture(GL10.GL_TEXTURE0 + unit); Note that Texture#bind(int unit); (where unit is zero based, so doesn't requires to offset using GL10.GL_TEXTURE0) will make the specified unit active. You don't have to call glActiveTexture prior to calling texture.bind(1);. tl;dr: ... spritebatch.setShader(my_shader); my_second_texture.bind(1); Gdx.gl.glActiveTexture(GL10.GL_TEXTURE0); my_shader.setUniformi("my_second_texture", 1); ...
has comment: http://stackoverflow.com/comment/32616563
type: Answer
answers question: http://stackoverflow.com/q/21585069

http://stackoverflow.com/comment/32622834
comment on: http://stackoverflow.com/q/21593184
score: 0
type: Comment
type: QuestionComment
has text: `Thread.sleep(5000);` Don't block the EDT (Event Dispatch Thread) - the GUI will 'freeze' when that happens. Instead of calling `Thread.sleep(n)` implement a Swing `Timer` for repeating tasks or a `SwingWorker` for long running tasks. See [Concurrency in Swing](http://docs.oracle.com/javase/tutorial/uiswing/concurrency/) for more details.

http://stackoverflow.com/comment/32640662
comment on: http://stackoverflow.com/a/21604280
type: Comment
has text: Yes, it's the ugly side of Java's type inference. It's an example of an *upcast* which actually makes sense.
score: 0
type: AnswerComment

http://stackoverflow.com/q/21579503
has body: I am using JAXB to generate binding classes from a DTD. I have a custom binding file binding.xjb as follows &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd " &gt; &lt;jaxb:globalBindings generateValueClass="false"&gt; &lt;xjc:simple /&gt; &lt;/jaxb:globalBindings&gt; &lt;/jaxb:bindings&gt; When I run the xjc compiler, as follows xjc -dtd -d target/generated-sources/ -b src/main/jaxb/binding.xjb -p com.example src/main/jaxb/my-dtd.dtd I get the following errors [ERROR] Unsupported binding namespace "http://java.sun.com/xml/ns/jaxb". Perhaps you meant "http://java.sun.com/xml/ns/jaxb/xjc"? line 7 of file:/Users/.../Development/projects/fuel/src/main/jaxb/binding.xjb [ERROR] cvc-elt.1: Cannot find the declaration of element 'jaxb:bindings'. line 7 of file:/Users/.../Development/projects/fuel/src/main/jaxb/binding.xjb [ERROR] Unsupported binding namespace "http://java.sun.com/xml/ns/jaxb". Perhaps you meant "http://java.sun.com/xml/ns/jaxb/xjc"? line 9 of file:/Users/.../Development/projects/fuel/src/main/jaxb/binding.xjb Failed to parse a schema. As far as I can tell, my binding XML is valid. Am I missing something? I am on Java 1.7 on MacOS (Mavericks) java -version returns java version "1.7.0_51" Java(TM) SE Runtime Environment (build 1.7.0_51-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode) and xjc -version returns xjc 2.2.4-2
type: Question
has title: How do I fix a JAXB Unsupported Binding Namespace error?
upvote count: 5
downvote count: 0
favorite count: 0
score: 5
tagged with: http://stackoverflow.com/tag/xml
answer count: 0
type: UnansweredQuestion
tagged with: java
tagged with: jaxb

http://stackoverflow.com/comment/32671792
type: AnswerComment
score: 0
type: Comment
has text: That is simple enough to fix, thank you for this. I don't know how long it would have taken me to realize that nextInt skips whitespace.
comment on: http://stackoverflow.com/a/21621708

http://stackoverflow.com/comment/74729896
has text: Hi, I am trying to use package (MY_PACKAGE) with type (MY_TYPE) in wso2 dss, it is not working for me . i used: MY_PACKAGE.MY_TYPE (not working), MY_SCHEMA.MY_PACKAGE.MY_TYPE (not working) MY_TYPE (not working) . please advise?
type: Comment
comment on: http://stackoverflow.com/a/21589348
score: 0
type: AnswerComment

http://stackoverflow.com/tag/r
tags question: http://stackoverflow.com/q/21602648
tags question: http://stackoverflow.com/q/21515155
tag name: r
tags question: http://stackoverflow.com/q/21514769
type: Tag

http://stackoverflow.com/q/21677479
has title: LinkedBlockingQueue's thread-safety with many producers in a producer-consumer scenario
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21677740
score: 1
tagged with: java
tagged with: concurrency
type: Question
tagged with: race-condition
tagged with: blockingqueue
has comment: http://stackoverflow.com/comment/32768488
tagged with: producer-consumer
has body: I'm trying to model a situation in Java in which many producers (at least 2) access the same LinkedBlockingQueue at a fixed rate. They produce, put, and then start over again. I was wondering whether this could eventually lead to race conditions between those producers which try to gain write access on the queue at the same time. Are java.util.concurrent.BlockingQueue's implementations already set up to handle such an issue, or should I manually create mutexes in order to avoid this kind of problems? Thank you for your attention.
upvote count: 1
has comment: http://stackoverflow.com/comment/32768479
answer count: 1
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/21677740

http://stackoverflow.com/comment/32750171
type: Comment
comment on: http://stackoverflow.com/q/21666635
has text: What kind of "check" do you want? Are you wanting the class or are you comfortable with a String?
score: 0
type: QuestionComment

http://stackoverflow.com/a/21701906
answers question: http://stackoverflow.com/q/21622595
type: Answer
accepted answer of: http://stackoverflow.com/q/21622595
has body: Found a workaround that fits my needs, maybe it helps someone else: set end time of the trigger 1 second before the desired fire time I want to skip - trigger.setEndTime(endTime) and apply the changes - scheduler.rescheduleJob(trigger.getKey(), trigger) (watch out for trigger's startTime to not get some funky results). Then add another trigger with startTime 1 second after the desired fire time I want to skip, otherwise exactly the same as previous trigger. Use groups to determine they are both doing the same thing.
score: 0
type: AcceptedAnswer

http://stackoverflow.com/q/21622254
answer count: 1
downvote count: 0
tagged with: tomcat
favorite count: 0
has body: I am currently trying to optimise my Tomcat on a 64bit sever with 4 GB of memory. Here are my current settings and its ticking over nicely: -Xms256m -Xmx1024m -XX:MaxPermSize=256m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled What I don't quite understand is how they relate to the New Relic charts - is the Eden space heap usage optimal - what should I be aiming on seeing in the reports?
has title: New Relic JVM graphs on Tomcat
tagged with: garbage-collection
has answer: http://stackoverflow.com/a/21639539
accepted answer: http://stackoverflow.com/a/21639539
tagged with: newrelic
score: 2
type: AnsweredQuestion
tagged with: java
type: Question
upvote count: 2

http://stackoverflow.com/comment/32709613
comment on: http://stackoverflow.com/q/21642731
score: 0
type: Comment
type: QuestionComment
has text: I believe you are close in terms of functionality however since Java does not allow to pass functions (does not treat functions as first class citizens), you need to (pre)wrap all functions in your `ToFunctionInterface` which seriously limits composability of functions and the binding of functions together via the `pipeline` is not super elegant. But as you said, this is Java.

http://stackoverflow.com/comment/32618017
has text: This looks suspiciously like homework. What have you tried and what specifically isn't working? Please give examples of what you've tried
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21587873

http://stackoverflow.com/q/21642397
downvote count: 1
favorite count: 0
type: UnansweredQuestion
has body: Error 500: java.lang.NoSuchMethodError: org/apache/commons/fileupload/FileUploadBase.isMultipartContent(Lorg/apache/commons/fileupload/RequestContext;) This is the error that I found in Websphere but I don't get any error in Apache tomcat. If anybody having solution. please reply me fast. I am using following jar: 1.) commons-fileupload-1.3.jar 2.) commons-io-2.4.jar
tagged with: java
has answer: http://stackoverflow.com/a/21642523
has comment: http://stackoverflow.com/comment/32707747
type: Question
has comment: http://stackoverflow.com/comment/32707756
has title: Error 500: java.lang.NoSuchMethodError: org/apache/commons/fileupload/FileUploadBase.isMultipartContent(
has answer: http://stackoverflow.com/a/63808101
score: 0
answer count: 2
tagged with: websphere
has comment: http://stackoverflow.com/comment/32708736
upvote count: 1

http://stackoverflow.com/comment/32639136
comment on: http://stackoverflow.com/a/21580022
type: Comment
has text: Yes you can. You might want that to be created elsewhere if you need [custom serializers](https://sites.google.com/site/gson/gson-user-guide#TOC-Custom-Serialization-and-Deserialization), but you shouldn't here because you're dealing with `JsonObject`, so inline is fine.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/32770282
type: Comment
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/21673975
has text: Looks like SWT.BORDER helped you. If I change from `Text firstText = new Text(shell, SWT.BORDER);` to `Text firstText = new Text(shell, SWT.NONE);` I will get my version

http://stackoverflow.com/q/21596871
upvote count: 4
answer count: 4
has comment: http://stackoverflow.com/comment/32628586
downvote count: 0
type: UnansweredQuestion
tagged with: set
has answer: http://stackoverflow.com/a/21597703
has answer: http://stackoverflow.com/a/32144355
has answer: http://stackoverflow.com/a/21599591
has title: Alternative to using TreeSet in java?
tagged with: java
has comment: http://stackoverflow.com/comment/32627974
type: Question
tagged with: comparator
has answer: http://stackoverflow.com/a/21597296
has body: I'm looking for a Set class that will use a given comparator to removeAll(). I was using TreeSet but after a few hours ripping my hair out trying to figured out why my removeAll() was not removing any I found this... http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4730113 Long story short removeAll() uses the equals() method. (But oddly enough the remove() method doesn't...) I do want a Set where so duplicates are removed, preferably with the comparator but not required, and I can't override the equals method b/c I need it as is for other logic. And obviously I would like to avoid making a loop that calls remove() on all elements so that it doesn't confuse me in the future (or someone else). does such an animal animal exist?
has comment: http://stackoverflow.com/comment/32628413
score: 4
favorite count: 0
tagged with: removeall

http://stackoverflow.com/q/21519037
duplicate of: http://stackoverflow.com/q/320588
linked to: http://stackoverflow.com/q/1372991
has answer: http://stackoverflow.com/a/21519089
type: Question
answer count: 2
downvote count: 4
upvote count: 0
has comment: http://stackoverflow.com/comment/32490678
has comment: http://stackoverflow.com/comment/32490249
has comment: http://stackoverflow.com/comment/32490409
tagged with: android
has answer: http://stackoverflow.com/a/21519231
has body: I use Interface for declaring Constants as they are public static final. Lot of times I've seen people write a class with public static final constant variables and sometimes I've done the same. Which one is the better practice to implement, the Interface or using a class? public class MyCodeConstants { public static final String VALUE_1 = "VALUE1"; public static final String VALUE_2= "VALUE2"; } or public interface MyCodeConstants { public static final String VALUE_1 = "VALUE1"; public static final String VALUE_2= "VALUE2"; } WHICH ONE IS A BETTER PRACTICE TO USE AND WHY??
favorite count: 0
has title: Use Interface for declaring Constants or a Class
score: -4
has comment: http://stackoverflow.com/comment/32490298
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/320588
has comment: http://stackoverflow.com/comment/32490275
accepted answer: http://stackoverflow.com/a/21519231
tagged with: java
possible better answer: http://stackoverflow.com/a/21519089

http://stackoverflow.com/comment/32701703
comment on: http://stackoverflow.com/q/21638808
score: 1
type: QuestionComment
type: Comment
has text: Use lowercase starting chars for method names, and when you get an infinite loop, print some debug info.

http://stackoverflow.com/comment/32593561
has text: where to put that on netbeans?
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21577658

http://stackoverflow.com/comment/32518083
comment on: http://stackoverflow.com/a/21534189
score: 0
type: AnswerComment
has text: Thanks mate. Will try to implement it first thing tomorrow.
type: Comment

http://stackoverflow.com/comment/32510906
type: Comment
comment on: http://stackoverflow.com/a/21522151
type: AnswerComment
has text: Actually, this code was wrong from the beginning. The `if` condition should be `power >= M` (i.e. the negation of remainder<divisor) otherwise you could end up with `power == M`.
score: 0

http://stackoverflow.com/a/21544425
has body: The problem is here: for(int i = 0; i &lt; number; i++){ return i; } This loop will only run one time, and it will immediately return i = 0. You don't want that. Make it append a * to your asterisks1 variable each iteration, then after the loop is finished, return asterisks1 to the caller and print it. Also, just FYI, this method is not recursive. A recursive method by definition calls itself at some point.
answers question: http://stackoverflow.com/q/21544374
score: 0
type: Answer

http://stackoverflow.com/q/21586025
has comment: http://stackoverflow.com/comment/32611777
has comment: http://stackoverflow.com/comment/32610776
linked to: http://stackoverflow.com/q/16074116
has body: I'm developing a desktop application which consists of overlapping jpanels. Those jpanels are transparent and include some jbuttons. What I want my application to do is to redispatch mouse events to below jpanels if user clicks buttonless areas. However, I could not get which jpanels below those jpanels. java.awt.container class has getComponentAt(int x, int y) method but it gives only component at top. javax.swing.SwingUtilities class has getDeepestComponentAt(Component parent, int x, int y) method but it gives only the deepest. Those methods do not meet my needs. Is it possible to implement methods like JComponent getComponentAt(int x, int y, int z-order) or JComponent[] getComponentsAt(int x, int y). Only possible solution I found is using getComponents() to get all components and checking their locations with their z-orders. However, I will have too many components in the application and this way is cpu consuming. Is it possible to access jpanels in a better way? Note: Could not add image to support the question, since my reputation is not high enough sorry for that.
score: 0
linked to: http://stackoverflow.com/q/21449502
has comment: http://stackoverflow.com/comment/32610393
type: UnansweredQuestion
tagged with: swing
answer count: 0
has title: java redispatch events between overlapping jpanels
tagged with: java
has comment: http://stackoverflow.com/comment/32611128
type: Question

http://stackoverflow.com/comment/32653702
comment on: http://stackoverflow.com/q/21611290
score: 0
has text: Can you post the directory structure of your webapp after the unzip?
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21532516
upvote count: 2
has comment: http://stackoverflow.com/comment/32515596
downvote count: 0
has body: I think you are trying to achieve what Google did with GAE. It's not a simple subject to be addressed here so I suppose this paper could be of help.
type: Answer
answers question: http://stackoverflow.com/q/21532166
score: 2

http://stackoverflow.com/q/21663966
answer count: 1
tagged with: user-interface
has body: I am trying to create an add button in a GUI interface which I have achieved, but I need this "add button" to prompt the user to enter data into the supplied fields and the application place all of the existing inventory as well as the new book created into a new array. The error I am currently getting is when trying to run it after it compiles. "Exception in thread "main" java.lang.NullPointerException at Bookstore.calculateInventoryTotal(Bookstore.java:198) at Bookstore.main(Bookstore.java:232)" Please know that because of this exception the GUI doesn't launch at all. I have pasted all of the code below, and thank you for your time taking a look at this! import java.util.Arrays; import java.text.NumberFormat; import java.util.Locale; import java.text.DecimalFormat; import javax.swing.*; import java.awt.*; import java.awt.event.*; // Begin class Book class Book { private String isbn; private String title; private String authorName; private int yearPublished; private String publisherName; private double price; NumberFormat usCurrency = NumberFormat.getCurrencyInstance(Locale.US); public Book (String isbn, String title, String authorName, int yearPublished, String publisherName, double price) { this.isbn = isbn; this.title = title; this.authorName = authorName; this.yearPublished = yearPublished; this.publisherName = publisherName; this.price = price; } /////////////////////////////////////////////// public void setISBN (String ISBN) //set ISBN { this.isbn = ISBN; } public String getISBN () //get ISBN { return isbn; } ////////////////////////////////////////////// public void setTitle (String Title) //set Title { this.title = Title; } public String getTitle () //get Title { return title; } /////////////////////////////////////////////// public void setAuthorName (String AuthorName) //set AuthorName { this.authorName = AuthorName; } public String getAuthorName () //get AuthorName { return authorName; } /////////////////////////////////////////////// public void setYea…
has answer: http://stackoverflow.com/a/21664077
has comment: http://stackoverflow.com/comment/32745418
has title: Java Add Button GUI Grow Array
tagged with: addition
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32745282
has comment: http://stackoverflow.com/comment/32745374
tagged with: java
accepted answer: http://stackoverflow.com/a/21664077
type: Question
tagged with: arrays
score: 0

http://stackoverflow.com/comment/32734064
type: AnswerComment
type: Comment
has text: Finally, if anyone felt bad that i copied by subsequent question in everyone's response, i again ask for forgiveness. I didn't mean to hurt anyone. Thanks for telling me this thing.
comment on: http://stackoverflow.com/a/21657557
score: 0

http://stackoverflow.com/comment/32691758
comment on: http://stackoverflow.com/a/21633452
type: AnswerComment
type: Comment
has text: That's arbitrary; it's not going to be used by people outside your organisation
score: 0

http://stackoverflow.com/q/21641398
favorite count: 0
has answer: http://stackoverflow.com/a/76131053
type: UnansweredQuestion
tagged with: jdbc
duplicate of: http://stackoverflow.com/q/17408769
answer count: 4
has comment: http://stackoverflow.com/comment/32706451
linked to: http://stackoverflow.com/q/1525444
linked to: http://stackoverflow.com/q/18089952
downvote count: 0
score: 1
has title: ClassNotFoundException: org.sqlite.JDBC
tagged with: java
has answer: http://stackoverflow.com/a/21642148
has answer: http://stackoverflow.com/a/78230217
type: Question
linked to: http://stackoverflow.com/q/17408769
has answer: http://stackoverflow.com/a/66598116
has body: I'm trying to set up a simple database for an Android app using sqlite but got the following error: java.lang.ClassNotFoundException: org.sqlite.JDBC at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:171) at testDB.main(testDB.java:16) Here is my code: public class testDB { public static void main(String args[]) { Connection c = null; try { Class.forName("org.sqlite.JDBC"); c = DriverManager.getConnection("jdbc:sqlite:/Users/Dropbox/csProject/test.db", "", ""); } } I have added sqlite-jdbc4-3.8.2-SNAPSHOT.jar in the library and I also tried to create a path in my home directory but am still getting the same error..
has comment: http://stackoverflow.com/comment/73539189
upvote count: 1
tagged with: sqlite

http://stackoverflow.com/q/21614897
has comment: http://stackoverflow.com/comment/32660126
type: Question
has body: Aftermath of this: Image for ImageButton doesn&#39;t change as intended When ImageButton of "ibChamp" is clicked, it opens up champions.xml. In that layout, there is an Imagebutton called "ibAnnie". What I want that to do when clicked is, to change the image of "ibChamp", and to switch to that layout. What happened here is that after "ibAnnie" is clicked, it switches to "create_build_page.xml", and in that is a changed picture of "ibChamp". But that only happens for a split second before changing back to the original, unchanged picture, "create_build_page.xml" layout. When I click the back button, it goes to the "create_build_page.xml" layout with the changed picture, but the buttons do not work. I would gladly provide any additional information required.
has comment: http://stackoverflow.com/comment/32659829
score: 0
has answer: http://stackoverflow.com/a/21617518
has comment: http://stackoverflow.com/comment/32664251
linked to: http://stackoverflow.com/q/21592015
answer count: 1
tagged with: imagebutton
has comment: http://stackoverflow.com/comment/32664178
tagged with: http://stackoverflow.com/tag/xml
has title: ImageButton changing an Image of another ImageButton causes unintended cycle
tagged with: android
accepted answer: http://stackoverflow.com/a/21617518
has comment: http://stackoverflow.com/comment/32664374
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32660277
has comment: http://stackoverflow.com/comment/32664114
has comment: http://stackoverflow.com/comment/32660151
tagged with: java
has comment: http://stackoverflow.com/comment/32660529

http://stackoverflow.com/a/21627952
score: 0
answers question: http://stackoverflow.com/q/21627815
type: Answer
has body: For your first question: it's not a problem that you're creating a new Intent every time The second one is a bit trickier. When you press the home button the current activity stays in memory, so it can start the new one even though you think it's not running. The easiest way to handle this to check weather the activity is finishing, and if so, you don't show the next one. if (!isFinishing()) startActivity(intent); This if statement prevents your activity to start a new one when it's in the background.

http://stackoverflow.com/comment/32538687
type: QuestionComment
comment on: http://stackoverflow.com/q/21546909
has text: Whats the problem you get exactly.
score: 1
type: Comment

http://stackoverflow.com/comment/32621948
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21592790
has text: You get no exception traceback???
score: 0

http://stackoverflow.com/comment/32754565
type: Comment
comment on: http://stackoverflow.com/q/21669087
has text: Java, you mean javascript ?, please rewrite your question
score: 1
type: QuestionComment

http://stackoverflow.com/comment/32517460
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/21534467
has text: Avoid scriptlets at _all_ costs.
type: Comment

http://stackoverflow.com/comment/32575787
comment on: http://stackoverflow.com/q/21566612
type: Comment
type: QuestionComment
has text: In other words you need something like AOP logging mechanism across your database access methods.
score: 0

opencv
type: Tag
tags question: http://stackoverflow.com/q/21528925
tags question: http://stackoverflow.com/q/21664730
tags question: http://stackoverflow.com/q/21623911
tag name: opencv
tags question: http://stackoverflow.com/q/21561542
tags question: http://stackoverflow.com/q/21615880
tags question: http://stackoverflow.com/q/21663423
tags question: http://stackoverflow.com/q/21533310
tags question: http://stackoverflow.com/q/21670225
tags question: http://stackoverflow.com/q/21541324
tags question: http://stackoverflow.com/q/21524524
tags question: http://stackoverflow.com/q/21618044
tags question: http://stackoverflow.com/q/21571761
tags question: http://stackoverflow.com/q/21554088

http://stackoverflow.com/a/21614413
score: 24
has comment: http://stackoverflow.com/comment/32658696
has comment: http://stackoverflow.com/comment/32660387
type: AcceptedAnswer
has body: Ok, I've written a micro-benchmark (as suggested by @Joni &amp; @MattBall) and here are the results for 1 x 1000000000 accesses for each a local and an instance variable: Average time for instance variable access: 5.08E-4 Average time for local variable access: 4.96E-4 For 10 x 1000000000 accesses each: Average time for instance variable access:4.723E-4 Average time for local variable access:4.631E-4 For 100 x 1000000000 accesses each: Average time for instance variable access: 5.050300000000002E-4 Average time for local variable access: 5.002400000000001E-4 So it seems that local variable accesses are indeed faster that instance var accesses (even if both point to the same object). Note: I didn't want to find this out, because of something I wanted to optimize, it was just pure interest. P.S. Here is the code for the micro-benchmark: public class AccessBenchmark { private final long N = 1000000000; private static final int M = 1; private LocalClass instanceVar; private class LocalClass { public void someFunc() {} } public double testInstanceVar() { // System.out.println("Running instance variable benchmark:"); instanceVar = new LocalClass(); long start = System.currentTimeMillis(); for (int i = 0; i &lt; N; i++) { instanceVar.someFunc(); } long elapsed = System.currentTimeMillis() - start; double avg = (elapsed * 1000.0) / N; // System.out.println("elapsed time = " + elapsed + "ms"); // System.out.println(avg + " microseconds per execution"); return avg; } public double testLocalVar() { // System.out.println("Running local variable benchmark:"); instanceVar = new LocalClass(); LocalClass localVar = instanceVar; long start = System.currentTimeMillis(); for (int i = 0 ; i &lt; N; i++) { localVar.someFunc(); } long elapsed = System.currentTimeMillis() - start; double avg = (elapsed * 1000.0) / N; // System.out.println("elapsed time = " + elapsed + "ms"); // System.out.println(avg + " microseconds per execution"); return avg; } public static void main(String[] args) { …
type: Answer
upvote count: 24
has comment: http://stackoverflow.com/comment/32660248
accepted answer of: http://stackoverflow.com/q/21613098
has comment: http://stackoverflow.com/comment/52895946
answers question: http://stackoverflow.com/q/21613098
downvote count: 0

http://stackoverflow.com/q/21629132
linked to: http://stackoverflow.com/q/1037009
tagged with: userprincipal
upvote count: 16
has body: I am trying to authenticate with a kerberos/HTTP host. Using Apache HttpClient as my client - and a slightly modified version of this source. My Kerberos authentication goes perfectly fine, and I wish to know how to set the login credentials programatically. At the moment, the credentials are entered manually through the console, but I want to have it chosen by me at run time. [ As I wish to automate and load test the server with a large number of users, actually. ]. EDIT : Here is a code snippet of the relevant parts : .. NegotiateSchemeFactory nsf = new NegotiateSchemeFactory(); httpclient.getAuthSchemes().register(AuthPolicy.SPNEGO, nsf); Credentials use_jaas_creds = new Credentials() { public String getPassword() { return null; } public Principal getUserPrincipal() { return null; } }; httpclient.getCredentialsProvider().setCredentials( new AuthScope(null, -1, null), use_jaas_creds); HttpUriRequest request = new HttpGet("http://kerberoshost/"); HttpResponse response = httpclient.execute(request); .. The interface Credentials has two methods - getPassword() and getUserPrincipal(), but from some debugging I did, they don't seem to be invoked at all. What am I missing here ? What is a cleaner way to statically set the credentials ? A very similar question had been asked before, but keytabs/login.conf hack is too cumbersome and not a practical option for an automated load test with a large number of user credentials. Appreciate any help on this.
has comment: http://stackoverflow.com/comment/32710303
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/23679954
tagged with: java
score: 16
tagged with: authentication
type: Question
tagged with: kerberos
has title: HttpClient set credentials for Kerberos authentication
has comment: http://stackoverflow.com/comment/32719780
tagged with: httpclient
linked to: http://stackoverflow.com/q/10923283
has comment: http://stackoverflow.com/comment/32719723
has comment: http://stackoverflow.com/comment/32704556
has answer: http://stackoverflow.com/a/23679954
answer count: 1
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/32788316

http://stackoverflow.com/comment/32508603
type: AnswerComment
type: Comment
has text: Sounds plausible. Just one thing that I didn't make myself clear in my original description: (excuse me if I will always tend to talk about things that are sort of unclear. Or maybe I didn't understand your comment properly) the scroll I'm doing is actually vertical. So, how do I do it? This is the first time I'm operating a BufferedImage with a LinearGradientPaint, and so I'm not sure on what code I must type to try this out. [you don't have to be exact, but it should be something I can learn from. I'm simply too occupied with other things.]
comment on: http://stackoverflow.com/a/21519409
score: 0

http://stackoverflow.com/comment/32565816
comment on: http://stackoverflow.com/q/21559779
has text: I stumbled across the Weiler-Atherton algorithm, can this possibly be what I'm looking for? I can't find really find much in the way of a practical example though
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21670649
answers question: http://stackoverflow.com/q/21670525
score: 0
type: Answer
has body: Basically the super class is the upper most level of the program. When you create a new subclass you must "inherit" from the super class using the keyword 'extends'. This does 2 things; It allows you to use any methods created in the super class, in the subclass and it also allows you overwrite methods in the super class. Basically, if you have one method you want to use in a bunch of classes you use the super class to create it and then the sub-classes can just call the method using standard dot notation.

http://stackoverflow.com/comment/32813500
comment on: http://stackoverflow.com/a/21678096
has text: That sounds worthy of a new [question](http://stackoverflow.com/questions/ask). Each question should be specific and (hopefully) have an accepted answer. For better help sooner on your next question, post a [MCTaRE](http://stackoverflow.com/help/mcve) (Minimal Complete Tested and Readable Example) like I did. (All one source file, with imports, with a `main(String[])` to run it.)
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32537259
has text: It my first application, I not so long ago start learn android. how make it? please, give me link on example.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21545884
type: Comment

http://stackoverflow.com/q/21554088
has title: Using eclipse in order to find the opencv native library doesn't work
has comment: http://stackoverflow.com/comment/33136296
has answer: http://stackoverflow.com/a/21678850
has answer: http://stackoverflow.com/a/21605359
favorite count: 0
answer count: 3
has comment: http://stackoverflow.com/comment/33120768
has comment: http://stackoverflow.com/comment/32716564
downvote count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21748568
tagged with: opencv
score: 2
has body: I'm attempting to use opencv on an ubuntu installation and am following this tutorial. Everything seemed fine and it even listed amongst the installed parts so I proceeded into this tutorial. This went well up until the moment where you have to add opencv as a user library as it was not amongst the (completely empty) list of libraries found. I have looked throughout the opencv folder and can't find anything like a library either am I missing something? Any idea on how to fix this? Note that it did manage to produce .jar file however the library is still missing. If it matters opencv is installed in usr/local/src. If in order fix this you require any extra information feel free to ask in the comments. This might have something to do with the problem: ulap:/usr/local/src/opencv-2.4.8/opencv/build/bin$ ant -DocvJarDir=path/to/dir/containing/opencv-248.jar -DocvLibDir=/usr/local/src/opencv-2.4.8/opencv/build/bin /opencv_java248/native/library Buildfile: /usr/local/src/opencv-2.4.8/opencv/build/bin/build.xml BUILD FAILED Target "/opencv_java248/native/library" does not exist in the project "SimpleSample". Total time: 0 seconds thijs@thijs-ulap:/usr/local/src/opencv-2.4.8/opencv/build/bin$ ant -DocvJarDir=path/to/dir/containing/opencv-248.jar -DocvLibDir=/usr/local/src/opencv-2.4.8/opencv/build/bin /opencv_java248/native/library Buildfile: /usr/local/src/opencv-2.4.8/opencv/build/bin/build.xml BUILD FAILED Target "/opencv_java248/native/library" does not exist in the project "SimpleSample". Total time: 0 seconds This is my build.xml: <property name="src.dir" value="src"/> <property name="lib.dir" value="${ocvJarDir}"/> <fileset dir="${lib.dir}" includes="**/*.jar"/> <property name="build.dir" value="build"/> <property name="classes.dir" value="${build.dir}/classes"/> <property name="jar.dir" value="${build.dir}/jar"/> <property name="main-class" value="${ant.project.name}"/> <delete dir="${build.dir}"/> <mkdir dir="${classes.dir}"/> <javac includeantruntime="false" srcdir…
has comment: http://stackoverflow.com/comment/32759730
tagged with: ant
tagged with: java
tagged with: eclipse
type: Question
upvote count: 2

http://stackoverflow.com/q/21538697
tagged with: loops
upvote count: 1
tagged with: methods
answer count: 1
accepted answer: http://stackoverflow.com/a/21538799
type: AnsweredQuestion
tagged with: jar
downvote count: 0
score: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/32525433
has answer: http://stackoverflow.com/a/21538799
type: Question
has title: Access methods which are being called from another jar
tagged with: java
has body: So I have a jar file which has a runnable, and it's calling a method named loop() every second. I want to be able to access this loop() method from ANOTHER java file. I was wondering if this is possible? Can I access this loop method without the use of abstract?

http://stackoverflow.com/q/21574744
answer count: 1
tagged with: apache-commons
has body: I've created an eclipse plugin project with support for a DSL. The problem that i'm facing is i'm using some external libraries like apache commons, antlr,jface.text etc. It is running fine when i run from inside eclipse. But once i make an update site project, and install from it, none of the dependencies are copied or taken care of.It installs properly, but once i open a view which uses any of these libraries, it fails to work.
tagged with: java
tagged with: update-site
type: UnansweredQuestion
has title: Why my external jars are not included when creating an eclipse update site
tagged with: eclipse-rcp
type: Question
has answer: http://stackoverflow.com/a/21577648
score: 0
tagged with: swt

http://stackoverflow.com/a/21598484
has comment: http://stackoverflow.com/comment/32746871
type: AcceptedAnswer
downvote count: 0
score: 6
has comment: http://stackoverflow.com/comment/32630721
has comment: http://stackoverflow.com/comment/32644277
type: Answer
accepted answer of: http://stackoverflow.com/q/21598382
upvote count: 6
answers question: http://stackoverflow.com/q/21598382
has body: AFAIK Garbage Collector usually runs when your app runs out of memory. Little disagree on that. No. It runs asynchronously and collects the referenced memory locations. I wonder if there is such method in java like free() as such in C language, that we could invoke when we explicitly want to free the part of memory allocated by a new operator. Again System.gc() is your call then, but not 100% sure of memory clear immediately. Also does new performs the same operation as do malloc() or calloc()? If you mean allocation memory, then yes for that Object Are there any alternates for delete(), free(), malloc(), calloc() and sizeof() methods in java. AFAIK there is no direct functions to do so. On top of my head, you need not to worry about such things and Modern JVM's are smart enoguh to handle these things. An interesting thread here found on SO, to when GC decides to run. Hope that helps.
has comment: http://stackoverflow.com/comment/32644303
has comment: http://stackoverflow.com/comment/32630667
has comment: http://stackoverflow.com/comment/32642421

http://stackoverflow.com/comment/32576073
type: QuestionComment
comment on: http://stackoverflow.com/q/21567326
type: Comment
has text: Under what circumstances do these errors arise?
score: 0

http://stackoverflow.com/q/21667425
type: AnsweredQuestion
score: 3
tagged with: java
tagged with: datastax-java-driver
has body: What would be the right way to build a insert statement with QueryBuilder from Datastax Java Driver for Cassandra I am using Cassandra 2.x with Java Driver 2.0.0-rc1 I know i could use a prepared statement to achieve the same but i am looking forward to using the QueryBuilder @Test public void testTableInsert() { Insert insert = QueryBuilder .insertInto(KEYSPACE_NAME, TABLE_NAME) .value("username", "jdoe") .value("first", "John") .value("last", "Doe"); System.out.println(insert.toString()); ResultSet result = session.execute(insert.toString()); System.out.println(result); } I can confirm the query string is valid because it succeeds when attempting manually on cqlsh INSERT INTO test.user(username,first,last) VALUES ('jdoe','John','Doe'); The error reported by the driver is com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured columnfamily user at com.datastax.driver.core.exceptions.InvalidQueryException.copy(InvalidQueryException.java:35) at com.datastax.driver.core.ResultSetFuture.extractCauseFromExecutionException(ResultSetFuture.java:271) at com.datastax.driver.core.ResultSetFuture.getUninterruptibly(ResultSetFuture.java:187) at com.datastax.driver.core.Session.execute(Session.java:126) at com.datastax.driver.core.Session.execute(Session.java:77) at SimpleClientTest.testTableInsert(SimpleClientTest.java:61) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores…
has answer: http://stackoverflow.com/a/24731860
possible better answer: http://stackoverflow.com/a/21685222
answer count: 3
has answer: http://stackoverflow.com/a/21714396
accepted answer: http://stackoverflow.com/a/21714396
has comment: http://stackoverflow.com/comment/32835011
downvote count: 0
has comment: http://stackoverflow.com/comment/32833342
favorite count: 0
tagged with: cassandra
has comment: http://stackoverflow.com/comment/32782454
has comment: http://stackoverflow.com/comment/32772467
has title: Datastax QueryBuilder insert statement
has comment: http://stackoverflow.com/comment/32793133
has answer: http://stackoverflow.com/a/21685222
upvote count: 3
has comment: http://stackoverflow.com/comment/32872712
type: Question

http://stackoverflow.com/a/49980166
answers question: http://stackoverflow.com/q/21574236
type: Answer
score: 7
upvote count: 7
downvote count: 0
has body: This means that the object which you are trying to access is not loaded, so write a query that makes a join fetch of the object which you are trying to access. Eg: If you are trying to get ObjectB from ObjectA where ObjectB is a foreign key in ObjectA. Query : SELECT objA FROM ObjectA obj JOIN FETCH obj.objectB objB

http://stackoverflow.com/comment/32513068
type: AnswerComment
score: 0
type: Comment
has text: ah ok. sry about that then :).
comment on: http://stackoverflow.com/a/21531897

http://stackoverflow.com/q/21517564
has comment: http://stackoverflow.com/comment/32487935
tagged with: http://stackoverflow.com/tag/xml
has comment: http://stackoverflow.com/comment/32487988
type: UnansweredQuestion
has body: Is there any suggestions or any help in wich way schould i go that you can advise me, to make the segmenting of the simple text in text file during converting it to xml file, such like as was before in xml. I mean, i'm converting text file into xml with jaxp+sax, like this text: Hello world. I am happy to see you today. into this xml: Hello world I am happy to see you today but if i for example have source xml content that in id="1" has 3 sentences for example: Hello world. Sunny smile. Wake up early. I am happy to see you today and wenn i parse text from this xml i become simple text: Hello world. Sunny smile. Wake up early.I am happy to see you today. How can i segment this text, during converting it into xml, in order that target xml file can have also 3 sentences again? like: Hello world. Sunny smile. Wake up early. I am happy to see you today that is conversion txt->xml: public void doit() { try { in = new BufferedReader(new InputStreamReader( new FileInputStream(file), "UTF8")); out = new StreamResult(selectedDir); initXML(); String str; while ((str = in.readLine()) != null) { elements = str.split("\n|((?<!\\d)\\.(?!\\d))"); for (i = 0; i < elements.length; i++) process(str); } in.close(); closeXML(); } catch (Exception e) { e.printStackTrace(); } } public void initXML() throws ParserConfigurationException,SAXException, UnsupportedEncodingException, FileNotFoundException, TransformerException { // JAXP + SAX SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); th = tf.newTransformerHandler(); Transformer serializer = th.getTransformer(); serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // XML ausgabe serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); serializer.setOutputProperty(OutputKeys.INDENT, "yes"); th.setResult(out); th.startDocument(); atts = new AttributesImpl(); atts1 = new AttributesImpl(); atts1.addAttribute("", "", "xlmns","CDATA", "urn:oasis:names:tc:xliff:document:1.2"); …
tagged with: xliff
has comment: http://stackoverflow.com/comment/32487887
has title: Segmenting text in Xliff file
tagged with: java
has answer: http://stackoverflow.com/a/21632412
has comment: http://stackoverflow.com/comment/32487813
has comment: http://stackoverflow.com/comment/32487670
type: Question
answer count: 1
score: 0
has comment: http://stackoverflow.com/comment/32487769

http://stackoverflow.com/comment/32700760
type: QuestionComment
has text: could you explain what you mean by squares? perhaps include some manually typed in input of what you would like it to look like?
score: 0
comment on: http://stackoverflow.com/q/21637986
type: Comment

http://stackoverflow.com/q/21590767
upvote count: 1
type: Question
has body: So I'm making a phonegap/cordova application (v 3.1.0) and need to open the InAppBrowser which doesn't cover the full layout, so I can make custom toolbars and such show beneath the browser. I've managed to make the InAppBrowser appear smaller than the screen by fiddling with the layout options and can succesfully show the toolbars but I'm not able to click on them. Now I need some help on how to manage to get those clicks propagate to the main phonegap view from the inappbrowser. As for the code - you edit the InAppBrowser.java at the following lines to your desired height: inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(WIDTH, HEIGHT)); And lp.height = HEIGHT; lp.width = WIDTH; Any ideas on how to pass the click, for example on the blue Close div? Here's a screenshot to show more detail: EDIT: Managed to get some click events by setting an onclick/touch listener on the inAppBrowser WebView, doing the samo on the main view attached on to the dialog created registers no touch events at all. Also you can find the source code of the inAppBrowser plugin on github on here.
tagged with: phonegap-plugins
downvote count: 0
has title: Clicking outside of Phonegap/Cordova InAppBrowser
favorite count: 0
tagged with: cordova
type: UnansweredQuestion
tagged with: android
answer count: 0
score: 1
tagged with: java

http://stackoverflow.com/q/21612400
has comment: http://stackoverflow.com/comment/32772279
has comment: http://stackoverflow.com/comment/32773811
tagged with: pdfbox
tagged with: http://stackoverflow.com/tag/pdf
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/32661082
has title: Generating PDF from template dynamically
upvote count: 2
type: UnansweredQuestion
score: 2
answer count: 0
tagged with: java
has body: I have a pdf template with placeholder for a list of people. I can use acro fields to populate their names but the problem is, the list have to be of variable length. This means that there may be from 1 to 16 people on the list and there should not be any gaps in resulting pdf (so I can't leave blank space in the middle of the page if I have only 2 people). What's the easiest way of generating such pdfs? PdfBox solution is preferred but not a must.
type: Question

http://stackoverflow.com/a/21632844
type: Answer
score: 7
has comment: http://stackoverflow.com/comment/32691171
upvote count: 7
has body: Your String is a JSON object containing a JSON array, try this : JSONObject myJSON = new JSONObject(result); JSONArray jArray = myJSON.getJSONArray("messages"); then iterate through your JSONArray ... int size = jArray.length(); for (int i=0 ; i&lt;size ; i++){ JSONObject itemInArray = jArray.get(i); // get values inside the object, for example : String text = itemInArray.getString("text"); }
answers question: http://stackoverflow.com/q/21632719
accepted answer of: http://stackoverflow.com/q/21632719
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/21515241
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32483722
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/21515195
accepted answer of: http://stackoverflow.com/q/21515195
has body: I'm surprised you get null and not a bunch of exceptions. (I'll assume you are swallowing the exceptions.) You need a no-argument constructor, or you need to annotate the parameters in your current constructor with @JsonProperty with the name of the JSON element to which they should map. It might look like public Business(@JsonProperty("id") int idBusiness, @JsonProperty("type") String type,@JsonProperty("pos") int pos) { this.setId(idBusiness); this.type = type; this.pos = pos; } Note that the JSON contains the property id, not idBusiness, so you need a @JsonProperty("id") over the field, getter, or setter (or rename the field and its getter/setter).

http://stackoverflow.com/q/21538202
upvote count: 1
type: AnsweredQuestion
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/21538287
has title: how to figure out captive portal URL in java
type: Question
answer count: 2
downvote count: 0
has body: I am trying to update an app that I wrote for Android that will automatically log a user into a captive portal at my university. The app worked fine last year with the portal URL hard coded in, however this year that won't work because they changed the server URL, I know what the URL is, so I simply changed it in my program ... which sort of works There are two main problems, for me, with this approach. hard coding is a pain in the ass to do every year, I also want to be able to make it future proof, so that hard coding the URL won't be necessary for some unexplainable reason there are actually buildings on campus that will direct to the OLD authentication server, it truly boggles my mind why it would do that I would like to be able to make an HTTP request and get the URL of the captive portal that is redirected to, how is that done?
tagged with: android
has answer: http://stackoverflow.com/a/21538287
possible better answer: http://stackoverflow.com/a/23775002
favorite count: 0
has answer: http://stackoverflow.com/a/23775002

http://stackoverflow.com/comment/32678645
type: Comment
type: QuestionComment
has text: Can you please edit your question to give more detail on what you're trying to do? Is this with a Cloud Service (e.g. worker role) via Eclipse? Are you asking if the JDK or Tomcat exist somewhere else, obviating the need for you to upload them? As it stands, your question is rather ambiguous.
score: 0
comment on: http://stackoverflow.com/q/21625826

http://stackoverflow.com/comment/32686553
type: Comment
type: AnswerComment
has text: Your idea of using a database view and then creating a JPA entity to match it does not sound too bad to me. Anything else is answered by the JEE tutorial and/or a good book on JPA.
score: 0
comment on: http://stackoverflow.com/a/21627919

http://stackoverflow.com/comment/32616914
type: QuestionComment
has text: See some of the Related answers at right, and/or see a tutorial on whatever you're trying to set up a listener on (which will almost certainly have examples). Anonymous classes are a convenient shorthand, nothing more. And yes, inner classes *are* used when appropriate; learning what is and isn't appropriate is something that comes with experience and reading examples.
score: 0
comment on: http://stackoverflow.com/q/21590153
type: Comment

http://stackoverflow.com/comment/32690952
comment on: http://stackoverflow.com/q/21633070
type: Comment
type: QuestionComment
has text: Sounds like a webserver issue. Is your firewall off? What port is your webserver running on?
score: 0

http://stackoverflow.com/a/21562696
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32567321
type: Answer
accepted answer of: http://stackoverflow.com/q/21562664
score: 1
answers question: http://stackoverflow.com/q/21562664
has body: Interfaces can be oriented to any type of class. Implicitly/Informally each class has some interface determined by the methods that class defines. It should be IAdministration in your sense. Because it defines operations on a administration which is a container for contact objects (backed by an array in your words). The "add", "delete", "swap" are not operations of a contact object, it seems, but on an administration object. ICustomer/IContact would be another interface which would have methods like e.g. setFirstName, setLastName, setPhone, getFirstName, getLastName, getPhone etc. It is just some POJO/bean carrying some data. So it seems to me from your description.
upvote count: 1

http://stackoverflow.com/comment/32608201
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21585394
has text: The result of System.out.println(a==c); will be true.String pool concept make same address for both the variable

http://stackoverflow.com/a/21588924
score: 2
accepted answer of: http://stackoverflow.com/q/21587543
answers question: http://stackoverflow.com/q/21587543
has body: The error message pretty much nails it. Your CasAuthenticationProvider is missing a reference to another bean which gives it access to the user information for your application: <constructor-arg ref="userService" /> where userService is a UserDetailsService instance. See the CAS Sample application for a working example.
has comment: http://stackoverflow.com/comment/32621476
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32789827
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/32614792

http://stackoverflow.com/q/21515392
has comment: http://stackoverflow.com/comment/32483916
favorite count: 0
upvote count: 0
has comment: http://stackoverflow.com/comment/36772101
tagged with: war
downvote count: 1
type: AnsweredQuestion
has body: So I have a regular Intellij java project, now I was asked to create a .war from this so it can be deployed on a tomcat server. However, when I google this, every link assumes I have a web application but I don't. If anyone could help me out with this, it'd be greatly appreciated.
tagged with: java
type: Question
tagged with: intellij-idea
accepted answer: http://stackoverflow.com/a/21515470
answer count: 1
score: -1
tagged with: tomcat
has comment: http://stackoverflow.com/comment/32519745
has title: Make .war file for Tomcat from a non-web intellij project
has answer: http://stackoverflow.com/a/21515470

http://stackoverflow.com/comment/32537573
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21545981
has text: Will `replaceFirst` do a "thorough search", or will it stop immediately due to the `'^'`?

http://stackoverflow.com/comment/32605553
comment on: http://stackoverflow.com/a/21583210
score: 1
has text: Sorry, I forgot what the stack is supposed to hold. Indeed, when remembering history of working directory changes, linked list is the best solution. If wanting to keep all the history – when only a fixed number of last working directories is needed, a circular buffer (array-based deque) is better.
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32564248
score: 1
comment on: http://stackoverflow.com/q/21560962
has text: There's nothing inherent in Ant that compiles anything. You would need to show what ant task your have used and what options to javac you have passed.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/32573557
comment on: http://stackoverflow.com/q/21565624
has text: have you tried refreshing your project? F5
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32616509
has text: That makes sense to me, however, after making the MyApplication class (extending Application) I CANNOT use the getter and setter methods of that class. I get the error: java.lang.RuntimeException: Unable to instantiate acitvity ComponentInfo{edu.umkc.baldwin/edu.umkc.baldwin.MainActivity}: java.lang.NullPointerException
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21570473
type: AnswerComment

http://stackoverflow.com/comment/32657644
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21613098
has text: @C.B. - Objects are never stored in an instance variable or a local variable, only references are stored there.

http://stackoverflow.com/q/21591005
has comment: http://stackoverflow.com/comment/32618275
tagged with: timer
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21591295
has title: Setting unique timers in for loop
has comment: http://stackoverflow.com/comment/32618691
has body: I am using a for loop and setting a timer at the beginning, and ending it at the end. The for loop repeats 3 times and gives me the 3 values that I need but I want to be able to compare the timer values it gives me in java and compute the results for biggest-smallest. To do that, I need each timer to have a unique name which I cannot seem to do. Here is an example of my code. int j; for(j=1;j&lt;=3;++j){ //...code { long startTime = System.nanoTime(); //timer start //...code long estimatedTime = System.nanoTime() - startTime; //timer end System.out.println(startTime + "_1"); } { timer comparison for the 3 timers } As I said, I already have the values, but I need a way to compare them. "estimatedTime" is the value I'm comparing, so ideally I like to assign names "estimatedTime2" and "estimatedTime3" on the second and third values.
tagged with: loops
type: Question
tagged with: java
score: 0
has comment: http://stackoverflow.com/comment/32618457
tagged with: for-loop
answer count: 1

http://stackoverflow.com/a/21572045
accepted answer of: http://stackoverflow.com/q/21553270
answers question: http://stackoverflow.com/q/21553270
has comment: http://stackoverflow.com/comment/32584254
upvote count: 1
type: AcceptedAnswer
type: Answer
has body: I think you can just use a StackPane which allows you to work with "layers". Indeed in the StackPane, each Node you add to it becomes a "layer" and appears above previously added Nodes. Meaning that the latest Node will always be on top. Knowing that, you can add your error message to the StackPane and then, if you use a transition to move it, at the end of the transition you automatically remove the message from the StackPane. Hope it helps.
downvote count: 0
score: 1

http://stackoverflow.com/a/21570792
has comment: http://stackoverflow.com/comment/32582292
has comment: http://stackoverflow.com/comment/32582249
has comment: http://stackoverflow.com/comment/32582042
score: 1
upvote count: 1
has body: The java version during compiling the code is different during running.Mean compiled with higher version than running version of JAVA.Make sure the version of running jvm is lower than compiled version.
has comment: http://stackoverflow.com/comment/32582232
answers question: http://stackoverflow.com/q/21570747
has comment: http://stackoverflow.com/comment/32582017
has comment: http://stackoverflow.com/comment/32582065
has comment: http://stackoverflow.com/comment/32582271
type: Answer
has comment: http://stackoverflow.com/comment/32582210
downvote count: 0

http://stackoverflow.com/comment/32586762
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21551072
score: 0
has text: I created a page almost empy. I just print out the heapsize, and it's always about 503316480, almost the same heapsize i get in other pages, even those with pics

http://stackoverflow.com/q/21524841
score: 0
answer count: 2
upvote count: 1
downvote count: 1
possible better answer: http://stackoverflow.com/a/21525912
has answer: http://stackoverflow.com/a/21525912
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has body: In my json example I have a problem and I can't resolve it. let's pretend I have class City class City { int id; int name; Address address } Sometimes from server comes address (i.e address_id,address_name ....) but when in particular cases there is no address the server returns false boolean value. I try to parse jsonObject City city = new ObjectMapper().readValue(response.toString(), City.class); address returning some data and it's okay. but when address returns false boolean value I got this error com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type from Boolean value. Is there any way to fix the problem? case 1. { "isLogin": false, "totalSum": 0, "addressCount": 0, "address": false, } case 2. { "isLogin": false, "totalSum": 378, "addressCount": 1, "address": { "id": "1127", "name": "New York", }
has comment: http://stackoverflow.com/comment/32500042
type: AnsweredQuestion
tagged with: jackson
favorite count: 0
type: Question
tagged with: android
has answer: http://stackoverflow.com/a/21525215
has title: jackson - json parsing not working well
accepted answer: http://stackoverflow.com/a/21525215

http://stackoverflow.com/q/21580841
linked to: http://stackoverflow.com/q/38922754
downvote count: 0
has comment: http://stackoverflow.com/comment/32599636
has answer: http://stackoverflow.com/a/21599696
has comment: http://stackoverflow.com/comment/32600248
favorite count: 0
answer count: 5
linked to: http://stackoverflow.com/q/9235845
has comment: http://stackoverflow.com/comment/32599583
has answer: http://stackoverflow.com/a/21581010
type: UnansweredQuestion
upvote count: 1
has comment: http://stackoverflow.com/comment/32599735
has title: Less than or equal to with GregorianCalendar
has body: i have this code in my program: if (expire.after(start) &amp;&amp; expire.before(end)) //do somethig But this code does not include the bound day. I mean for example if start is 2014/01/15, end is 2014/01/20 and expire is 2014/01/20, expire is not considered. How to solve? I tried in this way: if (expire.after(start) &amp;&amp; (expire.equals(end) || expire.before(end))) But it doesn't work, i get the same result.
has answer: http://stackoverflow.com/a/21581711
score: 1
tagged with: java
tagged with: gregorian-calendar
has answer: http://stackoverflow.com/a/21581060
has answer: http://stackoverflow.com/a/21581170
type: Question

http://stackoverflow.com/comment/32735080
comment on: http://stackoverflow.com/a/21658200
score: 0
type: AnswerComment
has text: @Whoppa What do you mean by - "Every class inherits from type object?*. Yes the class is generic, because of `<T>` following the class name .
type: Comment

http://stackoverflow.com/a/21641583
score: 6
type: Answer
upvote count: 6
answers question: http://stackoverflow.com/q/21641572
downvote count: 0
has body: It's depends on the platform/OS, in Linux it's \n, in Windows, it's \r\n Windows: '\r\n' Mac (OS 9-): '\r' Mac (OS 10+): '\n' Unix/Linux: '\n'

http://stackoverflow.com/q/21581198
has title: export to excel from web application is not working
linked to: http://stackoverflow.com/q/2943477
tagged with: jsp
has comment: http://stackoverflow.com/comment/32602388
type: UnansweredQuestion
answer count: 0
tagged with: java
has body: I am having a very wierd issue and I'm hoping you can help me out At work, we use a web application made with the framework GWT, and all the sales reports have an option to export the data to excel. It usually works fine, but the days that the report has more than about 15-20 thousand rows, the excel file only opens with the word "null" on the first cell. Within the code, we use a JSP to send the data as html and a StringBuffer object to append all the text of the html. Here es the method that sends the html: public void export(final String psFormat) { manageStartOfCall(); String lsFileName = "resources/system/excel_file.jsp"; final DynamicForm loForm = new DynamicForm(); loForm.setAction(lsFileName); loForm.setMethod(FormMethod.POST); loForm.setCanSubmit(true); final TextAreaItem loDataToExport = new TextAreaItem("psExcelData"); final Window loExcelWindow = new Window(); loExcelWindow.setWidth(5); loExcelWindow.setHeight(5); loExcelWindow.addItem(loForm); addChild(loExcelWindow); new Timer() { public void run() { cancel(); loDataToExport.setValue(moHeader.getHeaderAsExcel() + " " + moReportGrid.getDataAsHTML()); loForm.setFields(loDataToExport); new Timer() { public void run() { cancel(); manageEndOfCall(); loForm.submit(); loExcelWindow.destroy(); } }.schedule(200); } }.schedule(200); } I've already debugged the getDataAsHTML method and the string that it returns is fine, it contains the correct HTML, however when I call the method getParameter in the JSP y returns a null value. Here the code of the JSP: <% response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-Disposition", "attachment;filename=eYumReport.xls"); String msDataToExcel = request.getParameter("psExcelData"); %> Data to excel <%=msDataToExcel %> I may have to mention I am using this on Firefox 26, GWT 2.1, smartGWT 2.4, Windows 7 Professional and the Web application is on Windows Server 2008, mounted on Apache 6. Any ideas why this is happening??
tagged with: excel
type: Question
has comment: http://stackoverflow.com/comment/32601125
tagged with: gwt
has comment: http://stackoverflow.com/comment/32600438
score: 0

http://stackoverflow.com/comment/32691047
type: Comment
has text: Tested and accepted, I don't have enough reputation points to upvote the answer unfortunately.
comment on: http://stackoverflow.com/a/21633024
type: AnswerComment
score: 0

http://stackoverflow.com/comment/32717861
score: 0
type: AnswerComment
type: Comment
has text: @janepe: I'm sorry, but I'm not sure what you're saying. Could you clarify your statement above as well as the current state of your problem?
comment on: http://stackoverflow.com/a/21648318

http://stackoverflow.com/comment/32625190
score: 0
comment on: http://stackoverflow.com/q/21595078
type: Comment
type: QuestionComment
has text: Okay, can you tell me what exactly you want to pass???

http://stackoverflow.com/comment/32673769
type: AnswerComment
score: 0
type: Comment
has text: @JackSparrow: That depends. If you want the session to be persistence, then store in DB is OK, unless you need very high performance. Or use memcached or redis to temporally store the session in memory.
comment on: http://stackoverflow.com/a/21620731

http://stackoverflow.com/comment/105677645
score: 0
type: Comment
has text: You don't need to generate a CSR. Just use the `-genkey` option. That generates a keypair and a certificate. One step instead of two.
comment on: http://stackoverflow.com/a/45462170
type: AnswerComment

linux-mint
type: Tag
tag name: linux-mint
tags question: http://stackoverflow.com/q/21648335

http://stackoverflow.com/q/21657919
upvote count: 12
tagged with: camera
has comment: http://stackoverflow.com/comment/40659246
score: 12
downvote count: 0
answer count: 1
favorite count: 0
type: UnansweredQuestion
has body: I am taking pictures in the background inside my Android App. However it gives an error: 02-09 15:22:12.061: E/cheeta(28633): timer testing 02-09 15:22:13.546: W/System.err(28633): java.lang.RuntimeException: takePicture failed 02-09 15:22:13.546: W/System.err(28633): at android.hardware.Camera.native_takePicture(Native Method) 02-09 15:22:13.546: W/System.err(28633): at android.hardware.Camera.takePicture(Camera.java:1194) 02-09 15:22:13.551: W/System.err(28633): at cam.sharp.MainActivity$MyTimerTask.run(MainActivity.java:69) 02-09 15:22:13.551: W/System.err(28633): at java.util.Timer$TimerImpl.run(Timer.java:284) 02-09 15:22:13.551: E/cheeta(28633): timer testing 02-09 15:22:15.051: W/System.err(28633): java.lang.RuntimeException: takePicture failed 02-09 15:22:15.051: W/System.err(28633): at android.hardware.Camera.native_takePicture(Native Method) 02-09 15:22:15.051: W/System.err(28633): at android.hardware.Camera.takePicture(Camera.java:1194) 02-09 15:22:15.051: W/System.err(28633): at cam.sharp.MainActivity$MyTimerTask.run(MainActivity.java:69) 02-09 15:22:15.051: W/System.err(28633): at java.util.Timer$TimerImpl.run(Timer.java:284) 02-09 15:22:15.051: E/cheeta(28633): timer testing 02-09 15:22:16.551: W/System.err(28633): java.lang.RuntimeException: takePicture failed 02-09 15:22:16.556: W/System.err(28633): at android.hardware.Camera.native_takePicture(Native Method) 02-09 15:22:16.556: W/System.err(28633): at android.hardware.Camera.takePicture(Camera.java:1194) 02-09 15:22:16.561: W/System.err(28633): at cam.sharp.MainActivity$MyTimerTask.run(MainActivity.java:69) 02-09 15:22:16.561: W/System.err(28633): at java.util.Timer$TimerImpl.run(Timer.java:284) 02-09 15:22:16.561: E/cheeta(28633): timer testing I have two files. MainActivity.java and CameraPreview.java Here is the code for both. MainActivity.java package cam.sharp; import java.io.File; import java.io.FileOutputStream; import java.util.Timer; import java.util.TimerTask; import android.app.Activity; …
tagged with: android
has comment: http://stackoverflow.com/comment/32735011
has comment: http://stackoverflow.com/comment/32849452
tagged with: java
has title: Java.lang.Runtime exception: Take Picture failed?
has answer: http://stackoverflow.com/a/21728454
type: Question

http://stackoverflow.com/comment/32509211
has text: `The characters are copied in one go` using `System.arrayCopy` while your assumption that this done is one go without interleaving is reasonable and possibly true, there is no JVM specification that requires the same, the signature of the method is `public static native void`. I agree that the output I provided as examples are not likely, but there are not constrained by the specification to not occur. Besides, they serve as useful exposition for the purposes of answering the question at hand.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21529319
type: Comment

http://stackoverflow.com/q/21546699
answer count: 1
has answer: http://stackoverflow.com/a/21547273
accepted answer: http://stackoverflow.com/a/21547273
type: AnsweredQuestion
has title: getting property inside sub class using java inheritance?
tagged with: java
type: Question
has body: I have below classes. public abstract class BaseRequest{ protected SomeEntity entity; public BaseRequest() { entity= new SomeEntity(); } public void setName(String name){ entity.setName(name); } public void setAge(String age){ entity.setAge(age); } } public class Request extends BaseRequest{ private String address; public Request() { super(); } public void setAddress(String address){ this.address=address; } public String getAddress(){ return this.address; } } I create BaseRequest because it can be used by many sub classes. Also clients should not have access to SomeEntity property of BaseRequest.java Now clients can use Request as below. Request re = new Request(); re.setName("xxx"); re.setAge("xxxxx"); re.setAddress("xxxxxx"); and clients will send this request to service method as below. public void saveData(Request request){ //here i should get SomeEntity instance directly. } To get SomeEntity populated instance directly i can provide a getter method in BaseRequest.java. But if i provide a getter then even clients can also get SoemEntity instance by instantiating Request class. which i dont want to allow the clients to access it. Now the question is is there any best way to get someEntity instace inside saveData() ?
score: 0

http://stackoverflow.com/q/21673435
type: Question
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/21673523
has body: I have return a code to read a web page using jsoup-1.7.3.jar, Its working for some websites but giviing Read timed out error for some of the URls.... . Exception in thread "main" java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:152) at java.net.SocketInputStream.read(SocketInputStream.java:122) at java.io.BufferedInputStream.fill(BufferedInputStream.java:235) at java.io.BufferedInputStream.read1(BufferedInputStream.java:275) at java.io.BufferedInputStream.read(BufferedInputStream.java:334) at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687) at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1323) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468) at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:443) at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:424) at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:178) at org.jsoup.helper.HttpConnection.get(HttpConnection.java:167) at Main.main(Main.java:10)
answer count: 2
upvote count: 1
tagged with: url
has comment: http://stackoverflow.com/comment/32761430
favorite count: 0
accepted answer: http://stackoverflow.com/a/21673577
has title: Read Timed Out Error in reading URL using java
possible better answer: http://stackoverflow.com/a/21673523
has answer: http://stackoverflow.com/a/21673577
type: AnsweredQuestion
downvote count: 0
has comment: http://stackoverflow.com/comment/32800158

http://stackoverflow.com/q/21523149
upvote count: 1
favorite count: 0
type: UnansweredQuestion
answer count: 0
downvote count: 0
score: 1
tagged with: java
tagged with: eclipse
type: Question
has title: Stop Eclipse Java code completion from tacking on variable type to variable name
has body: I'm using Eclipse's Content Assist' Auto Activation, and I love it. But it has one really annoying feature. When I type a variable name, it tacks onto it the variable type. For example: private String name; is automatically changed into private String nameString; Is there a way to disable just this one feature / bug? I'm using Eclipse Kepler for Mac.

http://stackoverflow.com/q/21666381
tagged with: java
tagged with: eclipse
has body: I'm trying to launch a OSGI framework stack in debug mode in eclipse, and i wonder if there's a common way of doing it. First of all, i know i must configure Eclipse Plugin Development -> Target Platform for it to find my bundles and be able to develop easily with PDE. Let say i want to try my application on a Geronimo stack, i'll have to create a new Target Platform by hand, and manually add every bundle geronimo uses, and they are each in a separate folder... Same thing for Karaf, ServiceMix, Knopflerfish or any other stack i wanna try out. Is there another way of creating that Target Platform? Then, in the OSGi Framework launch configuration, whatever how is your Target Platform configured, by default the framework is Equinox and the only way i've found to change this is to install some eclipse plugins. I've found that Karaf provides EIK plugin which adds the Karaf framework. It hasn't been update for a long time, and i'm not even sure it supports Kepler... There's also Pax-Runner-Eclipse-Ui, which is no longer updated too. If you use the last available version of this plugin, you'll find that it provides a limited set of configurations, which includes several versions of Equinox, Felix and Concierge. AFAIK, these settings are directly packaged in the plugin, and there's no way to add a custom one (like a Karaf configuration, for example). And anyway, that plugin is helpful for running your bundles in differents frameworks, but the bundles used at runtime won't automatically appear in your Target Platform so you can develop against that particular framework. How do peoples usually work?? I'm trying to get things working for months, but i can't find a way to easily try some stacks in development mode. Some single bundles are easy to make working (service discovery, blueprint injection...), but having a complete stack with JSF, JPA and Transaction support is not a trivial thing to do, even after reading OSGi in Action, and Enterprise OSGi in Action. Did i miss some…
type: Question
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/32779759
favorite count: 0
has comment: http://stackoverflow.com/comment/32768990
has title: Running OSGI in Eclipse, generic way?
tagged with: osgi
tagged with: pde
has comment: http://stackoverflow.com/comment/32758686
answer count: 0
type: UnansweredQuestion
upvote count: 1
has comment: http://stackoverflow.com/comment/32911380
has comment: http://stackoverflow.com/comment/32779097
tagged with: eclipse-pde
has comment: http://stackoverflow.com/comment/32785196

http://stackoverflow.com/a/21657284
has comment: http://stackoverflow.com/comment/32733506
type: Answer
has comment: http://stackoverflow.com/comment/32734049
has comment: http://stackoverflow.com/comment/32734897
has comment: http://stackoverflow.com/comment/32733994
answers question: http://stackoverflow.com/q/21657208
has body: What about using the static method in the Character class: private static boolean containsOnlyLetter(String input) { for(int i=0; i &lt; input.length(); i++) { if (!Character.isLetter(input[i])) { return false; } } return true; } And please don't arbitrary catch exceptions in your code. One day one of those will catch an important one, makes it disappear and the program will fail at a later step. Debugging that will be a pain!
score: 0

http://stackoverflow.com/a/21649278
upvote count: 2
type: AcceptedAnswer
type: Answer
has body: Try to format your SimpleDateFormat using an E, which will output the day of the week. Than compare that Date as a String with your weekdays, e.g. day.equals("Monday"). Reference to SimpleDateFormat: http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
score: 2
accepted answer of: http://stackoverflow.com/q/21649233
downvote count: 0
answers question: http://stackoverflow.com/q/21649233

http://stackoverflow.com/comment/32504719
type: Comment
has text: When I print this. It shows like "[[Ljava.lang.Object;@50cedf4e, [Ljava.lang.Object;@3da6a354, [Ljava.lang.Object;@72cff6b, [Ljava.lang"
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21527511

http://stackoverflow.com/comment/32529552
score: 0
type: Comment
type: QuestionComment
has text: Have not tried any Java class with PsExec, take a look at this [SO Question](http://stackoverflow.com/questions/21515854), it may help you.
comment on: http://stackoverflow.com/q/21539307

http://stackoverflow.com/a/21645052
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/32712797
answers question: http://stackoverflow.com/q/21644970
upvote count: 1
has body: You need to escape the dot, if you want to split on a dot: String k[] = sen.split("\\."); A . splits on the regex ., which means any character.

database
tags question: http://stackoverflow.com/q/21664968
tags question: http://stackoverflow.com/q/21579326
tags question: http://stackoverflow.com/q/21523751
tags question: http://stackoverflow.com/q/21571886
tags question: http://stackoverflow.com/q/21659278
tags question: http://stackoverflow.com/q/21600626
tags question: http://stackoverflow.com/q/21556898
tags question: http://stackoverflow.com/q/21602183
tags question: http://stackoverflow.com/q/21641752
type: Tag
tags question: http://stackoverflow.com/q/21667058
tags question: http://stackoverflow.com/q/21592999
tags question: http://stackoverflow.com/q/21588038
tags question: http://stackoverflow.com/q/21576645
tags question: http://stackoverflow.com/q/21542825
tags question: http://stackoverflow.com/q/21672837
tag name: database
tags question: http://stackoverflow.com/q/21622382
tags question: http://stackoverflow.com/q/21533923
tags question: http://stackoverflow.com/q/21544485
tags question: http://stackoverflow.com/q/21549164
tags question: http://stackoverflow.com/q/21530325
tags question: http://stackoverflow.com/q/21600568
tags question: http://stackoverflow.com/q/21620622
tags question: http://stackoverflow.com/q/21517992
tags question: http://stackoverflow.com/q/21521238
tags question: http://stackoverflow.com/q/21515126
tags question: http://stackoverflow.com/q/21575468
tags question: http://stackoverflow.com/q/21577895
tags question: http://stackoverflow.com/q/21674326
tags question: http://stackoverflow.com/q/21518917

http://stackoverflow.com/q/21567037
tagged with: processing
score: -2
upvote count: 0
has title: Exception in thread "main" java.lang.StackOverflowError for Processing with Netbeans
answer count: 1
has comment: http://stackoverflow.com/comment/32578586
favorite count: 0
type: UnansweredQuestion
duplicate of: http://stackoverflow.com/q/214741
has body: whenever I run the main class as shown below, package gardeningmania; import processing.core.PApplet; import java.io.File; public class GardeningMania { public static void main(String[] args) { PApplet.main(new String[]{/*"--present",*/ "gardeningmania.Game"}); Game.main("null"/*"gardeningmania.Game"*/); File currentDir = new File("."); getAllFilse(currentDir); } } I get this error: ERROR CODE Exception in thread "main" java.lang.StackOverflowError at java.util.Hashtable.put(Hashtable.java:437) at sun.java2d.Disposer.add(Disposer.java:139) at sun.java2d.Disposer.addRecord(Disposer.java:107) at sun.awt.image.BufImgSurfaceData.initRaster(Native Method) at sun.awt.image.BufImgSurfaceData.createDataIC(BufImgSurfaceData.java:256) at sun.awt.image.BufImgSurfaceData.createData(BufImgSurfaceData.java:86) at sun.awt.image.BufImgSurfaceManager.&lt;init&gt;(BufImgSurfaceManager.java:55) at sun.awt.image.SurfaceManager.getManager(SurfaceManager.java:78) at sun.java2d.SurfaceData.getPrimarySurfaceData(SurfaceData.java:273) at sun.java2d.SunGraphicsEnvironment.createGraphics(SunGraphicsEnvironment.java:180) at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1154) at java.awt.image.BufferedImage.getGraphics(BufferedImage.java:1142) at processing.core.PFont.&lt;init&gt;(PFont.java:227) at processing.core.PFont.&lt;init&gt;(PFont.java:328) at processing.core.PApplet.createFont(PApplet.java:6560) at processing.core.PApplet.createFont(PApplet.java:6488) at gardeningmania.Game.&lt;init&gt;(Game.java:497) at gardeningmania.ImageLoader.&lt;init&gt;(ImageLoader.java:12) at gardeningmania.Game.&lt;init&gt;(Game.java:524) at gardeningmania.ImageLoader.&lt;init&gt;(ImageLoader.java:12) Can anyone explain what this error message means?
tagged with: netbeans
linked to: http://stackoverflow.com/q/214741
tagged with: java
downvote count: 2
has answer: http://stackoverflow.com/a/21568634
type: Question

http://stackoverflow.com/q/21523272
has title: Jar to dmg conversion
has answer: http://stackoverflow.com/a/21525391
type: Question
has comment: http://stackoverflow.com/comment/32498953
has body: Hi all please tell how to build setup for mac system from .jar files. I just tried jar bundler but in that file no main class is available please let me know as quick as possible
answer count: 1
tagged with: executable-jar
linked to: http://stackoverflow.com/q/2174849
favorite count: 0
upvote count: 3
duplicate of: http://stackoverflow.com/q/4395948
has comment: http://stackoverflow.com/comment/32561223
tagged with: macos
has comment: http://stackoverflow.com/comment/32906109
has comment: http://stackoverflow.com/comment/32498778
has comment: http://stackoverflow.com/comment/32497490
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/4395948
score: 3
downvote count: 0
tagged with: java
tagged with: javafx

http://stackoverflow.com/q/21561861
tagged with: vaadin7
answer count: 1
has comment: http://stackoverflow.com/comment/36655156
tagged with: java
tagged with: vaadin
type: UnansweredQuestion
type: Question
has answer: http://stackoverflow.com/a/21563855
has title: Set encoding vaadin?
has body: I created a CustomLayout but doesn't work encoding. Here in Brazil we use accentuation on some words but when I display my CustomLayout this words show &lt; ? >. Example: Nação(nation)-> displayed Na&lt; ? >&lt; ? >o. How to set encoding in vaadin 7 ?
score: 0

http://stackoverflow.com/comment/32685986
comment on: http://stackoverflow.com/a/21626264
score: 0
type: AnswerComment
type: Comment
has text: Thanks for the info. Regarding the String, is not exactly my problem since I have to create just 100 of String not more. The time is spent because inside the loop I'm calling others class which take a bit time to do some others operation. But anyway I didnt know it and sure I will use it in other parts of my code. Just let me share this clear example (http://www.yoda.arachsys.com/java/strings.html)

portlet
tags question: http://stackoverflow.com/q/21669353
tags question: http://stackoverflow.com/q/21545009
type: Tag
tag name: portlet
tags question: http://stackoverflow.com/q/21520937
tags question: http://stackoverflow.com/q/21653222

http://stackoverflow.com/a/21604622
type: Answer
has body: Your format string for parsing doesn't match the example date you have given. You could try something like the following: String val = "Wed Jan 08 08:49:13 GMT+05:30 2014"; DateFormat inFmt = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy"); Date date = inFmt.parse(val); DateFormat outFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); outFmt.setTimeZone(TimeZone.getTimeZone("GMT+1:00")); System.out.println(outFmt.format(date)); Note the following correspondences in the first two lines: Wed -> EEE Jan -> MMM 08 -> dd etc.
downvote count: 0
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/21604313
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21604313

http://stackoverflow.com/a/21616567
downvote count: 0
has body: You want to print the string values of the interior objects, not the string value of the array. Luckily java has a builtin for this: Arrays.deepToString() So your print code should be: System.out.println(Arrays.deepToString(trex.getStuff()));
upvote count: 3
type: Answer
has comment: http://stackoverflow.com/comment/32662967
answers question: http://stackoverflow.com/q/21616534
score: 3

http://stackoverflow.com/q/21627479
tagged with: ehcache
has answer: http://stackoverflow.com/a/21673345
has body: I am working on a project whose most of the Junit are failing. My job is to fix them and make them run. I have fixed around 200 Junit classes but there are around 136 Junits still failing, reason no Idea, some times they get fail and some they work. Try to drill down the problem and it the ehCache. It is being shut-down. Can any body please explain me why this exception occur in Junt testing and that to not all the time. Please Note we have test cases for "Action" classes as well(Which deal with Servlet Context) But interesting point all action test classes are getting passed. Error Message is : java.lang.IllegalStateException: The CacheManager has been shut down. It can no longer be used. at net.sf.ehcache.CacheManager.checkStatus(CacheManager.java:1504) at net.sf.ehcache.CacheManager.getCacheNames(CacheManager.java:1491) at net.sf.ehcache.CacheManager.clearAll(CacheManager.java:1526)
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/21627928
has title: CacheManager.clearAll throws CacheManager has been shut down for Junit Program
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/21627928
accepted answer: http://stackoverflow.com/a/21673345
tagged with: junit
tagged with: struts2
score: 0

http://stackoverflow.com/comment/32707894
type: Comment
type: QuestionComment
has text: What actually happens? What visibly goes wrong? Do you get an error message? If so, show it to us. Do you get wrong results? If so, show them to us, and show us what should have happened.
comment on: http://stackoverflow.com/q/21642489
score: 0

http://stackoverflow.com/comment/32556351
type: QuestionComment
has text: I think you should extend your question with code snippet.
comment on: http://stackoverflow.com/q/21556736
score: 0
type: Comment

http://stackoverflow.com/comment/50402965
type: Comment
score: 2
has text: Please do not answer like this. When someone asks how to do something, "Don't do it" is not the best answer;) If you want to have the same user interface on all platforms (iOS,Android,Windows), if app really needs the bottom tab bar, you might want to add it.
type: AnswerComment
comment on: http://stackoverflow.com/a/22347973

http://stackoverflow.com/comment/32655515
type: Comment
type: QuestionComment
has text: you can use FreeType to rasterize text
comment on: http://stackoverflow.com/q/21612715
score: 0

http://stackoverflow.com/q/21563755
has title: View Java functions inlined
downvote count: 2
has comment: http://stackoverflow.com/comment/32569519
score: -2
tagged with: user-interface
has comment: http://stackoverflow.com/comment/32570231
answer count: 1
has comment: http://stackoverflow.com/comment/32569386
favorite count: 0
has comment: http://stackoverflow.com/comment/32569395
upvote count: 0
has comment: http://stackoverflow.com/comment/32569423
has body: First off all, I know there are several questions about "Java inline". But they are all about how the compiler or JVM inlines function calls. I'm interested in doing this myself, or create some kind of a View for it. I want to define a function call of a class, and want to see everything inlined. Every method call should get inlined. I'm not sure how to handle instantiation of new objects, but it doesn't matter as much. The goal is manual optimization, i.e. if a parameter is checked too often against null. Is there a tool to to something like this? I would prefer a GUI, but some kind of command line tool where I can specify a class function and it dumps some text somewhere will suffice, too. EDIT: For clearification: Today I argued to use the NullObjectPattern, because some are defensively overchecking for nulls everywhere. This makes the code unreadable and unclean. I dont like it and wanted to have some kind of a tool, to show them how often they are actually checking the very same parameter again and again for null.
has answer: http://stackoverflow.com/a/21564299
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32569853
has comment: http://stackoverflow.com/comment/32569539
linked to: http://stackoverflow.com/q/2096361
type: Question
has comment: http://stackoverflow.com/comment/32569460
tagged with: java
tagged with: inline-code
has comment: http://stackoverflow.com/comment/32569521

http://stackoverflow.com/a/21655165
score: 0
has comment: http://stackoverflow.com/comment/32852919
answers question: http://stackoverflow.com/q/21543022
type: Answer
has body: If you have COCOS_HOME defined as an environment variable, you can load the environment variables with the property task and the environment attribute. By setting the environment attribute with a prefix to use. Properties will be defined for every environment variable by prefixing the supplied name and a period to the name of the variable. You will need to be sure to load the environment variables prior to loading your properties files, so that the property reference in the properties file is expanded to have the value of the property. For example: &lt;property environment="env"/&gt; &lt;echo message="COCOS_HOME is set to = ${env.COCOS_HOME}"/&gt; &lt;property file="android.properties"/&gt; &lt;echo message="android.library.reference.1 is set to = ${android.library.reference.1}" /&gt;
has comment: http://stackoverflow.com/comment/32768120
has comment: http://stackoverflow.com/comment/32756379

http://stackoverflow.com/comment/32601359
score: 0
has text: You need to put () around the h and then replace group 2.. group 0 is the entire match (lh/mh), group 1 is the single character (which you can replace with [lmts] and group 1 is the h
type: Comment
comment on: http://stackoverflow.com/q/21581573
type: QuestionComment

http://stackoverflow.com/q/21617471
answer count: 1
downvote count: 0
tagged with: neo4j
favorite count: 0
has answer: http://stackoverflow.com/a/21623228
has body: Can you help me with a problem. I have installed Neo4j version 2.0.0. And I've started the server. I'm trying to connect to it via a Java client(Java code in Eclipse). Despite setting the property allow_store_upgrade=true in Neo4j.properties, I still get the exception. org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException: Failed to start Neo4j with an older data store version. To enable automatic upgrade, please set configuration parameter "allow_store_upgrade=true" Can any one help me. Please, I am stuck at this problem. service = new GraphDatabaseFactory().newEmbeddedDatabase(Neo4jDBPath); It fails at this step. Please help me.
score: 2
type: AnsweredQuestion
has title: Neo4j Auto Upgrade option
upvote count: 2
type: Question
tagged with: java
accepted answer: http://stackoverflow.com/a/21623228

http://stackoverflow.com/q/21518014
answer count: 1
linked to: http://stackoverflow.com/q/12615720
has answer: http://stackoverflow.com/a/21518053
tagged with: android
tagged with: eclipse-adt
type: AnsweredQuestion
tagged with: java
has title: How to change color of background Android Java in Eclipse ADT
type: Question
accepted answer: http://stackoverflow.com/a/21518053
has body: I am very new to mobile development, this isn't homework I am working ahead of my class, I developed a simple app that has a button and when it's pressed it shows a message "Hello Android". I would like to build on this and change the color of the background when the onClickListener is called, I will post my code below, I am asking for the best approach to achieve my goal (change background). I want to iterate that this code below works, and that I am not asking for anything to do with the code I have presented, I want to add to it to change the background color (it's currently white, I'm assuming by default). Oh and I have never worked with Java before (very difficult course teaching android/iOS/WinMobile in 1 class). Thank you. public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setupMessageButton(); } private void setupMessageButton() { // 1. Get a reference to the button final Button messageButton = (Button) findViewById(R.id.helloDroidButton); //Set the click listener to run my code. //Code will run when user clicks button. messageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Anonymous class? --&gt; not sure what he means Log.i("DemoButtonApp", "Hello Android!"); Toast.makeText( MainActivity.this, "Hello Android!", Toast.LENGTH_LONG ).show(); } }); }
linked to: http://stackoverflow.com/q/2748830
score: 0

http://stackoverflow.com/comment/32686774
has text: Although, I have another projects imported in the same way and they work.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21630389

http://stackoverflow.com/comment/32709040
type: QuestionComment
has text: http://stackoverflow.com/questions/1692230/is-it-possible-to-catch-out-of-memory-exception-in-java
comment on: http://stackoverflow.com/q/21643225
type: Comment
score: 0

http://stackoverflow.com/comment/32770965
type: Comment
has text: @LutzHorn whats your suggestion, Thanks @ Kumar
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21673754

querying
type: Tag
tag name: querying
tags question: http://stackoverflow.com/q/21542473

http://stackoverflow.com/q/21525198
tagged with: java
type: Question
has title: GCM - How to send notification to multiple device targets with different message contents in java
downvote count: 0
has body: I need to send different message contents to different device targets final List&lt;String&gt; androidTargets = new ArrayList&lt;String&gt;(); serverSender.send(gcmMessage, androidTargets, 1); I can add multiple device targets with same message however I need to add multiple messages related to that target like: List&lt;String&gt; messages Message index need to be mapped to device target Is there any possibility to achieve this? I need this since I want to send notification in a single shot instead of queuing in my side!
tagged with: android
score: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/32500896
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32501703
upvote count: 1
has comment: http://stackoverflow.com/comment/32501902
has comment: http://stackoverflow.com/comment/32500614

http://stackoverflow.com/q/21568501
accepted answer: http://stackoverflow.com/a/21675974
tagged with: java
tagged with: concurrency
answer count: 1
has body: I am currently trying to write a Java program that solves this. "Another way to generalize the two-thread Peterson lock is to arrange a number of 2-thread Peterson locks in a binary tree. Suppose n is a power of two. Each thread is assigned a leaf lock which it shares with one other thread. Each lock treats one thread as thread 0 and the other as thread 1." I feel like I have solved it, but my output is not always correct. I suspect my problem is in the for loop in my lock method that calls a verified Peterson lock (Peterson lock has no errors in that it was provided to solve this problem). I basically build a balanced binary tree, declare an array of Peterson Algorithm instances, and, as each thread comes in, I have use the tree as an index and call the Peterson locks. package mutex; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; public class tree_lock implements Lock{ int total_instances; int thread_instances = 0; int N; static int cnt = 0; static int cnt2 = 0; int flag = 0; Node root; Peterson[] PeterInstances; int[] IncomingThreadIDs; final private ThreadLocal&lt;Integer&gt; THREAD_ID2 = new ThreadLocal&lt;Integer&gt;(){ final private AtomicInteger id2 = new AtomicInteger(0); protected Integer initialValue(){ return id2.getAndIncrement(); } }; //Constructor : tree_lock Constructor //Input : n, the number of threads //Descritpion : Determine number of instances fore each thread, Create IDs for each thread, // Create Balanced Binary Tree of with keys numbered from 0 to n tree_lock(int n) { N=n; int temp = n; total_instances = n - 1; int[] IDs = new int[total_instances]; //Determine number of instances of each thread while(temp != 1) { temp /=2; thread_instances++; } PeterInstances = new Peterson[total_instances]; for(int i = 0; i &lt; total_instances; i++) { PeterInstances[i] = new Peterson(); } IncomingThreadIDs = new int[n]; //Create IDs …
tagged with: binary-tree
has title: Peterson Algorithm as a binary tree
has answer: http://stackoverflow.com/a/21675974
score: 0
tagged with: multithreading
type: Question
type: AnsweredQuestion
tagged with: algorithm

http://stackoverflow.com/comment/32521634
has text: Thanks, probably a very newbie question :).
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21536458

http://stackoverflow.com/q/21666635
linked to: http://stackoverflow.com/q/2575363
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32750121
tagged with: generics
has body: I have the following classes: Class Dog extends Animal Class Cat extends Animal Class Mouse extends Animal Furthermore, I have a List in which I put every Animal, regardless of the subclass: List&lt;? extends Animal&gt; list = new ArrayList&lt;? extends Animal&gt;(); Populating said list with Dogs, Cats and Mice works perfectly, unless I want to later check what kind of Animal there is inside the list. for (Animal animal: list) { if (animal instanceof Dog) { //do some dog stuff } if (animal instanceof Cat) { // do some cat stuff } } How can I check for each Animal in the list whether it is a Dog, a Cat or a Mouse?
has comment: http://stackoverflow.com/comment/32750417
has answer: http://stackoverflow.com/a/21666671
has comment: http://stackoverflow.com/comment/32750293
upvote count: 1
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/32750212
has comment: http://stackoverflow.com/comment/32750196
tagged with: java
has title: Check for subclass in Java
has comment: http://stackoverflow.com/comment/32750231
has comment: http://stackoverflow.com/comment/32750490
score: 0
has comment: http://stackoverflow.com/comment/32759013
answer count: 2
has comment: http://stackoverflow.com/comment/32750331
tagged with: polymorphism
has comment: http://stackoverflow.com/comment/32750290
has comment: http://stackoverflow.com/comment/32750171
favorite count: 0
has comment: http://stackoverflow.com/comment/32750519
has answer: http://stackoverflow.com/a/21666723

http://stackoverflow.com/comment/32545501
has text: If you have got it, please close the question.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21550912

http://stackoverflow.com/a/21593171
has comment: http://stackoverflow.com/comment/32623172
has comment: http://stackoverflow.com/comment/32622330
has comment: http://stackoverflow.com/comment/32622013
has body: The best way to approach this is using a CardLayout. Notes A button with an ActionListener is far better than a MouseListener over a rectangle. The button will show focus when the mouse is pointed at it, or the component is tabbed to via the keyboard. The button is keyboard accessible. The button has facility to support multiple icons built in (e.g. for 'initial look', focused, pressed etc.) White space in the GUI is provided around the menu panel and game by adding an EmptyBorder The button is made larger by setting a margin. Adjust margins, borders and preferred size according to need. These sizes were set by me so as not to make the screenshots too large. See more tips in the code comments. Code Here is the MCTaRE (Minimal Complete Tested and Readable Example) that produced the above screenshots. import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import javax.swing.border.EmptyBorder; public class PipesGame { public static void main(String[] args) { Runnable r = new Runnable() { @Override public void run() { // the GUI as seen by the user (without frame) final CardLayout cl = new CardLayout(); final JPanel gui = new JPanel(cl); // remove if no border is needed gui.setBorder(new EmptyBorder(10,10,10,10)); JPanel menu = new JPanel(new GridBagLayout()); JButton playGame = new JButton("Play!"); ActionListener playGameListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cl.show(gui, "game"); } }; playGame.addActionListener(playGameListener); Insets margin = new Insets(20, 50, 20, 50); playGame.setMargin(margin); menu.add(playGame); gui.add(menu); cl.addLayoutComponent(menu, "menu"); JPanel pipes = new Pipes(); gui.add(pipes); cl.addLayoutComponent(pipes, "game"); JFrame f = new JFrame("Pipes Game"); f.add(gui); // Ensures JVM closes after frame(s) closed and // all non-daemon threads are finished f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // See https://stackov…
has comment: http://stackoverflow.com/comment/32661480
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32622317
has comment: http://stackoverflow.com/comment/32623566
has comment: http://stackoverflow.com/comment/32624370
type: Answer
accepted answer of: http://stackoverflow.com/q/21592492
answers question: http://stackoverflow.com/q/21592492
has comment: http://stackoverflow.com/comment/32661550
score: 6
upvote count: 6

http://stackoverflow.com/comment/32552037
comment on: http://stackoverflow.com/a/21547833
type: AnswerComment
score: 0
has text: @user3152686 With xls files, there's nothing that can be done to reduce memory usage, it will be loaded completely in memory, unlike with .xlsx files where you have a lot more options to control the memory used.
type: Comment

http://stackoverflow.com/comment/32749616
type: QuestionComment
has text: Depends on whom the message is intended for. You can use `IOException` with a detail message, or make your own subclass of `Exception`, `RuntimeException`, or some other appropriate sublass.
score: 0
comment on: http://stackoverflow.com/q/21666291
type: Comment

http://stackoverflow.com/comment/32644420
score: 1
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21606532
has text: Can you show me some value `a` that will fail test `(a != 1 OR a != 2)`?

http://stackoverflow.com/a/21673521
has body: I'm not a MS guy, but there might be an issue with not exporting the variables after setting them. Try setting the environment variables manually ( point and click :) ) through computer>properties.. Also, you should probably set it to reference the previously set attributes and add new, something like: PATH set "$PATH;C:\Program Files\Java\jdk1.7.0_51\bin" Sorry but, I don't know the syntax. Hope it helps a bit. Follow this tutorial to set the environment variables.
score: 0
answers question: http://stackoverflow.com/q/21671623
type: Answer

http://stackoverflow.com/q/21611290
upvote count: 1
type: Question
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32674437
has comment: http://stackoverflow.com/comment/32653403
has answer: http://stackoverflow.com/a/21611893
tagged with: eclipse
has comment: http://stackoverflow.com/comment/32659452
has comment: http://stackoverflow.com/comment/32659178
answer count: 1
downvote count: 0
tagged with: jar
favorite count: 0
has comment: http://stackoverflow.com/comment/32653702
accepted answer: http://stackoverflow.com/a/21611893
tagged with: maven
has comment: http://stackoverflow.com/comment/32658748
has body: SOLVED! ok, so i have a web application which is working with the JAR files in the lib folder. I've been trying to unzip one of the JARs in my WEB folder's classes. So that the 2 projects merge in 1 project on build. I got the jar unzipped in the correct location using: Building a WAR project with unzipped JAR dependency? Now you may be asking yourself why i would want to do this. Since it's to hard to explain lets just go with: It's what I want to do. Just to be clear: I dont want lectures telling me "it's wrong" and "you can't do that, it has to be this way". I know what i'm asking and i know you normally woulden't do this. So lets give it a try: I've set it to unzip in my classes folder. All files go in WEB-INF\classes. However it doesn't load my beans anymore (those from the JAR). I scan both packages with the component scanner like when i was using the packaged JAR (which worked). There is a difference though between the WAR and JAR. My JAR has different package names, like: WAR: com.test JAR: com.root.test Could it be that this is the problem? Different Package names? If not what am i missing here? If you need to see some code just ask as i'm unsure what it is you need to see. Thanks in advance! EDIT: My currect folder structure inside the WAR's WEB-INF folder is as follows: classes +- com +- +- root +- +- +- test +- +- +- +- processer +- +- +- +- splitter +- +- +- +- validators +- +- test +- +- +- beans +- +- +- services +- +- +- validators I scan it using: &lt;context:component-scan base-package="com.test,com.root.test"/&gt; UPDATE: Ok i've found the problem. The code was all fine. It was a problem with Eclipse. Eclipse was cleaning the builder folder and not filling it up properly. I've removed eclipse out of the equation and it works fine. Thanks for all the help guys, i realy appreciate it!
linked to: http://stackoverflow.com/q/1368088
has comment: http://stackoverflow.com/comment/32653128
score: 1
has title: Unzipped JAR in WAR classes folder not working?
tagged with: java

http://stackoverflow.com/comment/32578603
score: 0
has text: @jpmc26 I used pip install sympy.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21568446

http://stackoverflow.com/comment/32613165
type: QuestionComment
score: 1
has text: Is your in-memory (HSQLDB?) database defined as a bean in the spring application context? If so, you can tell Spring to re-initialise the context between tests - which will clear out the database.
comment on: http://stackoverflow.com/q/21584942
type: Comment

http://stackoverflow.com/q/21663423
has answer: http://stackoverflow.com/a/39247196
type: Question
tagged with: opencv
tagged with: java-native-interface
downvote count: 0
has title: Generating header file with JNI using 'javah'
has comment: http://stackoverflow.com/comment/32745452
answer count: 3
linked to: http://stackoverflow.com/q/13438368
has answer: http://stackoverflow.com/a/47827057
has body: I'm trying to use JNI for an Android application using the OpenCV4Android library. I can generate a header file without using the opencv library, but I get an error whenever the class imports anything. I assume it needs to link to the library, but I'm not sure how to do that? I'm using cygwin on a Windows 8.1 64 bit machine. original output: $ javah -jni -classpath ./bin/classes -d jni/ com.example.icam.nativeRDE Error: Class org.opencv.core.Mat could not be found. After following advice from: Android, generate jni Header Files with javah , show error that can&#39;t find org.opencv.core.Mat, I get the following output: $ javah -classpath /cygdrive/c/Users/Majid/Documents/OpenCV4Android/OpenCVLib2.4.8/bin/classes/org/opencv/;/cygdrive/c/Users/Majid/Documents/OpenCV4Android/iCam/bin/classes/com/example/icam/ -jni -d jni/ com.example.icam.nativeRDE Error: no classes specified -bash: /cygdrive/c/Users/Majid/Documents/OpenCV4Android/iCam/bin/classes/com/example/icam/: is a directory I've tried: removing '/' after icam adding nativeRDE after 'icam/' adding nativeRDE.class after 'icam/' Thanks for any help.
favorite count: 0
has comment: http://stackoverflow.com/comment/32746785
has comment: http://stackoverflow.com/comment/98940126
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32758292
tagged with: android
has comment: http://stackoverflow.com/comment/32864342
has comment: http://stackoverflow.com/comment/32862479
score: 3
has answer: http://stackoverflow.com/a/25311083
upvote count: 3
tagged with: java
linked to: http://stackoverflow.com/q/39261963
tagged with: javah

http://stackoverflow.com/comment/32515543
has text: Distance between your two Point objects? `double distance = start.distance(end);`
score: 1
type: Comment
comment on: http://stackoverflow.com/q/21533310
type: QuestionComment

http://stackoverflow.com/comment/32666554
type: Comment
score: 0
comment on: http://stackoverflow.com/q/21617986
type: QuestionComment
has text: @Rafa I didn't see a closing brace to the block starting after the String.

http://stackoverflow.com/a/21575879
has comment: http://stackoverflow.com/comment/32590672
type: Answer
answers question: http://stackoverflow.com/q/21575156
has comment: http://stackoverflow.com/comment/32591153
has comment: http://stackoverflow.com/comment/32590937
has comment: http://stackoverflow.com/comment/32590758
has body: I've solved my problem like this: private void txtNameKeyReleased(java.awt.event.KeyEvent evt) { String j = (String)txtName.getText(); if ( j.matches("\\d+") &amp;&amp; !txtName.getText().isEmpty()) { jOptionPane1.showMessageDialog(null, "Please enter String values"); txtName.setText(""); } } Thanks for the ones who tried to help me :)
score: 0
has comment: http://stackoverflow.com/comment/32590551

http://stackoverflow.com/comment/32707868
type: QuestionComment
has text: The order of operands does not matter for `==`. Whether it matters for `.equals()` is up to the implementation of `.equals()`, but best practice would say that `a.equals(b) == b.equals(a)`
comment on: http://stackoverflow.com/q/21642374
score: 0
type: Comment

http://stackoverflow.com/a/21549280
has comment: http://stackoverflow.com/comment/32544432
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/32546538
answers question: http://stackoverflow.com/q/21549194
has body: That depends on your application. If you have complex object graphs, it might be worthwhile using JPA for the conversion. You can define several EntityManager objects, for each schema.

http://stackoverflow.com/q/21570810
tagged with: mysql
tagged with: jboss
has answer: http://stackoverflow.com/a/21570869
answer count: 1
has body: i am searching the solution for the below problem , if you have any idea please share when I try to run a single query from java (jboss server), am getting the below exception (not frequently .) Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was43200 seconds ago. The last packet sent successfully to the server was 43200 seconds ago, which is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.* if connection is idle, it is closed by MySQL. in this case Java will give Can not write: broken pipe" or alike exception but in this case, connection is not idle. it is working. so MySQL won’t close it. but Java is waiting for query result and cannot get it for 12 hours so it shows "Read Timeout" exception
score: 0
type: UnansweredQuestion
has title: Communications Exception in MySQL
type: Question
tagged with: java

http://stackoverflow.com/q/21667592
has body: I want to extract the R,G and B values of the pixels of an image. I do it in two ways. File img_file = new File("../foo.png"); BufferedImage img = ImageIO.read(img_file); 1st method(which works fine): img.getRaster().getPixel(i, j, rgb); 2nd method(which throws new IllegalArgumentException("More than one component per pixel")) red = img.getColorModel().getRed(img.getRGB(i, j)); What is the reason for this behaviour?
has title: Get RGB components from ColorModel
tagged with: pixel
tagged with: java
tagged with: rgb
type: Question
answer count: 2
tagged with: raster
score: 0
tagged with: colors
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21667656
has answer: http://stackoverflow.com/a/21667661

http://stackoverflow.com/a/21540117
answers question: http://stackoverflow.com/q/21540063
type: Answer
score: 0
has body: http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html#read() - From API, the read() method of InputStream throws IOException, hence you either need to catch it or rethrow it

http://stackoverflow.com/q/21619305
accepted answer: http://stackoverflow.com/a/21620436
downvote count: 0
has comment: http://stackoverflow.com/comment/32667584
has body: I'm getting the following error: &gt; 02-06 23:10:24.104: E/dalvikvm(912): Could not find class &gt; 'android.support.v4.app.FragmentActivity', referenced from method &gt; com.robotium.solo.Waiter.getSupportFragment When running a project I'm using for Programming Mobile Applications for Android Handheld Systems on Coursera.I believe this error is somehow related to my output answer being considered incorrect. if I can fix this error,I can fix my output. I didn't have the latest version of Android Support Repository (not installed) when I initially ran my tests,but I now have the latest version of Android Support Repository according to the SDK Manager (v4),and have even restarted Eclipse and the emulator,but I'm still getting the error. How can I fix the LogCat claiming ASR doesn't exist when it's installed according to the SDK?
has answer: http://stackoverflow.com/a/21619576
has title: "Could not find class 'android.support.v4.app.FragmentActivity'" Error
favorite count: 0
has answer: http://stackoverflow.com/a/27167317
tagged with: android
possible better answer: http://stackoverflow.com/a/26049978
has answer: http://stackoverflow.com/a/26049978
answer count: 4
has comment: http://stackoverflow.com/comment/32668003
has comment: http://stackoverflow.com/comment/32667630
score: 17
has comment: http://stackoverflow.com/comment/32667757
has comment: http://stackoverflow.com/comment/32667733
has comment: http://stackoverflow.com/comment/32667605
upvote count: 17
has comment: http://stackoverflow.com/comment/32668024
type: Question
type: AnsweredQuestion
tagged with: android-fragments
tagged with: java
has answer: http://stackoverflow.com/a/21620436
has comment: http://stackoverflow.com/comment/32667800
tagged with: eclipse

cd
tag name: cd
tags question: http://stackoverflow.com/q/21582143
type: Tag

http://stackoverflow.com/comment/32517994
score: 0
has text: When I look at the downloaded directory, I don't see anything resembleing a com jar file.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21533056

http://stackoverflow.com/comment/109932804
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/24323795
has text: @A.D: Yeah, you're totally right. My excuse is that I was 6 years younger! :-D All jokes aside I don't see any real reason anymore why we did include it explicitly back then. To use a newer version I would use dependencyManagement instead - and that was not part of the question.
score: 1

http://stackoverflow.com/comment/32718642
has text: `BTW - the SSCCE Document will go off the net at the end of the month.` @AndrewThompson, Why? There ares more than one forum on the web. I use the `SSCCE` link on all the other web sites. Other web sites (like Java Ranch) even recognize `SSCCE` as a keyword and will generate the link for you.
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21644142

http://stackoverflow.com/q/21602069
score: 0
tagged with: http://stackoverflow.com/tag/xml
type: UnansweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/21602170
has title: How can I put the value from an XML file into an array list in another class in java?
type: Question
has comment: http://stackoverflow.com/comment/32637933
answer count: 1
has body: I am reading in an XML file, and trying to return the values in another class using Java. In the XML Reader I read in the values from the XML file. I'm not quite sure how to do this. Any help would be appreciated. public class XMLReader { public static List&lt;String&gt; load() { try{ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); Document doc = docBuilder.parse (new File("C:/adapters.xml")); doc.normalize(); NodeList rootNodes = doc.getElementsByTagName("adapters"); Node rootNode = rootNodes.item(0); Element rootElement = (Element) rootNode; NodeList adaptersList = rootElement.getElementsByTagName("class"); for(int i=0; i&lt;adaptersList.getLength(); i++){ Node theAdapter = adaptersList.item(i); Element adpElement = (Element) theAdapter; System.out.println("This is: " + adpElement.getTextContent()); } }catch(ParserConfigurationException e){ e.printStackTrace(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } } public class AdapterLoader { public static List&lt;AbstractAdapter&gt; loadAllAdapters() { List&lt;AbstractAdapter&gt; allAdapters = new ArrayList&lt;AbstractAdapter&gt;(); List&lt;String&gt; adapterClasses = XMLReader.load(); for (String className : adapterClasses) { try { Class adapters = Class.forName(className); AbstractAdapter adp = (AbstractAdapter) adapters.newInstance(); allAdapters.add(adp); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return allAdapters; } }
tagged with: class

http://stackoverflow.com/q/21540527
has comment: http://stackoverflow.com/comment/32531869
has answer: http://stackoverflow.com/a/21557210
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32531933
tagged with: java
has body: I get this error while running this Java/JDBC code. Any ideas how to get around it? Seems like it's complaining about the parameter in date_trunc function? org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1" Position: 100 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryEx ecutorImpl.java:2161) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutor Impl.java:1890) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.ja va:255) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Stat ement.java:560) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(Abstract Jdbc2Statement.java:417) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc 2Statement.java:302) Java code: static PreparedStatement searchErrorPP = connection.prepareStatement( "select count(*) from tracking where date_trunc('day', run_date) &lt;= date_trunc('day', timestamp ?)"); public static int queryCount(java.util.Date date) throws SQLException { PreparedStatement ps = null; try { ps = searchErrorPP; ps.setDate( 1, new java.sql.Date(date.getTime())); ResultSet rs = ps.executeQuery(); resulting query which executes fine in pgAdmin: select count(*) from tracking where date_trunc('day', run_date) &lt;= date_trunc('day', timestamp '2014-11-11 -05:00:00')
type: Question
score: 9
has comment: http://stackoverflow.com/comment/32617975
accepted answer: http://stackoverflow.com/a/21557210
answer count: 2
has comment: http://stackoverflow.com/comment/32531604
upvote count: 9
has comment: http://stackoverflow.com/comment/32531709
has answer: http://stackoverflow.com/a/29655792
downvote count: 0
has title: date_trunc org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1"
tagged with: postgresql
possible better answer: http://stackoverflow.com/a/29655792
has comment: http://stackoverflow.com/comment/32532228
tagged with: jdbc
has comment: http://stackoverflow.com/comment/32531237
favorite count: 0

http://stackoverflow.com/comment/32624427
type: Comment
comment on: http://stackoverflow.com/a/21594554
has text: What a great explanation..I read every word and I actually learned something today. I wish I could give you 10 likes. This will be a the best answer for sure!
type: AnswerComment
score: 0

http://stackoverflow.com/q/21621450
has body: i am trying to influence a UI-Element during an event in javaFX. void buttonClicked(ActionEvent e) { labelInfo.setText("restarting - might take a few seconds"); jBoss.restart(); labelInfo.setText("JBoss successfully restarted"); } The action "jBoss.restart()" waits till the JBoss is restarted. The problem: the text "restarting - ..." is not displayed. The application waits till the JBoss is restarted and then it shows the Text "JBoss successfully restarted". My thoughts: the scene is refreshed AFTER the event is completed. So the first label-change will not happen. How can i show a info message during an event?
tagged with: javafx-2
score: 2
upvote count: 2
tagged with: javafx
has answer: http://stackoverflow.com/a/21624233
accepted answer: http://stackoverflow.com/a/21624233
type: AnsweredQuestion
tagged with: scene
tagged with: java
type: Question
answer count: 1
downvote count: 0
favorite count: 0
has title: JavaFX - Action during event
tagged with: events

http://stackoverflow.com/q/21644142
type: Question
has comment: http://stackoverflow.com/comment/32711742
has comment: http://stackoverflow.com/comment/32710743
has comment: http://stackoverflow.com/comment/32718642
tagged with: java
has answer: http://stackoverflow.com/a/25245206
has comment: http://stackoverflow.com/comment/32710691
tagged with: jtable
has comment: http://stackoverflow.com/comment/32712651
has comment: http://stackoverflow.com/comment/32711801
answer count: 2
has comment: http://stackoverflow.com/comment/32726715
has answer: http://stackoverflow.com/a/21650806
has comment: http://stackoverflow.com/comment/32710807
downvote count: 0
score: 1
has title: Using JPopupMenu + JTextField for a quick search
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32712483
has comment: http://stackoverflow.com/comment/32726523
has comment: http://stackoverflow.com/comment/32726450
has comment: http://stackoverflow.com/comment/32710664
has comment: http://stackoverflow.com/comment/32710704
has body: I have a JTable that displays business data. To make it more usable, I want to add a popup menu when right-clicking the column header which simply displays a text input field which serves as the input for a filtering. It's easy to add a popup menu when right-clicking on the column header and to put a JTextField inside it. However, I would like the text field to automatically gain focus so that the user can instantly start typing rather than having to focus the text field first. Relevant code (fully working SSCCE below): final JTextField filter = new JTextField( 20 ); final JPopupMenu popup = new JPopupMenu(); popup.add( filter ); table.getTableHeader().addMouseListener( new MouseAdapter() { @Override public void mousePressed( MouseEvent event ) { if( !event.isPopupTrigger() ) { return; } popup.show( table, event.getX(), event.getY() ); // TODO focus the text field } } ); At the TODO comment's location I tried things like filter.requestFocusInWindow(), but that doesn't work. I assume that the popup menu itself is stealing the focus. How can I force the text field to gain focus when the popup is triggered? Alternatively if there is a better way to display a text field popup I'd be glad to see that, too :) SSCCE: import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JFrame; import javax.swing.JPopupMenu; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; public class Test { private static final JTable table = new JTable( new Object[][] { { "Foo", "Bar" } }, new Object[] { "A", "B" } ); public static void main( String[] args ) { final JTextField filter = new JTextField( 20 ); final JPopupMenu popup = new JPopupMenu(); popup.add( filter ); table.getTableHeader().addMouseListener( new MouseAdapter() { @Override public void mousePressed( MouseEvent event ) { if( !event.isPopupTrigger() ) { return; } popup.show( table, event.getX(), event.getY() ); // TODO focus the text field } } ); JFrame frame = ne…
has comment: http://stackoverflow.com/comment/32711869
has comment: http://stackoverflow.com/comment/32729329
upvote count: 1
tagged with: swing
has comment: http://stackoverflow.com/comment/32710523

http://stackoverflow.com/comment/32691454
comment on: http://stackoverflow.com/a/21633339
type: Comment
has text: +1 for the last sentence – the design should really have a `Player` object that takes `Ground` as a constructor parameter, in order to make the dependency explicit. IMO in OO code, `static` should mostly be used for constants and in API surfaces, not for internally structuring code.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32660041
score: 0
comment on: http://stackoverflow.com/q/21614743
type: QuestionComment
has text: What has javascript to do with your app? After you downloaded the zip what does Filetransfer has to do? You mention two different paths.
type: Comment

http://stackoverflow.com/comment/32716091
type: QuestionComment
type: Comment
has text: You should post your code so we can help. It's likely you are not using the `BitmapOptions` object to specify things like size of the download.
comment on: http://stackoverflow.com/q/21647403
score: 0

http://stackoverflow.com/comment/32657947
score: 0
type: AnswerComment
has text: Thank you Peter. It worked, and can I tell you that, on a hunch, I actually tried that a few hours ago. It didn't then, but you know how debugging goes -- I might have momentarily changed something else which still gave rise to the same issue. For my understanding: I had assumed that Spring (which I've only used for two days) matched property "name" to the method it finds that sets it. But I guess there could be any number of methods that sets a property value. So: if name = "fooBar", then your setter/getter names should be setFooBar() and getFooBar()?
type: Comment
comment on: http://stackoverflow.com/a/21613724

http://stackoverflow.com/q/21556576
answer count: 3
downvote count: 0
tagged with: jvm
favorite count: 0
upvote count: 2
tagged with: cpu-usage
possible better answer: http://stackoverflow.com/a/21556755
accepted answer: http://stackoverflow.com/a/21557167
has answer: http://stackoverflow.com/a/21556755
type: AnsweredQuestion
score: 2
tagged with: opensuse
tagged with: java
tagged with: eclipse
type: Question
has body: I am using Eclipse for basic android development along with chrome browser on my laptop and i see that eclipse alone is taking beyond 100% CPU everytime. My system properties are as below: Linux Distro cat /etc/issue Welcome to openSUSE 12.2 "Mantis" - Kernel \r (\l). Kernel uname -a Linux linux-b4rl.site 3.4.47-2.38-desktop #1 SMP PREEMPT Fri May 31 20:17:40 UTC 2013 (3961086) x86_64 x86_64 x86_64 GNU/Linux JAVA Version java version "1.7.0_40" OpenJDK Runtime Environment (IcedTea 2.4.1) (suse-3.41.1-x86_64) OpenJDK 64-Bit Server VM (build 24.0-b50, mixed mode) As you can see i am not running any emulator and chrome is not using any JRE plugin. My laptop is Dell Inspiron N5110 with Core i5 (2.30 Ghz + 4 GB RAM) and this sluggish performance of java on linux compared to windows breaks my heart. Any suggestions why JVM is eating up the CPU?
has answer: http://stackoverflow.com/a/21557167
has title: Eclipse/Java always beyond 100% CPU usage in OpenSuse 12.2
has answer: http://stackoverflow.com/a/21556926

http://stackoverflow.com/a/21667305
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21638322
type: Answer
has body: The exception that you claimed didn't happen will almost certainly be due to a ClassNotFoundException mentioning the remote interface or the stub, or a class that they depend on. When you call list() you're only retreiving Strings, not the class of the object, so there is no exception. list() and lookup() both tell you whether the object is currently bound in the Registry. That doesn't by itself mean that the object still exists. You would have to execute a remote method on it to know that; and for that you would need the missing class(es).
has comment: http://stackoverflow.com/comment/32751567
accepted answer of: http://stackoverflow.com/q/21638322
score: 0

openide
type: Tag
tag name: openide
tags question: http://stackoverflow.com/q/21627164

javacv
tags question: http://stackoverflow.com/q/21670225
tags question: http://stackoverflow.com/q/21571761
tag name: javacv
type: Tag

http://stackoverflow.com/q/21653323
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21653642
downvote count: 1
has answer: http://stackoverflow.com/a/21653403
has body: Does anyone know how I would go about creating an application that will go through a comma separated file (CSV) and organize that information and subsequently put that into a database? For example, I have to go through a file that looks like this: Name of Athlete, Birthday, Salary($) John Morris, 9/25/1991, 5000000 Mike Hawk, 2/2/1988, 1000000 Dewayne Johnson, 11/22/1985, 4000000 etc. How would I organize this information and set it up? I am trying to make it so I can ask the user for input. For example: have the user enter "a" for amount of salary and output all the players who make that EXACT amount of money. Player 1 name, Player 1 birthday Player 2 name, Player 2 birthday Any help is appreciated. I would appreciated help with reading the information and storing/retrieving it. Don't give me the complete answer. I am a student learning this and I want to understand it.
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32726898
has comment: http://stackoverflow.com/comment/32744297
type: Question
has title: How do I parse through a CSV (comma separated file) and display output
tagged with: arrays
has answer: http://stackoverflow.com/a/21653397
favorite count: 0
has comment: http://stackoverflow.com/comment/32726655
answer count: 3
tagged with: http://stackoverflow.com/tag/csv
has comment: http://stackoverflow.com/comment/32726683
upvote count: 2

http://stackoverflow.com/a/21666929
type: Answer
answers question: http://stackoverflow.com/q/21666870
score: 4
upvote count: 4
has body: Enclose your if statements in braces if (e.getSource() == b2) { input.setText(""); output.setText(""); } otherwise the second statement will always be executed in the ActionListener
downvote count: 0

http://stackoverflow.com/comment/32493332
has text: I don't know if this is your complete code, but if it is, the `s.filter()` call effectively does nothing. This is a lazy, intermediate operation. The stream won't actually do anything until you add a terminal operation. See the `java.util.stream` class documentation.
score: 1
comment on: http://stackoverflow.com/q/21520380
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21572601
answer count: 1
has answer: http://stackoverflow.com/a/21572818
type: UnansweredQuestion
tagged with: android
has title: Android GridLayout, Checkbox and spinners
tagged with: java
type: Question
has body: I am looking for information about GridLayout, I create a Grid layout with Column : layout2 = new GridLayout (this); layout2.setColumnCount (2); But I wonder how to manage the size of the Column, as premierre is too large compared to the second. In addition I also asked about the Checkbox and spinners, you can increase their size?
score: 0
has comment: http://stackoverflow.com/comment/32585385

http://stackoverflow.com/comment/32487391
type: Comment
has text: thanks a lot @user3088847! looks like the error was in printing the parent node only and not in adding it.
comment on: http://stackoverflow.com/a/21517182
type: AnswerComment
score: 0

http://stackoverflow.com/comment/32576155
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21550916
has text: 1) For better help sooner, post a [Minimal Complete Tested and Readable Example](http://stackoverflow.com/help/mcve) (MCTRE). 2) One way to get image(s) for an example is to hot-link to the images seen in [this answer](http://stackoverflow.com/a/19209651/418556).

http://stackoverflow.com/comment/32527910
comment on: http://stackoverflow.com/a/21536553
type: AnswerComment
score: 0
type: Comment
has text: Perhaps I'm not sure how to do this the correct way, then. As I've said: this is the obvious solution, but whenever I've tried it it just... didn't work for me. Can you point me to somewhere I can reference for something like this perhaps? If you can I'll accept this answer.

http://stackoverflow.com/a/21585377
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/21584849
downvote count: 0
score: 1
has body: I suggest to use a helper boolean array to keep track of which numbers were already added to the array. Review this code, it is short and concise: boolean[] used = new boolean[2000]; int[] randomUniqueIntegers = new int[SIZE]; for (int i = 0; i &lt; SIZE; i++) { int num = (int) (Math.random() * 1999); if (!used[num]) { used[num] = true; randomUniqueIntegers[i] = num; } else { while (used[num]) { num = (int) (Math.random() * 1999); if (!used[num]) { used[num] = true; randomUniqueIntegers[i] = num; break; } } } } As you see the implementation above doesn't use Set or shuffling. However, you can use the test code below to see it works correctly. Set&lt;Integer&gt; set = new HashSet&lt;Integer&gt;(); for (int i : randomUniqueIntegers) set.add(i); System.out.println(set.size()); You will see that the size of the set is equal to SIZE constant in each run which indicates we have all unique elements in our array.
has comment: http://stackoverflow.com/comment/32607958
has comment: http://stackoverflow.com/comment/32608013

http://stackoverflow.com/q/21623066
answer count: 1
downvote count: 0
score: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/32673434
has comment: http://stackoverflow.com/comment/32673425
has body: I have an application in which I want to include a button for clearing all the browsers cache including default browser, or is it possible to clear cache of all the applications instead (via deleting the folders)? How can this be achieved via button click?
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/3774161
tagged with: android
linked to: http://stackoverflow.com/q/6898090
tagged with: java
has title: How to clear Browser Cache?
has comment: http://stackoverflow.com/comment/32674549
upvote count: 1
tagged with: caching
type: Question
has comment: http://stackoverflow.com/comment/32675144
has answer: http://stackoverflow.com/a/21623192

http://stackoverflow.com/comment/32703136
has text: I want each number separate, so say 0.0054 would be a double while 5 and 10 would be made an int
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21639577
score: 0

http://stackoverflow.com/q/21576564
has comment: http://stackoverflow.com/comment/32591911
type: Question
linked to: http://stackoverflow.com/q/3874894
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/21576991
accepted answer: http://stackoverflow.com/a/21576991
answer count: 2
possible better answer: http://stackoverflow.com/a/21576976
has body: I'm trying to get some runtime information to do some debugging. Is there a way to access the parameters actually passed to a method? I know the calling class and method, but not the parameters and their value at runtime. Any Ideas how to solve this? Thanks in advance. My code so far: //get the class I wanna know something about out of the call history StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace(); String callerMethod = stacktrace[2].getMethodName(); //load the class to get the information Class&lt;?&gt; c = Class.forName(stacktrace[2].getClassName()); Method[] methods = c.getMethods(); Class&lt;?&gt;[] parameters = methods[1].getParameterTypes(); //get the parameter data (parameters[y].isArray()? parameters[y].getComponentType() : parameters[y]).getName(); //TODO: how about the parameter value at runtime? The code has to be generic for all Classes I will implement. Example of usage: public class doClass() { public void doSomething(Object o) { //here comes my debug line magicDebugger(level); } } level is the switch/trigger to activate console/db/file/mail output or whatever of some information I expect following output (maybe there's some System.out.println in the magicDebugger class): [debug] caller: com.company.package.doClass.doSomething(Object o); value of o at runtime = java.lang.String "test"
upvote count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/99749933
has answer: http://stackoverflow.com/a/21576976
linked to: http://stackoverflow.com/q/4943612
has title: How to get the parameter values of a called method in java?
has comment: http://stackoverflow.com/comment/32592400
type: AnsweredQuestion
downvote count: 0
tagged with: reflection
duplicate of: http://stackoverflow.com/q/3874894

http://stackoverflow.com/q/21670252
has title: Android How to use a Text Input in Canvas.drawColor
answer count: 1
tagged with: string
type: UnansweredQuestion
tagged with: android
has body: I have two questions you might be able to help me with, I am new at programming and this might be really easy but I looked for the answers for a couple of days and have not been able to get them. I am doing a simple android application in which you enter a hexadecimal number in a plain text field and when you click on a button a canvas gets created and you see the color from that hexadecimal number in the canvas (ex:0xff000000 you would get black) unfortunately I am not able to use the string as an integer variable into the Canvas.drawcolor(), can someone tell me how can I do this correctly, and/or why what I am doing is wrong? My second question is how can I make the canvas appear without making my button and text field disappear from the layout when it gets created? Here is my code, I created the toast to see if I was getting the string correctly: public class MainActivity extends Activity implements TextWatcher{ private Bitmap mBitmap; private Canvas mCanvas; private ImageView mImageView; private EditText mHexadecimal; private String comments; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mHexadecimal = (EditText) findViewById(R.id.Hexadecimal); mHexadecimal.addTextChangedListener(this); } public void onClick(View v) { mBitmap = Bitmap.createBitmap(300, 300, Bitmap.Config.ARGB_8888); mCanvas = new Canvas(mBitmap); comments = mHexadecimal.getText().toString(); Toast.makeText(getApplicationContext(), comments,Toast.LENGTH_LONG).show(); mCanvas.drawColor(Integer.parseInt(comments,16)); mImageView = new ImageView(this); mImageView.setImageBitmap(mBitmap); setContentView(mImageView); }
tagged with: java
tagged with: eclipse
type: Question
tagged with: android-canvas
has answer: http://stackoverflow.com/a/21671070
score: 0

http://stackoverflow.com/a/21607436
has comment: http://stackoverflow.com/comment/32645844
score: 4
has comment: http://stackoverflow.com/comment/32646152
upvote count: 4
has body: It's a JPanel. It provides means for visually structuring elements into box-like containers. You can find more information on how to effectively use and style them here. EDIT: Since you seem to be more interested in the style of the border than the name of the component being used in the example above here's a snippet using the border style on a panel. import javax.swing.*; public class MyPanelTestDrive{ public static void main(String [] args){ JFrame myFrame = new JFrame("Panel Test Drive"); myFrame.setSize(800,600); JPanel myPanel = new JPanel(); myPanel.setBorder(BorderFactory.createTitledBorder("Panel Title")); myFrame.add(myPanel); myFrame.setVisible(true); } }
has comment: http://stackoverflow.com/comment/32645918
downvote count: 0
has comment: http://stackoverflow.com/comment/32646088
answers question: http://stackoverflow.com/q/21607385
type: Answer

http://stackoverflow.com/a/21582123
accepted answer of: http://stackoverflow.com/q/21581311
score: 3
has comment: http://stackoverflow.com/comment/32631840
has comment: http://stackoverflow.com/comment/32630605
has comment: http://stackoverflow.com/comment/32631341
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32611511
downvote count: 0
has comment: http://stackoverflow.com/comment/32633179
type: Answer
answers question: http://stackoverflow.com/q/21581311
has body: So first one: Bit Shifting I guess you've heard about binary numbers. Most people nowadays use the decimal number system in our day-to-day business, where you have digits ranging from 0-9. Every number you use is made up of digits from 0-9. The binary system only uses the digits 0 and 1, which is very convenient for computer to use since then you can represent numbers with power easily: 0 = no power 1 = power Same as the decimal number system you can make larger numbers just by putting digits next to each other: in decimal 10 is 9+1. In binary 10 is 1+1. Binary = Decimal 0 = 0 1 = 1 10 = 2 11 = 3 100 = 4 101 = 5 110 = 6 111 = 7 and so on. Computers usually work with fixed-length numbers (at least with integer-type nubers, like int, long, short, byte, ...), so they fill all remaining digits on the left with 0: 5 in decimal = 101 in binary = 00000101 in 8-bit (byte) = 0000000000000101 in 16-bit (short) and so on. What bit shifting does is it moves all bits into one direction: Right-Shift by two digits: 00001101 &gt;&gt; 2 = 00000011 Left-Shift by three digits: 00001101 &lt;&lt; 3 = 01101000 A left shift is equivalent to multiplying by 2 while a right shift equivalent to dividing by 2 (talking about positive numbers here, since negative numbers are a bit different). Now to the second one: Masking This is now about this part: sData[i] &amp; 0x00FF At first, here we have another numbers notation: the hexadecimal numbers. It works quite similarly as the binary numbers just now there are 16 different digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. Each of them stands for four digits in binary, so you can convert between the two by just replacing each digit by the following digits: Hex = Binary 0 = 0000 1 = 0001 2 = 0010 3 = 0011 4 = 0100 5 = 0101 6 = 0110 7 = 0111 8 = 1000 9 = 1001 A = 1010 B = 1011 C = 1100 D = 1101 E = 1110 F = 1111 So the number given here as 0x00FF equals 0000000011111111 in 16-bit binary. Now to the &amp;, or the actual masking. The &amp;-Operator returns 1 …
upvote count: 3

http://stackoverflow.com/comment/32495906
comment on: http://stackoverflow.com/q/21522589
has text: HelloService extends Service?. post the manifest and the code
score: 1
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32672940
type: QuestionComment
has text: @dev_feed the orientation is 'landscape', pixelFoot is a variable that I recieve from another activity and get the pixels distance of one stride.
comment on: http://stackoverflow.com/q/21602092
score: 0
type: Comment

http://stackoverflow.com/q/21523195
has answer: http://stackoverflow.com/a/28864504
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/45992650
tagged with: java
has comment: http://stackoverflow.com/comment/32785626
has comment: http://stackoverflow.com/comment/33859521
has comment: http://stackoverflow.com/comment/45994428
type: Question
upvote count: 2
answer count: 2
has body: I am trying to query my (GAE Java) datastore's text field and expecting results including partial matches. For example, results for the search string "test" should include "test, test1, more tests, etc". Below is the Java code snippet I am using. DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); Filter testFilter = new FilterPredicate("test", FilterOperator.GREATER_THAN_OR_EQUAL, testStr); Query testQuery = new Query("testEntity").setFilter(testFilter); List&lt;Entity&gt; testResults = datastore.prepare(testQuery).asList(FetchOptions.Builder.withLimit(100)); My test results are totally irrelavant. I am new to GAE and Java and I am sure I am not on the right track. I have searched for the right approach in SO and other sites and found solutions for Python, but couldn't find any for Java. The Java examples I came across are all using queries with integer values. Please suggest.
tagged with: google-cloud-datastore
has answer: http://stackoverflow.com/a/21523390
accepted answer: http://stackoverflow.com/a/21523390
favorite count: 0
has title: Partial text search in GAE datastore (Java)
has comment: http://stackoverflow.com/comment/32796862
tagged with: google-app-engine
score: 2
possible better answer: http://stackoverflow.com/a/28864504
downvote count: 0

http://stackoverflow.com/q/21531860
score: 2
answer count: 1
has comment: http://stackoverflow.com/comment/32512638
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/32512737
has body: Given a "save" method in a Spring-MVC controller: @RequestMapping(value = "/save") public void save(@ModelAttribute(MY_KEY) final MyModel myModel) { ... } with a property in the myModel parameter that is an abstract class: public class MyModel { public AbstractFruit fruit; } Is there any way of specifying use of a particular subclass (e.g. Apple) in the request?
tagged with: binding
has answer: http://stackoverflow.com/a/43393430
tagged with: spring-mvc
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32512700
upvote count: 2
tagged with: java
accepted answer: http://stackoverflow.com/a/43393430
has comment: http://stackoverflow.com/comment/32512841
has title: How to bind a subclass of an abstract class in a Spring-MVC method?
type: Question
has comment: http://stackoverflow.com/comment/32512912
tagged with: controller
tagged with: abstract-class

http://stackoverflow.com/q/21602667
upvote count: 3
tagged with: java
has comment: http://stackoverflow.com/comment/32639190
has comment: http://stackoverflow.com/comment/92067480
linked to: http://stackoverflow.com/q/19418500
type: Question
score: 3
has answer: http://stackoverflow.com/a/21604060
tagged with: hibernate
possible better answer: http://stackoverflow.com/a/21604750
has answer: http://stackoverflow.com/a/21604750
has title: Get physical column value with entity property value using hibernate
answer count: 2
tagged with: sql
has comment: http://stackoverflow.com/comment/32643052
downvote count: 0
has comment: http://stackoverflow.com/comment/32790203
favorite count: 0
has comment: http://stackoverflow.com/comment/32639375
accepted answer: http://stackoverflow.com/a/21604060
type: AnsweredQuestion
has body: I have a table T with columns defined as usual. @Entity @Table(name="T") public class T { @Column(name="test_id") private Long testId; } Given entity property "testId", I want to get corresponding DB column name (i.e. "test_id"). How could it be achieved? Edit 1: I want to keep this column at separate location with actual DB column name (test_id) than testId. I fetched these values from DB using HQL which have key as entity name (i.e. testId) and I want actual column name in DB.

http://stackoverflow.com/a/21647200
has comment: http://stackoverflow.com/comment/32722575
answers question: http://stackoverflow.com/q/21647095
score: 0
has body: Google's Guava library makes such operations trivial. You can find out more in the documentation here: http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/io/Files.html.
type: Answer

http://stackoverflow.com/q/21641542
type: Question
has answer: http://stackoverflow.com/a/21641556
accepted answer: http://stackoverflow.com/a/21641556
has comment: http://stackoverflow.com/comment/32706472
tagged with: jpanel
has comment: http://stackoverflow.com/comment/32706517
tagged with: random
upvote count: 1
has body: I am trying to make a small version of a slot machine. I am using five JPanels. Four of the JPanels will hold random shapes like a square, circle, and oval. If all four of the JPanels are displaying a square then the fifth JPanel should display JackPot and if any other combination is displayed then the fifth JPanel should say try again. The problem I am having is making the fifth JPanel display a message when the user wins or loses. I am able to draw the shapes randomly on the JPanels but the problem I am having is making the paint method draw in a specific JPanel. When I run the code a random shape appears on every JPanel but I only want the shapes to appear on four JPanels instead of all five. import javax.swing.*; import java.awt.*; import java.util.Random; public class JackPot extends JPanel { public JackPot(Color backColor) { setBackground(backColor); } public void paintComponent(Graphics g) { super.paintComponent(g); Random gen = new Random(); int a = gen.nextInt(10); if (a &lt;= 3) { g.drawOval(20,20,25,25); } else if (a &gt; 3 &amp;&amp; a &lt;= 6) { g.drawRect(20,20,25,10); } else { g.drawOval(20,20,20,10); } } public static void main(String[] args) { JFrame GUI = new JFrame(); GUI.setTitle("JackPot"); GUI.setSize(500, 400); Container pane = GUI.getContentPane(); pane.setLayout(new GridLayout(5, 1)); JackPot panel = new JackPot(Color.red); JackPot panel2 = new JackPot(Color.white); JackPot panel3 = new JackPot(Color.yellow); JackPot panel4 = new JackPot(Color.green); JackPot panel5 = new JackPot(Color.pink); pane.add(panel); pane.add(panel2); pane.add(panel3); pane.add(panel4); pane.add(panel5); GUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GUI.setVisible(true); } }
answer count: 1
favorite count: 0
has title: How do i draw random shapes in different JPanels in Java
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
tagged with: swing

http://stackoverflow.com/comment/32631666
type: QuestionComment
comment on: http://stackoverflow.com/q/21597759
score: 0
type: Comment
has text: I have no Problem to Order My Query "Normal". Like: "SELECT x from PersonDetail1 x ORDER BY x.id asc... But how to Order a List inside a List?

http://stackoverflow.com/comment/32487891
type: Comment
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/21517687
has text: I suggest that you debug your code and go step by step to see what is going on.

http://stackoverflow.com/a/21678037
has body: What i have understood from your statement is that you need exact 4 players to decide game's outcome. each player passes a number while connecting to server and he/she is not allowed to enter or pass anything more. so the shared resources are TOTAL SUM and NUMBER OF CONNECTION and thread is connection to server. So whenever a player requests to connect you, start a new thread and this thread increment the shared TOTAL SUM and NUMBER OF CONNECTION and after incrementing also check the value of total sum and no. of connection.
score: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32770044
type: Answer
answers question: http://stackoverflow.com/q/21677743
accepted answer of: http://stackoverflow.com/q/21677743
has comment: http://stackoverflow.com/comment/32769640

http://stackoverflow.com/comment/32746765
has text: In this of the calculate method, I would simply skip an null values, as they can't be included in the tally. You should place the summing of the total instead the not null if statement
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/21664077
type: Comment

http://stackoverflow.com/comment/32618865
comment on: http://stackoverflow.com/a/21591239
has text: rather than bring the code down to a lower level, what say we elevate your understanding of the code to a higher level? My original answer linked the `HashMap` reference to the java class definition page. I've edited it so that it now links to the oracle tutorials page for the `Map` interface.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/21530721
has comment: http://stackoverflow.com/comment/32510508
has comment: http://stackoverflow.com/comment/32510677
accepted answer of: http://stackoverflow.com/q/21530642
answers question: http://stackoverflow.com/q/21530642
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32510479
has comment: http://stackoverflow.com/comment/32510957
type: Answer
has comment: http://stackoverflow.com/comment/32510501
has body: Your if condition seems to be wrong... This is how it should be. if (dateString.length() != "dd/MM/YYYY".length()) return false; if input date is 22/07/1986 obviously it's length will be more than length of ddMMYYYY because of missing slashes. df.setLenient(false); Will ensure that it won't roll over for invalid dates. Just put thiss line after you created df object.
score: 2
upvote count: 2

http://stackoverflow.com/q/21641805
tagged with: java
type: Question
has body: I have some instance fields in an Android activity that I initialize on onCreate, and then just use everywhere else within the activity. But, sometimes (very rarely, once every few thousand uses) this instance field is null on onResume, leading to an immediate NullPointerException. Here's a very simple working example: class Foo { } class CrashingActivity extends Activity { private Foo foo; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); foo = new Foo(); } @Override protected void onResume() { super.onResume(); Log.i("CrashingActivity", "Foo: " + foo); // CRASH! } } I don't think we need to use onPause or onSaveInstanceState, right? Why is this crash happening?
downvote count: 0
favorite count: 0
tagged with: onresume
tagged with: android
score: 2
answer count: 0
upvote count: 2
type: UnansweredQuestion
tagged with: android-lifecycle
has title: Rare occurrence: Instance fields not initialized on onResume in an Android activity

http://stackoverflow.com/q/21639283
type: AnsweredQuestion
upvote count: 2
score: 1
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has body: What would be the easiest way to load a file containing JSON into a JSONObject. parsing a file into a JSONObject - w/o the intermittent String object (arguably memory wasting) This is what I have, but it throws an exception: public class AlphabetGestures { private Map&lt;Character,Vector&lt;Point&gt;&gt; mMap; public AlphabetGestures(String jsonFileName) throws JSONException { mMap = new HashMap&lt;Character,Vector&lt;Point&gt;&gt;() ; // parsing a file into a JSONObject - w/o the intermittent String object (arguably memory wasting) File f = new File(jsonFileName); // making File object for .json file. JSONObject masterJSON = new JSONObject(f.toString()); // giving .json file string to jsonvalue parser JSONArray characters = masterJSON.names(); for ( int c = 0; c &lt; characters.length(); c++ ) { // this loop will get each object from jsonArr String character = characters.getString(c); JSONArray pointsJSON = masterJSON.getJSONArray(character); // this will get each element from jsonarray and make subarray for (A, B C ... ) Vector&lt;Point&gt; pointsVector = new Vector&lt;Point&gt;(); for ( int i = 0; i &lt; pointsJSON.length(); i++ ) { JSONArray point = pointsJSON.getJSONArray(i); pointsVector.add(new Point(point.getInt(0), point.getInt(1))); } mMap.put(character.charAt(0), pointsVector); // put pointVector in mMap with key temp. } } public void scribble(char letter, UiDevice uiDevice){ //System.out.println("here"); //AlphabetGestures Y = new AlphabetGestures() ; Vector&lt;Point&gt; points = mMap.get(letter) ; System.out.println("------------------"); System.out.println(points); if(points!=null){ uiDevice.swipe(points.toArray(new Point[points.size()]), 5); } } Output:- while running the test case Error in testAccordion: java.lang.NoSuchMethodError: ionmini.automate.AlphabetGestures.&lt;init&gt; at ionmini.automate.AccordionDrag.testAccordion(AccordionDrag.java:33) at java.lang.reflect.Method.invokeNative(Native Method) at com.android.uiautomator.testrunner.UiAutomat…
tagged with: android-uiautomator
downvote count: 1
type: Question
accepted answer: http://stackoverflow.com/a/21639637
has comment: http://stackoverflow.com/comment/32703581
linked to: http://stackoverflow.com/q/7463414
duplicate of: http://stackoverflow.com/q/7463414
has title: reading JSONObject from JSON file
has comment: http://stackoverflow.com/comment/32703149
has comment: http://stackoverflow.com/comment/32702891
has comment: http://stackoverflow.com/comment/32703176
has comment: http://stackoverflow.com/comment/32703682
answer count: 1
has comment: http://stackoverflow.com/comment/32703044
favorite count: 0
tagged with: android
has answer: http://stackoverflow.com/a/21639637
has comment: http://stackoverflow.com/comment/32702985

http://stackoverflow.com/a/21583973
has body: ParseRole is a term used to define the role a User has, that is, what objects it can access. It is used in conjunction with ACLs (Access Control Lists) to add a layer of data security, ensuring only valid users access it. Imagine a game whose backend is provided by Parse, this game has user generated levels and there's a group of players denoted "moderators". Moderators can delete other's levels if it breaks the game's rules. You only want them to be able to delete any level, so you create a role named moderator and assign delete permissions to it in the Level class' ACL. ParseRelation, in the other hand, is a many-to-many relation between any kind of object.
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32608104
has comment: http://stackoverflow.com/comment/32606130
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/32608142
upvote count: 2
has comment: http://stackoverflow.com/comment/32616114
accepted answer of: http://stackoverflow.com/q/21582767
has comment: http://stackoverflow.com/comment/32606544
has comment: http://stackoverflow.com/comment/32606741
answers question: http://stackoverflow.com/q/21582767

http://stackoverflow.com/a/21584208
has comment: http://stackoverflow.com/comment/32607434
upvote count: 1
has comment: http://stackoverflow.com/comment/33039988
type: Answer
downvote count: 0
has body: I don't think you can change the value of input attribute dynamically. When your form is submitted and fails validation, it gets redirected to the page defined in the "input" attribute. I don't see the need to change the "input" attribute dynamically. When the validation fails, you can redirect it back to the same page, where the user inputs data, with error message showing the invalid fields. You can see this kind of behavior in any "Registration/Login" page of a website, when you enter invalid data. EDIT This is a work around. Set validate="false" in your mapping file. And call the validation method from your action class. You can also change the return type of the validate method to fit your need(for eg to a string). So in your action class depending on the value returned by the validate method you can create different urls and forward it there: public class MyAction extends DispatchAction{ public ActionForward add(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, ActionMessages messages) throws Exception MyForm myForm = (MyForm) form; String url=""; String result = form.validate(); if(result.equals("something")){ url="book.do?op=add&amp;id=" + book.getId(); }else if(result.equals("somethingElse"){ url="book.do?op=edit&amp;id=" + book.getId(); } RequestDispatcher rd = request.getSession().getServletContext().getRequestDispatcher(url); rd.forward(request, response); }
answers question: http://stackoverflow.com/q/21561576
score: 1

http://stackoverflow.com/a/21609542
type: Answer
has comment: http://stackoverflow.com/comment/32649989
answers question: http://stackoverflow.com/q/21605803
has body: What is exactly failing? Is there an error message "testtable doesn't exist"? Then your program closes the connection after each request. Is the table empty when you do the SELECT? Then you forgot to add ON COMMIT PRESERVE ROWS to the CREATE.
upvote count: 1
downvote count: 1
score: 0
has comment: http://stackoverflow.com/comment/32649889
has comment: http://stackoverflow.com/comment/32649542

http://stackoverflow.com/q/21627048
upvote count: 2
type: UnansweredQuestion
score: 2
tagged with: java
has body: Is there a library that will allow me to easily convert the java type XMLGregorianCalander to Epoch time (The number of seconds since 01-01-1970 00:00:00?)? Or any other fixed integer for that matter? If not, is there some neat, boiler plate code to do this? This seems like too common a use case to be writing from scratch... Thank you very much for your answers.
type: Question
has answer: http://stackoverflow.com/a/21627458
answer count: 1
downvote count: 0
has title: How to convert XMLGregorianCalander to Epoch-Time or other fixed integer ?
favorite count: 0

union
type: Tag
tag name: union
tags question: http://stackoverflow.com/q/21519007

http://stackoverflow.com/a/21602352
type: Answer
has body: You haven't created any tables in your database! Have a look at this to see the create table statements and where they are executed. Similar question
score: 0
answers question: http://stackoverflow.com/q/21602183

http://stackoverflow.com/comment/32579793
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21569350
has text: Thanks guys. and sorry about that. I'm totally new to this. but can one of explain me how to do it?
score: 0

http://stackoverflow.com/comment/32733462
comment on: http://stackoverflow.com/q/21657220
type: Comment
type: QuestionComment
has text: @ElhadiMamoun: in 'project1Tester' class
score: 1

http://stackoverflow.com/q/21523794
type: AnsweredQuestion
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/21553260
upvote count: 1
type: Question
has title: Invoking Interceptors through StrutsSpringTestCase in Struts2 + Spring project
tagged with: struts2
has body: The requirement of Test case through StrutsSpringTestCase is: If i call any method of Action class then the interceptors, Validate, prep and prepare methods should be called automatically. In real scenario only the method, which i am calling through proxy object, is called. I have added code snippet below. import org.apache.struts2.StrutsSpringTestCase; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.opensymphony.xwork2.ActionProxy; @ContextConfiguration(locations = { "classpath:test-applicationContext.xml", "classpath*:applicationContext.xml" }) @RunWith(SpringJUnit4ClassRunner.class) public class TestMyProfilePage extends StrutsSpringTestCase { @Test public void testExecute() throws Exception { ActionProxy proxy = getActionProxy("/secure/profile_process.action"); ProfileAction profileProxy = (ProfileAction) proxy.getAction(); profileProxy.setAppointmentDateCode("09/27/2011:D:8AM-12PM"); String result = profileProxy.execute(); assertEquals(result, "success"); } } Please help me out.
downvote count: 0
answer count: 1
has answer: http://stackoverflow.com/a/21553260
favorite count: 0
tagged with: spring

http://stackoverflow.com/comment/32627570
has text: There is no parent in memory...
comment on: http://stackoverflow.com/q/21596670
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32694422
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21633246
has text: That's correct, in the end it's all up to the hardware and the OS. But it's the only way to go. I mean: blocking won't be faster, right?
type: Comment

http://stackoverflow.com/a/58044583
has body: I really like using form:xxxx instead of the more traditional tags. However, it seems to work best with PUT requests where I am modifying something, and maybe DELETE. With POST where everything is new, I tend to end up using the traditional tags. It does link the human readable to the value being sent for automated readers, but both can do that.
answers question: http://stackoverflow.com/q/21593988
upvote count: 1
type: Answer
downvote count: 0
score: 1

http://stackoverflow.com/comment/32613022
score: 0
has text: Good catch. Not quite sure what I was thinking there. Adding 1 to the end of that value should rectify that.
type: Comment
comment on: http://stackoverflow.com/a/21587978
type: AnswerComment

http://stackoverflow.com/comment/32497185
type: Comment
has text: could you explain you steps of creating new Project.
type: QuestionComment
comment on: http://stackoverflow.com/q/21523299
score: 1

http://stackoverflow.com/q/21605904
linked to: http://stackoverflow.com/q/1372599
possible better answer: http://stackoverflow.com/a/41011957
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/41011957
tagged with: java
accepted answer: http://stackoverflow.com/a/21605919
type: Question
answer count: 2
has body: hi all i have gone through many thread and i found the way but don't know how to fit in my string please give me regexpattern to solve this. input: String [200,350,500] output: String{"200","350","500"} one of the article where i found something: How to convert a String into an array of Strings containing one character each
tagged with: string
score: 0
has title: How to convert String to String Array
has answer: http://stackoverflow.com/a/21605919

http://stackoverflow.com/q/21592717
favorite count: 0
tagged with: jarsigner
has title: is there any pure-java or standalone deployable implementation of jarsigner?
upvote count: 1
type: AnsweredQuestion
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/41614351
type: Question
answer count: 2
has body: I've seen a lot of questions here asking how to deploy an app with jarsigner but without a full JDK. Also some people ask how to programatically do jarsigner tasks. I was wondering if there is any pure-java implementation of jarsigner or even some standalone and alternate implementation of it, easier to deploy with apps. (of course, I know that you could just force the user to install a full JDK in the installation process or require an installed JDK) So my question is if there is such a thing like an alternate jarsigner. If any good soul could also explain why jarsigner must be always native (because java can be decompiled?), it would be a plus :-)
downvote count: 0
has answer: http://stackoverflow.com/a/21593557
accepted answer: http://stackoverflow.com/a/21593557
possible better answer: http://stackoverflow.com/a/41614351

http://stackoverflow.com/q/21605068
downvote count: 0
tagged with: application-server
tagged with: tomcat
has comment: http://stackoverflow.com/comment/97339333
favorite count: 0
score: 9
type: Question
accepted answer: http://stackoverflow.com/a/21606506
has body: So, after several years using Eclipse I finally decided to give IntelliJ a chance (ultimate edition). I added the tomcat server in the file->settings... option. The tomcat integration plugin is also enabled in the plugin list. Hitting Control + Shift + A and typing "Application Servers" will show me a "disabled" option. The same happens in the View menu. So, how can I enable the tab, deploy and manage my web apps? Thanks :)
has title: Application servers tab not enabled in Intellij ultimate edition
tagged with: java
answer count: 2
upvote count: 9
tagged with: intellij-idea
has answer: http://stackoverflow.com/a/69819527
tagged with: eclipse
has answer: http://stackoverflow.com/a/21606506
possible better answer: http://stackoverflow.com/a/69819527
type: AnsweredQuestion

http://stackoverflow.com/q/21635928
tagged with: volume
has answer: http://stackoverflow.com/a/21636125
has title: Getting the current master volume in Java
upvote count: 1
type: Question
has body: I have Clip plaiong on my app and I'd like to get either the master volume or the volume of the Clip that is playing. Here's the code where i play the audio: AudioInputStream ais = AudioSystem.getAudioInputStream(new File("src/music/music.wav")); Clip clip = AudioSystem.getClip(); clip.open(ais); clip.start(); clip.loop(-1);
has comment: http://stackoverflow.com/comment/32696591
tagged with: java
answer count: 1
has comment: http://stackoverflow.com/comment/32696723
downvote count: 0
has comment: http://stackoverflow.com/comment/32697149
score: 1
favorite count: 0
tagged with: javasound
type: UnansweredQuestion

http://stackoverflow.com/a/22278250
upvote count: 7
has body: Same problem in 4.3.4.Final. Now after adding following code, the problem is gone. public class Service { private SessionFactory factory; private ServiceRegistry serviceRegistry; public void initialize() throws Exception{ Configuration configuration = new Configuration(); configuration.configure("com/jeecourse/config/hibernate.cfg.xml"); serviceRegistry = new StandardServiceRegistryBuilder().applySettings( configuration.getProperties()).build(); factory = configuration.buildSessionFactory(serviceRegistry); } public void close() throws Exception{ if(serviceRegistry!= null) { StandardServiceRegistryBuilder.destroy(serviceRegistry); } } .....
score: 7
answers question: http://stackoverflow.com/q/21645516
downvote count: 0
type: Answer

http://stackoverflow.com/comment/32630218
comment on: http://stackoverflow.com/q/21597840
score: 0
has text: @ejp. yes ..But After forcing through the tool also why it is not releasing memory in my 1st case when I am not disposing the listener
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32664362
comment on: http://stackoverflow.com/a/21616095
score: 0
type: Comment
has text: Then how would I go about getting it to work on subsequent attempts?
type: AnswerComment

http://stackoverflow.com/a/21570676
has comment: http://stackoverflow.com/comment/32629547
has comment: http://stackoverflow.com/comment/32584152
upvote count: 1
answers question: http://stackoverflow.com/q/21570520
score: 1
has body: Go to Window - Preferences - General - Keys, as you did, and order the shortcuts by Binding. Be patient and look for Ctrl+Shift+I and Ctrl+I, they are there. The first one is Inspect and the other is Indent Line, Correct Indentation or Format Active Elements, depending on the editor you are in. These are the default shortcuts and you could change them. Hope this helps you.
has comment: http://stackoverflow.com/comment/32583776
downvote count: 0
type: Answer

http://stackoverflow.com/q/21525280
has comment: http://stackoverflow.com/comment/32536911
has title: MyFaces hellow world application give NullPointerException error
type: AnsweredQuestion
score: 3
tagged with: facelets
tagged with: jsf
has comment: http://stackoverflow.com/comment/32542670
upvote count: 3
tagged with: java
has body: I am a beginner with Java (as in 2 weeks of reading), and I would like to learn more by using a project created with Eclipse IDE. What I am using: - Java JDK 1.7 - Eclipse IDE Juno - Maven latest version - JBoss (7.1.1, 6.2 EAP, WidlFly) - all have the same behaviour - A maven project created with Maven archetype: myfaces-archetype-helloworld-facelets. When trying to run, I receive a java.lang.NullPointerException in page. The log from JBoss is showing: 12:25:58,890 INFO [org.apache.catalina.core] (ServerService Thread Pool -- 33) JBWEB001093: The listener org.apache.myfaces.webapp.StartupServletContextListener is already configured for this context, the duplicate definition has been ignored 12:25:58,907 INFO [org.apache.myfaces.shared_impl.config.MyfacesConfig] (ServerService Thread Pool -- 33) No context init parameter 'org.apache.myfaces.RENDER_VIEWSTATE_ID' found, using default value true 12:25:58,907 INFO [org.apache.myfaces.shared_impl.config.MyfacesConfig] (ServerService Thread Pool -- 33) No context init parameter 'org.apache.myfaces.STRICT_XHTML_LINKS' found, using default value true 12:25:58,907 INFO [org.apache.myfaces.shared_impl.config.MyfacesConfig] (ServerService Thread Pool -- 33) No context init parameter 'org.apache.myfaces.CONFIG_REFRESH_PERIOD' found, using default value 2 12:25:58,907 INFO [org.apache.myfaces.shared_impl.config.MyfacesConfig] (ServerService Thread Pool -- 33) No context init parameter 'org.apache.myfaces.VIEWSTATE_JAVASCRIPT' found, using default value false 12:25:58,908 INFO [org.apache.myfaces.shared_impl.config.MyfacesConfig] (ServerService Thread Pool -- 33) Starting up Tomahawk on the MyFaces-JSF-Implementation 12:25:58,919 INFO [org.apache.myfaces.config.FacesConfigurator] (ServerService Thread Pool -- 33) Reading standard config META-INF/standard-faces-config.xml 12:25:58,972 INFO [org.apache.myfaces.config.FacesConfigurator] (ServerService Thread Pool -- 33) Reading config vfs:/D:/JBoss/jboss-eap-6.2/standalone/deploymen…
type: Question
accepted answer: http://stackoverflow.com/a/21549299
possible better answer: http://stackoverflow.com/a/46422794
has answer: http://stackoverflow.com/a/46422794
answer count: 2
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/32542802
has answer: http://stackoverflow.com/a/21549299

http://stackoverflow.com/q/21575873
has comment: http://stackoverflow.com/comment/32590804
has answer: http://stackoverflow.com/a/21576076
tagged with: date
score: 0
answer count: 3
tagged with: sql
has answer: http://stackoverflow.com/a/21578220
has comment: http://stackoverflow.com/comment/32590685
has comment: http://stackoverflow.com/comment/32591103
possible better answer: http://stackoverflow.com/a/21576076
has body: Hello in my web application i ve used SimpleDateFormat to convert string to date and in the format MM/dd/yyyy but when the form fields get inserted in the database its in the format yyyy/MM/dd. Below is my servlet protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Affiliate af= new Affiliate(); af.setFisrtName(request.getParameter("txtFname")); af.setLastName(request.getParameter("txtLname")); af.setGender(request.getParameter("txtGender")); af.setCategory(request.getParameter("txtCategory")); String dob=(request.getParameter("txtDob")); SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); Date date; try { date = (Date)formatter.parse(dob); af.setDate(date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } af.setAge(Integer.parseInt(request.getParameter("txtAge"))); af.setAddress(request.getParameter("txtAddr")); af.setCountry("India"); af.setState(request.getParameter("txtState")); af.setCity(request.getParameter("txtCity")); af.setPinCode(Integer.parseInt(request.getParameter("txtPin"))); af.setEmailId(request.getParameter("txtEmail")); af.setStd(Integer.parseInt(request.getParameter("txtStd"))); af.setContactNo(Integer.parseInt(request.getParameter("txtPhone"))); af.setMobileNo(Long.parseLong(request.getParameter("txtMobile"),10)); AffiliateService afs=new AffiliateService(); **afs.createAffiliate(af);** } Below is my DAO: public void insertAffiliate(Affiliate affiliate){ String sql="INSERT INTO REGISTER " +"(id,FisrtName,LastName,Gender,Category,DateOfBirth,Age,Address,Country,State,City,PinCode,EmailId,Std,ContactNo,MobileNo)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; Connection conn = null; try { **conn = dataSource.createConnection();** PreparedStatement ps = conn.prepareStatement(sql); ps.setInt(1, affiliate.getId()); ps.setString(2, affiliate.getFisrtName()); ps.setString(3, affiliate.getLastName()); ps.setString(4,affiliate.getGender()); ps.s…
linked to: http://stackoverflow.com/q/3469507
has comment: http://stackoverflow.com/comment/32590964
linked to: http://stackoverflow.com/q/4052862
type: AnsweredQuestion
has title: Date format in Database is in yyyy/MM/dd i want it in the from MM/dd/yyyy
tagged with: java
has comment: http://stackoverflow.com/comment/32594672
tagged with: mysql
has answer: http://stackoverflow.com/a/21576084
accepted answer: http://stackoverflow.com/a/21576084
has comment: http://stackoverflow.com/comment/32592293
has comment: http://stackoverflow.com/comment/32590844
type: Question
has comment: http://stackoverflow.com/comment/32591019

http://stackoverflow.com/a/21602569
downvote count: 0
has body: getCurrentDirectory() returns the current directory that is opened in the JFileChooser. When you are selecting C:\test you opened C:\ directory, so you are getting C:\ on getCurrentDirectory() The getSelectedFile() returns the file that is selected (in your case the file is a directory). So you if you want the directory that is selected by the user use getSelectedFile()
upvote count: 3
type: Answer
score: 3
answers question: http://stackoverflow.com/q/21602114

http://stackoverflow.com/a/21571516
score: 2
downvote count: 0
type: Answer
has body: Program to an interface The only advantage is that you are hiding the exact implementation by using interface MyInterface and you are free to change the implementation in future. But when you use concrete class then you are bound to the behavior of that class. Suppose you were passing List&lt;Integer&gt; in method of other class then it can be any implementation of list the user does not care. But if you pass ArrayList&lt;Integer&gt; then the user can use ArrayList specific methods and you will not be able to change it to LinkedList in future. So case2() is better than case1() There is no other benefit. Do they have any advantages in terms of performance , visibility , protecting the object from illegal usage? Performance will be same when passing any kind of reference, it does not matter whether it is an interface or concrete class reference. EDIT: As per the comment and further post of @maaartinus there seems to be some difference in performance when using interfaces. But again I would not be worried unless it proven to be a bottleneck in my code, which is going to be never.
upvote count: 2
answers question: http://stackoverflow.com/q/21571479
has comment: http://stackoverflow.com/comment/32601816
has comment: http://stackoverflow.com/comment/32626699
has comment: http://stackoverflow.com/comment/32647218

http://stackoverflow.com/a/21574469
score: 1
answers question: http://stackoverflow.com/q/21574385
upvote count: 1
has comment: http://stackoverflow.com/comment/32588387
has comment: http://stackoverflow.com/comment/32589673
type: Answer
has comment: http://stackoverflow.com/comment/32589338
has body: You should use: R.id.yourControlId In the autogenerated class R are you're ID's stored for multiple things like your resources; images/strings etc.. To get your images from your drawable folder: R.drawable.image To get your string from your strings.xml: R.string.hello_world So you should do this instead: EditText Password = (EditText)FindViewById(R.id.pass);
downvote count: 0

http://stackoverflow.com/comment/32660744
has text: Does the assignment expect you to handle an arbitrary number of polygon sides? If so, your code for 3 and 4 sides won't be too helpful. You should think about what the radius and inscribed circle mean and how they can help you solve this problem. EDIT: What I said is true even if you only have to handle up to pentagons.
score: 0
type: Comment
comment on: http://stackoverflow.com/q/21615203
type: QuestionComment

http://stackoverflow.com/comment/32644246
score: 1
type: Comment
has text: You didn't mention you wanted to remove old data. Just use `model.setRowCount(0);`
comment on: http://stackoverflow.com/a/21605879
type: AnswerComment

http://stackoverflow.com/comment/32680900
comment on: http://stackoverflow.com/q/21627108
score: 0
type: Comment
type: QuestionComment
has text: That didn't seem to solve anything.

http://stackoverflow.com/q/21636973
possible better answer: http://stackoverflow.com/a/21637081
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21637081
tagged with: android-edittext
has answer: http://stackoverflow.com/a/21637892
score: 1
tagged with: java
upvote count: 1
has answer: http://stackoverflow.com/a/21637082
type: Question
has body: I have an EditText view where the user inputs a number and another EditText directly next to it. When the user clicks the second EditText I would like to change the first EditText to a TextView. How can I go about this?
has title: Change EditText to TextView on focus change
has answer: http://stackoverflow.com/a/21637080
tagged with: layout
downvote count: 0
tagged with: textview
has comment: http://stackoverflow.com/comment/32698310
favorite count: 0
accepted answer: http://stackoverflow.com/a/21637080
tagged with: android

http://stackoverflow.com/q/21666727
tagged with: android-activity
has body: I'm trying to make a transition between two Activities, the following code works with my Android 4.2.1 Device, but doesn't work in my 4.0.4 Intent intent = new Intent(this, MyClass.class); startActivity(intent); //transition overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.fade_out); //finish activity finish(); I really don't understand why it doesn't work on Android 4.0.4 Can you help me please ? thanks you
has title: Android Activity transition compatibility
upvote count: 1
answer count: 1
tagged with: java
has answer: http://stackoverflow.com/a/21669482
tagged with: transition
type: AnsweredQuestion
downvote count: 0
score: 1
favorite count: 0
type: Question
tagged with: android
accepted answer: http://stackoverflow.com/a/21669482

http://stackoverflow.com/comment/32562171
comment on: http://stackoverflow.com/a/21532700
type: AnswerComment
score: 0
type: Comment
has text: I test the application on my Nexus 4. This is my Main and Settings activities in the Android Manifest file [link](http://pastebin.com/M5BQRqgK)

http://stackoverflow.com/q/21639428
tagged with: swing
type: Question
score: 3
has answer: http://stackoverflow.com/a/21639458
has title: make a special delay in gui of java
has body: I've made this code in java, i wanna make a delay after this part of code, but when i use delay or sleep codes the whole code sleeps for the delay time but i wanna see this back ground changes in gui and then make a delay!!! so what should i do?(I use swing gui) for (int i = 0; i &lt; 8; i++) { for (int j = 0; j &lt; 8; j++) { if (matrisBazi[i][j] == 0) { jb[i][j].setBackground(Color.white); } if (matrisBazi[i][j] == 1) { jb[i][j].setBackground(Color.red); } if (matrisBazi[i][j] == 2) { jb[i][j].setBackground(Color.blue); } } } jb[i][j].addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { click(s); } }); my actionPerformed void is called before and its inside of click(); functions and is doing the process so how to add swing timer code to this void?! i think the timer doesn't work until the click(); finished.
has answer: http://stackoverflow.com/a/21639473
upvote count: 3
has comment: http://stackoverflow.com/comment/32703034
answer count: 2
favorite count: 0
type: UnansweredQuestion
downvote count: 0
tagged with: java

http://stackoverflow.com/a/21530397
has comment: http://stackoverflow.com/comment/32588703
upvote count: 3
answers question: http://stackoverflow.com/q/21529351
has comment: http://stackoverflow.com/comment/32548165
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32526768
has comment: http://stackoverflow.com/comment/32593324
type: Answer
has comment: http://stackoverflow.com/comment/32609601
has comment: http://stackoverflow.com/comment/32588229
has comment: http://stackoverflow.com/comment/32517550
has comment: http://stackoverflow.com/comment/32588896
score: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/32559803
has body: There are two major solutions. All solutions have in common, that the column containing the date has to be ordered somehow. If this order is destroyed your data is corrupt and your queries cannot return the expected results! 1. Save your Dates as INTEGER in your database and use a method to map Dates to a number: A possible way is to use Date.getTime () to map Dates to numbers, but there are many others. Important is that equal dates get the same number and that a date that is after another date gets a bigger number. This way ordering will be correct for sure. To achieve this with `Java.util.Date.getTime() you only have to set the time to 0:00:00:000 if you want to store date only. For example: "CREATE TABLE " + Food_TABLE +"(" + EX_RowID + "INTEGER PRIMARY KEY AUTOINCREMENT, " + EX_Cattype + " TEXT NOT NULL, " + EX_Date + " INTEGER NOT NULL," + EX_Price + " INTEGER NOT NULL," + EX_Type + " TEXT NOT NULL UNIQUE );" private static String dateOnly(java.util.Date d) { Calendar cal = Calendar.getInstance(); // locale-specific cal.setTime(d); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return Long.toString(cal.getTimeInMillis()); } public Cursor CstmRpot(java.util.Date fd, java.util.Date td) { // TODO Auto-generated method stub String[] columns = new String[]{EX_RowID,EX_Cattype, EX_Date, EX_Price, EX_Type }; Cursor c= ourdatabase.query(Food_TABLE, columns, EX_Date + " &gt; " + dateOnly (fd) + " AND " + EX_Date + " &lt; " + dateOnly(td), null, null, null, null); if (c != null) { c.moveToFirst(); } return c; } If you don't use different timezones the dateOnly(java.util.Date d) can be optimized. Of course you can also use JODA-time. 2. Save your Dates as TEXT If you choose this method your queries that are comparing the date-column are going to be a bit slower, but the entries in the database are human readable which doesn't have t be the case with method 1. TEXT-columns are ordered with BINA…
has comment: http://stackoverflow.com/comment/32594204
accepted answer of: http://stackoverflow.com/q/21529351

http://stackoverflow.com/q/21591708
has answer: http://stackoverflow.com/a/21592462
tagged with: android
type: AnsweredQuestion
score: 4
possible better answer: http://stackoverflow.com/a/21592462
tagged with: java
has answer: http://stackoverflow.com/a/21594388
accepted answer: http://stackoverflow.com/a/21594530
type: Question
has comment: http://stackoverflow.com/comment/32619459
upvote count: 4
answer count: 3
downvote count: 0
has title: Java variables declaration
favorite count: 0
has answer: http://stackoverflow.com/a/21594530
has comment: http://stackoverflow.com/comment/32619490
has comment: http://stackoverflow.com/comment/32620055
has body: I am a little bit confused about the program flow of an android activity, in java the main method executes first while in android the onCreate methods gets called first, so what about the variables which are defined at class level? How do they get declared/initialized when the activity starts executing, saying that onCreate gets called first. Also Can we initialize these variables in Inner class and use their values outside of the inner class?

dialog
tag name: dialog
type: Tag
tags question: http://stackoverflow.com/q/21550964
tags question: http://stackoverflow.com/q/21566221
tags question: http://stackoverflow.com/q/21525743
tags question: http://stackoverflow.com/q/21606722
tags question: http://stackoverflow.com/q/21645681

http://stackoverflow.com/q/21520828
has comment: http://stackoverflow.com/comment/32493153
has title: import large data into a 2d array
tagged with: java
has comment: http://stackoverflow.com/comment/32493068
type: Question
answer count: 2
has body: I get an exception when I run this program, its big file filled with data, I am trying to import the data from that file and insert the information into a 2d array, though, the file consists of around 19,000 lines. Though, my program stops running and tells me that there are no lines during the process. My exception is java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Scanner.java:1585) at Data.main(Data.java:30) Please help, what is wrong? import java.util.Scanner; import java.io.FileReader; import java.io.FileNotFoundException; import java.io.IOException; public class Data { public static void main(String[] args) { try{ java.io.File file = new java.io.File("/Users/admin/Desktop/data.csv"); Scanner in = new Scanner(file); String title = in.nextLine(); String[][] data = new String[19517][5]; int currentRow = 0; String current; int i = 0; while (in.hasNextLine()) { String[] c = new String[5]; String line = in.nextLine().replaceAll("\"", ""); //changing the format of the data input c = line.split(","); c[1] = c[1].replace(" ", ""); for (int j = 0; j &lt;data[0].length; j++) { current = c[j]; data[i][j] = c[j]; } i++; } } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } catch (Exception ex) { ex.printStackTrace(); } } }
has comment: http://stackoverflow.com/comment/32493136
has comment: http://stackoverflow.com/comment/32493209
score: 0
has answer: http://stackoverflow.com/a/21520927
has answer: http://stackoverflow.com/a/21520925
tagged with: multidimensional-array
has comment: http://stackoverflow.com/comment/32493056
type: UnansweredQuestion

http://stackoverflow.com/a/21633073
downvote count: 1
has body: You often hear the general recommendation that, in the best case, comments should simply not be necessary at all. But concerning JavaDoc, they play an important role not only for the developer, but also for the user of the library. Additionally, writing JavaDoc comments may be more useful for you (especially for a beginner) than for anyone else: When you find it hard to describe what a variable is or what a method does with a single /** One-line-JavaDoc comment */, then you'll automatically re-think what you have done there. When generating JavaDocs, you may choose whether you want to generate them only for the public and protected parts of the API, or also for default- or private elements. However, you should in any case document protected methods: May someone who extends the class only call this method, or is he also allowed to override this method? If so, are there any pre- and postconditions that he should know about? Should he call super.theMethod() in the overridden version? (BTW: If he's not allowed to override the method, then it should be final, but documented anyhow) BTW: I personally comment everything, but know that most people think it's not necessary or even a bad style, especially for "trivial" things /** * The number of elements in this set */ private final int numberOfElements; I think it does not harm, but helps in many cases. Maybe, regarding private parts, it's just a matter of taste.
has comment: http://stackoverflow.com/comment/137344330
upvote count: 8
type: Answer
answers question: http://stackoverflow.com/q/21632086
score: 7

http://stackoverflow.com/comment/32673544
type: QuestionComment
type: Comment
has text: @KamleshArya No 3rd party addons :)
score: 0
comment on: http://stackoverflow.com/q/21623064

http://stackoverflow.com/comment/32634509
comment on: http://stackoverflow.com/a/21600731
score: 0
type: AnswerComment
has text: Thanks Bruno for explaining in detail. can you provide link from where i can download your book.
type: Comment

http://stackoverflow.com/comment/32699076
score: 0
type: Comment
type: QuestionComment
has text: Thanks, I will go ahead with this approach.
comment on: http://stackoverflow.com/q/21587566

http://stackoverflow.com/a/21550716
score: 1
upvote count: 1
has body: Try this and let me know that helps.. System.getProperties().put("http.proxyHost", "someProxyURL"); System.getProperties().put("http.proxyPort", "someProxyPort"); System.getProperties().put("http.proxyUser", "someUserName"); System.getProperties().put("http.proxyPassword", "somePassword"); http://viralpatel.net/blogs/http-proxy-setting-java-setting-proxy-java/
has comment: http://stackoverflow.com/comment/32545313
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21550637

http://stackoverflow.com/q/21608250
type: UnansweredQuestion
tagged with: android
score: 0
tagged with: java
has title: Using TextToSpeech together with RecognizerIntent (android)
tagged with: eclipse
type: Question
has body: I'm trying to combine the use of RecognizerIntent and TextToSpeech to make the phone respond to certain commands given by the user using RecognizerIntent. The for-loop in the onActivityResult method checks the possible inputs from the user against the texts string-array. The log-cat messages run, but the text will not be spoken. Here's my Java code: import java.util.ArrayList; import java.util.Locale; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.speech.RecognizerIntent; import android.speech.tts.TextToSpeech; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class TextVoice extends Activity implements OnClickListener { static final String[] texts = { "Hello", "Welcome", "Nice to meet you" }; static final int check = 111; ArrayList&lt;String&gt; results; TextToSpeech tts; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.textvoice); Button b = (Button) findViewById(R.id.bTextToVoice); b.setOnClickListener(this); Log.println(Log.DEBUG, "voice", "Startet"); tts = new TextToSpeech(TextVoice.this, new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { if (status != TextToSpeech.ERROR) { tts.setLanguage(Locale.US); } } }); } // @Override // public void onClick(View v) { // // TODO Auto-generated method stub // Random r = new Random(); // String random = texts[r.nextInt(3)]; // tts.speak(random, TextToSpeech.QUEUE_FLUSH, null); // } @Override public void onClick(View v) { // TODO Auto-generated method stub Intent i = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); i.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speak up, son!"); startActivityForResult(i, check); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) …
tagged with: voice
answer count: 1
has answer: http://stackoverflow.com/a/21608898
tagged with: http://stackoverflow.com/tag/xml

http://stackoverflow.com/comment/32745673
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21664103
has text: Oh i see what you did there..thanks alot for your help. As soon at it lets me i will mark your answer. Thanks
score: 0

http://stackoverflow.com/q/21520827
accepted answer: http://stackoverflow.com/a/21520864
has comment: http://stackoverflow.com/comment/32493063
has comment: http://stackoverflow.com/comment/32493673
score: 0
tagged with: java
linked to: http://stackoverflow.com/q/2416056
possible better answer: http://stackoverflow.com/a/21521259
has answer: http://stackoverflow.com/a/21521259
has comment: http://stackoverflow.com/comment/32493536
has comment: http://stackoverflow.com/comment/32493737
type: AnsweredQuestion
has body: I am getting an org.springframework.beans.factory.BeanCreationException in my spring controller as I use ResponseList bean. Error creating bean with name 'responseList' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: 1 constructor arguments specified but no matching constructor found in bean 'responseList' (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities) Here is the context part: Here is the Bean: package com.form.response; import java.util.List; public class ResponseList { public ResponseList() { // TODO Auto-generated constructor stub } private List<Response> responseList; public List<Response> getResponseList() { return responseList; } public void setResponseList(List<Response> responseList) { this.responseList = responseList; } } Can anyone please correct what I am missing here?
has answer: http://stackoverflow.com/a/21520864
tagged with: spring-bean
has title: BeanCreationException in spring controller
has comment: http://stackoverflow.com/comment/32493110
type: Question
answer count: 2
tagged with: spring

http://stackoverflow.com/q/21663549
upvote count: 2
accepted answer: http://stackoverflow.com/a/21664150
type: Question
type: AnsweredQuestion
tagged with: java
answer count: 1
downvote count: 0
tagged with: openrdf
has answer: http://stackoverflow.com/a/21664150
has body: I am quite new to Java Sesame. I am following this tutorial: http://openrdf.callimachus.net/sesame/2.7/docs/users.docbook?view . I know how to create statements and add them into the Sesame repository. At the moment, I am trying to describe classes and properties for the statements I am going to add. For example, I am having the ones below: :Book rdf:type rdfs:Class . :bookTitle rdf:type rdf:Property . :bookTitle rdfs:domain :Book . :bookTitle rdfs:range rdfs:Literal . :MyBook rdf:type :Book . :MyBook :bookTitle "Open RDF" . As shown, Book is defined as a Class. bookTitle is defined as a Property. My question is: How can I do this in Java Openrdf using org.openrdf.model.vocabulary.RDFS. To clarify the point, Here is another example: con.add(alice, RDF.TYPE, person); alice is a type of person. How can I define person as a class using org.openrdf.model.vocabulary.RDFS. Your assistance would be very much appreciated.
has title: How to describe classes and properties using RDFS in Java
tagged with: sesame
favorite count: 0
score: 2

http://stackoverflow.com/comment/32492128
has text: Well, you're already doing it...
comment on: http://stackoverflow.com/q/21519914
score: 0
type: Comment
type: QuestionComment

jmockit
tags question: http://stackoverflow.com/q/21608074
tags question: http://stackoverflow.com/q/21577341
type: Tag
tag name: jmockit
tags question: http://stackoverflow.com/q/21556431

http://stackoverflow.com/comment/32531287
has text: No the server class is the server application on the PC, it's not part of the android application.
score: 0
comment on: http://stackoverflow.com/q/21541748
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21574745
score: 2
type: AnsweredQuestion
downvote count: 0
linked to: http://stackoverflow.com/q/1264709
tagged with: java
possible better answer: http://stackoverflow.com/a/61773554
type: Question
has answer: http://stackoverflow.com/a/61773554
has answer: http://stackoverflow.com/a/21575089
accepted answer: http://stackoverflow.com/a/21575089
upvote count: 2
tagged with: jakarta-mail
has title: Java: Encode String in quoted-printable
answer count: 2
tagged with: mime
has comment: http://stackoverflow.com/comment/32588898
tagged with: quoted-printable
favorite count: 0
has body: I am looking for a way to quoted-printable encode a string in Java just like php's native quoted_printable_encode() function. I have tried to use JavaMails's MimeUtility library. But I cannot get the encode(java.io.OutputStream os, java.lang.String encoding) method to work since it is taking an OutputStream as input instead of a String (I used the function getBytes() to convert the String) and outputs something that I cannot get back to a String (I'm a Java noob :) Can anyone give me tips on how to write a wrapper that converts a String into an OutputStream and outputs the result as a String after encoding it?

http://stackoverflow.com/q/21570984
type: UnansweredQuestion
score: 0
tagged with: android-intent
has title: Failed to get "Integer Tag" of ImageView and pass in Intent in Android?
tagged with: java
tagged with: tags
type: Question
answer count: 1
has body: I want to set Tag of ImageView as 1,2,3 ....... and want to retreive that tag onClick and pass it with Intent and retrieve it using Intents in nextActivity and pass to a function But failed to do so.... XML: &lt;ImageView android:id="@+id/latest_btn_quran_on" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="2dp" android:src="@drawable/latest_quran_on" android:tag="1"/&gt; ImageView ClickListener : quranHadeesButton = (ImageView)findViewById(R.id.latest_btn_quran_on); quranHadeesButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent latestQuranQuesAns = new Intent(GenraltopicActivity.this,GeneralTopicQuestions.class); //latestQuranQuesAns.putExtra("clickedTopicid",quranHadeesButton.getTag().toString()); int id = (Integer) quranHadeesButton.getTag(); latestQuranQuesAns.putExtra("clickedTopicid",id); startActivity(latestQuranQuesAns); } }); GeneralTopicQuestions Activity : public class GeneralTopicQuestions extends Activity {ImageView quranOHadeesQuestion1; Context context; List&lt;String&gt; questionImagesNameList = new ArrayList&lt;String&gt;(); @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.general_topic_questions); context = this; //Intent intent = getIntent(); String clickedTopicId = Integer.toString(getIntent().getExtras().getInt("clickedTopicid"));//string data will contain image file name Log.i("clickedTopicid",""+clickedTopicId); JamiaBinoriaDBHelper dbhelper = new JamiaBinoriaDBHelper(context); dbhelper.open(); //Integer sampleId = clickedTopicId questionImagesNameList = dbhelper.GetClickedIdImages(getIntent().getExtras().getInt("clickedTopicid")); Log.i("questionImagesNameList:",""+questionImagesNameList); } } The problem is with this LOC: questionImagesNameList = dbhelper.GetClickedIdImages(getIntent().getExtras().getIn…
tagged with: android
has comment: http://stackoverflow.com/comment/32582490
has answer: http://stackoverflow.com/a/21571280

http://stackoverflow.com/q/21581977
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has title: java.lang.TypeNotPresentException
has body: I'm using a fiew webservices that return an object but not a standard type object, it's an object of my own classes, for example: public class BaseResponse { public String ErrorMessage; public String ResponseStatus; public String ResponseDate; public String SessionExpire; } public class ResponseJsonModel extends BaseResponse{ private String firstName; private String lastName; private boolean male; private Address address; ... } NOTE: BaseResponse is a standard types object. Everything works fine except when I use proguard because it throws: java.lang.TypeNotPresentException: Type com.myapp.ResponseJsonModel not present I've found an issue similar to mine: http://code.google.com/p/google-api-java-client/issues/detail?id=527 but the solution doesn't work, I'm still having the same exception even if I use: -keep class com.google.api.client.googleapis.json.GoogleJsonError$ErrorInfo as mentioned in the issue... I've read somewhere in the web that I should annotate such classes with various JAXB annotations. Could this be the solution? I know nothing about JAXB. Thanks for your time.
has comment: http://stackoverflow.com/comment/32602834
type: Question
has comment: http://stackoverflow.com/comment/32601828
has answer: http://stackoverflow.com/a/73634921
answer count: 1
downvote count: 0
favorite count: 0
upvote count: 2
tagged with: google-api
tagged with: android
score: 2
accepted answer: http://stackoverflow.com/a/73634921
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32604861

http://stackoverflow.com/a/23480673
score: 0
upvote count: 1
answers question: http://stackoverflow.com/q/21639695
downvote count: 1
accepted answer of: http://stackoverflow.com/q/21639695
type: AcceptedAnswer
has body: Here is the answer O.o finally found it!! you just have to see this way the last part of the code: File folder = new File("C://Users//YourUser//YourWorkspace//YourProject//bin"); File[] files = folder.listFiles(); File file=new File("C://Users//YourUser//Desktop//Examples.jar");
type: Answer

http://stackoverflow.com/comment/32561353
has text: @Marco13 *"You know that I'm not questioning your code.."* Why not? *Anyone's* code and approach is open for discussion. It's all good. :)
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21557361
type: Comment

ienumerator
tag name: ienumerator
tags question: http://stackoverflow.com/q/21589889
type: Tag

http://stackoverflow.com/q/21564601
has comment: http://stackoverflow.com/comment/32570898
tagged with: java
has body: I saw this code and wondered why in.close() was done in the finally block. The main point of try-with resources is that it closes the resources correct. File file = new File(FILE_NAME); FileInputStream in = null; try (in = new FileInputStream(file)){ //do something } catch (final FileNotFoundException e) { log.log(Level.WARNING, "file not found, " + file.getAbsolutePath(), e); } catch (final IOException e) { log.log(Level.WARNING, "cannot access the file for reading", e); } finally { if (in != null){ try { in.close(); } catch (final IOException e) { log.log(Level.WARNING, "Attempt to close file failed.", e); } } } Will there be a situation where a file can be opened but cannot be closed using try-with-resources in Java?
has answer: http://stackoverflow.com/a/21564781
type: Question
has title: Can closing a File fail?
has comment: http://stackoverflow.com/comment/32570989
tagged with: try-with-resources
has answer: http://stackoverflow.com/a/21564819
has answer: http://stackoverflow.com/a/21564784
downvote count: 0
favorite count: 0
tagged with: finally
has answer: http://stackoverflow.com/a/21564882
upvote count: 2
tagged with: exception
type: UnansweredQuestion
answer count: 4
score: 2

http://stackoverflow.com/a/21565168
answers question: http://stackoverflow.com/q/21564605
type: Answer
upvote count: 2
score: 2
has comment: http://stackoverflow.com/comment/32572478
accepted answer of: http://stackoverflow.com/q/21564605
has body: I think it has to do with the design goals of the framework: The main design goal was to produce an API that was small in size and, more importantly, in "conceptual weight." (Source) You should check out Guava's immutable collection types, if you are willing to learn more conceptual weight :)
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/21546909
favorite count: 0
has comment: http://stackoverflow.com/comment/32538687
has comment: http://stackoverflow.com/comment/32538716
has comment: http://stackoverflow.com/comment/32538681
tagged with: android
has comment: http://stackoverflow.com/comment/32538723
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21546991
tagged with: java
accepted answer: http://stackoverflow.com/a/21547006
upvote count: 1
type: Question
possible better answer: http://stackoverflow.com/a/21546991
has title: How to navigate to next activity after user clicks on AlertDialog OK button?
downvote count: 0
has body: Sorry to ask this question after searching in http://stackoverflow.com. But I couldn't process to next activity when using these below codes at different section. Here when user Not connected internet then a popup will alert and says "you not connected to internet" in alertdialog and when user click on exit button in alertdilog the app will close. if user have internet connection a popup will alert and says "you have internet connection" in alertdialog and when user click on continue button app continues to next activity. I am having problem in continuing to next activity, How to do that? Below codes are show in their section Code in AndroidDetectInternetConnectionActivity.java package com.example.detectinternetconnection; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.view.View; import android.widget.Button; public class AndroidDetectInternetConnectionActivity extends Activity { // flag for Internet connection status Boolean isInternetPresent = false; // Connection detector class ConnectionDetector cd; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btnStatus = (Button) findViewById(R.id.btn_check); // creating connection detector class instance cd = new ConnectionDetector(getApplicationContext()); /** * Check Internet status button click event * */ btnStatus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // get Internet status isInternetPresent = cd.isConnectingToInternet(); // check for Internet status if (isInternetPresent) { // Internet Connection is Present // make HTTP requests AlertDialog.Builder builder = new AlertDialog.Builder(AndroidDetectInternetConnectionActivity.this); builder.setMessage("You have network connection.") .setTitle("Internet Connection") .setCancelable(false); AlertDialog alert = builder.…
has answer: http://stackoverflow.com/a/21546995
answer count: 3
score: 1
has answer: http://stackoverflow.com/a/21547006

http://stackoverflow.com/comment/32745628
has text: Thank you very much for your help. Please correct me if I am mistaken. I am trying to do the schema or the ontology and create my statement based on it. Is that right? One more thing, please. Would you recommend me to create an ontology in a file and upload that file in Sesame and then create the statements like the alice example? Since I do not know how to do it in this way, I will do it in the way you helped me with. Do you think it would be OK?
comment on: http://stackoverflow.com/a/21664150
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/21618829
answers question: http://stackoverflow.com/q/21618684
has body: Change println() by System.out.print(); or System.out.println(); For More
score: 0
type: Answer

http://stackoverflow.com/q/21653931
has comment: http://stackoverflow.com/comment/32727597
type: Question
tagged with: arrays
answer count: 1
has body: Can you give me a hint on what I'm doing wrong with my average in the average method? I'm trying to call the method in the read scores.I'm trying to get the average of the scores I have in my input.txt file. import java.io.*; import java.util.*; public class FindGrade { public static final int NUM_SCORE_TYPES = 5; public static void main(String[] args) { Scanner scan = null; int[] quizArray = null; int[] labArray = null; int[] attendance = null; int[] midterms = null; int quizgrade =0; int labgrade=0; int attendance_1=0; int midterms_1 =0; String name; try { scan = new Scanner(new File("input.txt")); } catch (FileNotFoundException e) { e.printStackTrace(); return; } // each iteration is for single exam type (ie: Quizzes is the 1st one) for (int i = 0; i &lt; NUM_SCORE_TYPES; i++) { name = scan.next(); int numScores = scan.nextInt(); int maxGrade = scan.nextInt(); if (name.equals("Quizzes")) { quizArray = new int[numScores]; readScores(quizArray, numScores, scan); } else if (name.equals("Labs")) { labArray = new int[numScores]; readScores(labArray, numScores, scan); } else if (name.equals("Lab_attendance")) { attendance = new int[numScores]; readScores(attendance, numScores, scan); } else if (name.equals("Midterms")) { midterms = new int[numScores]; readScores(midterms, numScores, scan); } } } public static void readScores(int[] scoreArray, int numScores, Scanner scan) { for (int i = 0; i &lt; numScores; i++) { scoreArray[i] = scan.nextInt(); } } public static void average(double [] scoreArray, int numScores){ double sum=0; for(int i=0; i&lt; scoreArray.length; i++){ sum += scoreArray[i]; } double average = sum/numScores; System.out.println(sum + " " + average); }
has comment: http://stackoverflow.com/comment/32727789
has comment: http://stackoverflow.com/comment/32727808
has comment: http://stackoverflow.com/comment/32727695
has title: average method arrays hint
has comment: http://stackoverflow.com/comment/32727751
type: UnansweredQuestion
score: 0
has answer: http://stackoverflow.com/a/21654086
has comment: http://stackoverflow.com/comment/32727637
has comment: http://stackoverflow.com/comment/32727714
has comment: http://stackoverflow.com/comment/32727731
tagged with: java

http://stackoverflow.com/a/21595979
type: Answer
has body: You have given the classname and name wrong. classname is "text" and name is "errorContent". WebElement divElement = Hcd.findElement(By.className("text"));
answers question: http://stackoverflow.com/q/21592406
score: 0

http://stackoverflow.com/comment/32761239
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21671993
has text: @allprog it's just an example. My `SomeObject` is different (and proprietary, hence can't post).

http://stackoverflow.com/q/21671103
type: Question
has title: How to handle JSON string in jQuery?
accepted answer: http://stackoverflow.com/a/21671378
answer count: 2
possible better answer: http://stackoverflow.com/a/21671227
downvote count: 0
tagged with: jquery
favorite count: 0
has body: I have a JSON string as following [{"partner-code":"AMEX", "partner":"American Express", "issuer":"American Express", "summary":[], "description":[], "url":"http://www.qantas.com.au/fflyer/dyn/partners/card-american-express", "email":[], "phone-number":[], "mediafile":[], "bonus-offer-summary":"Earn up to 50,000 bonus Points with the Qantas American Express Ultimate Card. Up to 7,500 bonus Points also available on the Qantas American Express Premium and Discovery Cards. Conditions and spend criteria apply.", "bonus-offer-description":"You could earn up to 50,000 bonus points with the Qantas American Express Ultimate Card when you apply by 31 December 2013, are approved and meet the eligible spend criterias&lt;sup&gt;***&lt;/sup&gt;. Also, you could earn up to 30,000 bonus points with the Qantas American Express Premium Card&lt;sup&gt;^^&lt;/sup&gt; or up to 7,500 bonus points with the Qantas American Express Discovery Card&lt;sup&gt;**&lt;/sup&gt; when you apply, are approved by 31 December 2013 and meet the eligible spend criteria.", "show-bonus-offer":"", "card-offerings":[{"card-name":"Qantas American Express Discovery Card", "earning-points":"This credit card automatically earns Qantas Frequent Flyer points", "website":"http://www.americanexpress.com/au/content/frequent-flyer-cards/qantas-discovery-card/?filter=qanseries&amp;bkgd=3&amp;PID=35&amp;BUID=CCG&amp;AFFID=Qantas&amp;CRTV=Earn&amp;PSKU=AQDB&amp;sourcecode=25A996J001&amp;CPID=100036881", "contact-phone-number":"1300 736 978", "usage-type":"Personal", "card-level":"Classic", "card-type-01":"American Express", "annual-fee":"0","opt-in-fee":"0", "supplementary-card-fee":"0", "supplementary-card-fee-descriptor":"annual Card fee per Supplementary Card&lt;sup&gt;~&lt;/sup&gt;", "interest-rate":"20.74", "interest-free-period":"Up to 44 days interest free on purchases when the closing balance (including any balance transfer or promotional amount) is paid in full by the statement due date&lt;sup&gt;$&lt;/sup&gt;"…
score: 2
upvote count: 2
has answer: http://stackoverflow.com/a/21671378
type: AnsweredQuestion
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has answer: http://stackoverflow.com/a/21671227

http://stackoverflow.com/q/21551798
type: UnansweredQuestion
tagged with: spring
has comment: http://stackoverflow.com/comment/45400134
tagged with: java
tagged with: jax-ws
has comment: http://stackoverflow.com/comment/32562466
type: Question
tagged with: weblogic
answer count: 1
has title: Read timed out error - javax.xml.ws.soap.SOAPFaultException
has body: I'm trying to debug a critical issue where a JSP application is seeing request timeouts when making call to a remote web service. I should clarify the timeout doesn't happen at all time, for smaller queries the web service does return response. I have tried increasing the timeout value in WebLogic server > Protocols > HTTP > Post timeout and Duration. I have also tried to set JAX-WS properties in my spring.xml as follows: <util:map id="jaxwsCustomProperties"> 650000 650000 </util:map> Console output: org.springframework.remoting.jaxws.JaxWsSoapFaultException: Request timeout. Read timed out; nested exception is javax.xml.ws.soap.SOAPFaultException: Request timeout. Read timed out at org.springframework.remoting.jaxws.JaxWsPortClientInterceptor.doInvoke(JaxWsPortClientInterceptor.java:395) at org.springframework.remoting.jaxws.JaxWsPortClientInterceptor.invoke(JaxWsPortClientInterceptor.java:379) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy72.getDeviceList(Unknown Source) at com.company.msr.web.actionbean.DeviceListProcessor.getDeviceList(DeviceListProcessor.java:223) at com.company.msr.web.actionbean.MsrMainActionBean.listToJson(MsrMainActionBean.java:287) 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 net.sourceforge.stripes.controller.DispatcherHelper$6.intercept(DispatcherHelper.java:467) at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:158) at net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113) at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionCo…
has answer: http://stackoverflow.com/a/21562508
score: 0
tagged with: soap

http://stackoverflow.com/comment/32786891
type: QuestionComment
has text: Putting the annotation @LazyCollection with FALSE value, hibernate breaks into a lot of queries. Query 1: Query survey where survey.id = Question.survey.id Query N: For each question hibernate queries for all question choice
score: 0
comment on: http://stackoverflow.com/q/21659388
type: Comment

http://stackoverflow.com/comment/32686888
score: 1
has text: Off topic related to Stackoverflow's Super User
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21630849

http://stackoverflow.com/comment/32938164
has text: Hello @simekadam I have updated the code to hopefully reveal a bit more information on how I delete from the main activity vs noteeditor
score: 0
comment on: http://stackoverflow.com/a/21628430
type: AnswerComment
type: Comment

http://stackoverflow.com/a/53005977
upvote count: 4
has comment: http://stackoverflow.com/comment/129889557
has body: This means you are using JPA or hibernate in your code and performing modifying operation on DB without making the business logic transaction. So simple solution for this is mark your piece of code @Transactional
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21574236
score: 4

http://stackoverflow.com/q/21530325
has comment: http://stackoverflow.com/comment/32509916
has comment: http://stackoverflow.com/comment/32510089
type: AnsweredQuestion
has body: I am an Android Developer, i am creating a Dictionary like app.I have maintained my dictionary in a text file. I want to search in my dictionary for the keyword entered by the user. My dictionary has 35000+ entries in it. What is the best way to do it? Do i have to do a binary search, a hashing technique or a trie? I have tried hashing but creating a proper hash function in ascending order and binary search over it is very tedious. This is my first question here. Please tell me if i go wrong any where.
tagged with: file
has comment: http://stackoverflow.com/comment/32509929
type: Question
tagged with: java
tagged with: database
has comment: http://stackoverflow.com/comment/32510098
tagged with: search
has comment: http://stackoverflow.com/comment/32509941
has comment: http://stackoverflow.com/comment/32510106
has title: Searching in Oxford Dictionary
accepted answer: http://stackoverflow.com/a/21530670
answer count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/32510057
has comment: http://stackoverflow.com/comment/32509873
score: 4
favorite count: 0
has comment: http://stackoverflow.com/comment/32509830
upvote count: 5
has answer: http://stackoverflow.com/a/21530670
tagged with: android

http://stackoverflow.com/a/21612697
downvote count: 0
has body: In short answer, XDocReport doesn't support odt->docx converter. You use report.process which means that there is no conversion (docx template->docx report, odt template->odt report). In your sample, the generated report is an odt (even if you set filename with docx extension), that's why OpenOffice is enable to open it although MS Word cannot open it. If you wish to convert the report to other format like html, pdf you must use report.convert but in your case you need a docx->odt converter that XDocReport doesn't provide. But as XDocReport is modular you could develop your own docx->odt converter and plug it with XDocReport.
accepted answer of: http://stackoverflow.com/q/21599083
upvote count: 3
answers question: http://stackoverflow.com/q/21599083
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32657502
type: Answer
score: 3

http://stackoverflow.com/comment/32488599
has text: Curly brackets for if statements, I should really remember that. Thanks!
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21518043

http://stackoverflow.com/comment/32671891
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21598655
type: AnswerComment
has text: Well, I was actually hoping for a general solution where I wouldn't need to implement it for every Locale that needs to be supported specifically. :) As there doesn't seem to be a shortcut around it, thank your for your proposed solution. It definitely does the job.

http://stackoverflow.com/a/21575542
upvote count: 5
downvote count: 0
has body: That's because D represents the Day in year. You need to use dd instead which represents Day in month. Have a look at the docs on different patterns and their representation.
accepted answer of: http://stackoverflow.com/q/21575488
answers question: http://stackoverflow.com/q/21575488
score: 5
has comment: http://stackoverflow.com/comment/32592458
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32593617
type: Answer

http://stackoverflow.com/comment/67287511
type: Comment
has text: I've tested with the latest version of HAProxy and I still end up with RST as the Signal used by HAProxy.
comment on: http://stackoverflow.com/a/36491485
score: 0
type: AnswerComment

parsing
tags question: http://stackoverflow.com/q/21538998
tags question: http://stackoverflow.com/q/21677926
tags question: http://stackoverflow.com/q/21651274
tags question: http://stackoverflow.com/q/21592056
tags question: http://stackoverflow.com/q/21630791
tags question: http://stackoverflow.com/q/21595050
tags question: http://stackoverflow.com/q/21587566
tags question: http://stackoverflow.com/q/21656673
tags question: http://stackoverflow.com/q/21639577
tag name: parsing
tags question: http://stackoverflow.com/q/21588619
tags question: http://stackoverflow.com/q/21624803
tags question: http://stackoverflow.com/q/21596347
tags question: http://stackoverflow.com/q/21645155
tags question: http://stackoverflow.com/q/21661899
tags question: http://stackoverflow.com/q/21647834
tags question: http://stackoverflow.com/q/21599223
tags question: http://stackoverflow.com/q/21652079
type: Tag
tags question: http://stackoverflow.com/q/21531195
tags question: http://stackoverflow.com/q/21532262
tags question: http://stackoverflow.com/q/21539283
tags question: http://stackoverflow.com/q/21561920
tags question: http://stackoverflow.com/q/21581336
tags question: http://stackoverflow.com/q/21610104
tags question: http://stackoverflow.com/q/21545170
tags question: http://stackoverflow.com/q/21518607
tags question: http://stackoverflow.com/q/21644116
tags question: http://stackoverflow.com/q/21634785
tags question: http://stackoverflow.com/q/21658092
tags question: http://stackoverflow.com/q/21582824
tags question: http://stackoverflow.com/q/21556332
tags question: http://stackoverflow.com/q/21571281

http://stackoverflow.com/q/21629258
has answer: http://stackoverflow.com/a/21629502
tagged with: java
tagged with: indexoutofboundsexception
answer count: 5
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21629529
has title: java.lang.ArrayIndexOutOfBoundsException: 0 error in Eclipse, for programs that work using command prompt?
tagged with: eclipse
has comment: http://stackoverflow.com/comment/32684108
has comment: http://stackoverflow.com/comment/32685086
has answer: http://stackoverflow.com/a/21629308
score: 1
type: Question
has body: Right, so I managed to get Eclipse to work (which we need to use in our exam). I'm importing and running some of my programs I had written with gedit and run with command prompt (which worked), but they don't seem to work in Eclipse. My Hello World program did, but my others seem to throw errors regarding args? package week1; public class PersonalGreeting { public static void main(String[] args) { String first_name = args[0]; String last_name = args[1]; System.out.println("Hello " + first_name + " " + last_name); } } Error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at week1.PersonalGreeting.main(PersonalGreeting.java:6) Any ideas how to fix this and what's causing it? Why should it work in command prompt but not Eclipse?
linked to: http://stackoverflow.com/q/23456742
has answer: http://stackoverflow.com/a/21629311
favorite count: 0
has answer: http://stackoverflow.com/a/21629377
upvote count: 2
downvote count: 1

http://stackoverflow.com/comment/32660941
comment on: http://stackoverflow.com/q/21615159
has text: But, I would just like to know how to catch any Exception thrown from within a Fragment. RuntimeException just happens to be my current poison. The goal being a clean shutdown of the app instead of a crash.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21581804
answers question: http://stackoverflow.com/q/21581061
has comment: http://stackoverflow.com/comment/32680439
has comment: http://stackoverflow.com/comment/32686983
type: Answer
has body: When you first give a wrong answer, guessedWord's text becomes the empty String "", so at the next iteration, it will never be equal to the given word, because the String that you get with guessedWord.getText() will now be "". You need to ask the user for a new word and then get the NEW word! For example, you could set a private variable int trials in your class, initialized with 5 (in your main method) and another one, boolean tryAgain initialized with true. Then the above method could be written as: private void guessedWordActionPerformed(java.awt.event.ActionEvent evt){ if (tryAgain &amp;&amp; trials &gt; 0) { if (wordLibrary.isCorrect(wordIdx, guessedWord.getText())){ JOptionPane.showMessageDialog(null, "Your answer is correct! Guess another word.","", JOptionPane.INFORMATION_MESSAGE); getRootPane().setDefaultButton(nextTrial); guessedWord.setText(""); wordIdx = (wordIdx + 1) % wordLibrary.getSize(); scrambledWord.setText(wordLibrary.getScrambledWord(wordIdx)); guessedWord.setText(""); getRootPane().setDefaultButton(guessButton); guessedWord.requestFocusInWindow(); tryAgain = false; } else { trials--; JOptionPane.showMessageDialog(null, "Your answer " + guessedWord.getText() + " is wrong.\n Number of trials remaining: " + trials , "Incorrect Answer", JOptionPane.ERROR_MESSAGE); guessedWord.setText(""); tryAgain = true; } } else { //show "the correct word was..." } guessedWord.requestFocusInWindow(); }
score: 1
has comment: http://stackoverflow.com/comment/32640008
has comment: http://stackoverflow.com/comment/32640345
upvote count: 1
downvote count: 0

http://stackoverflow.com/comment/32744664
type: QuestionComment
score: 0
has text: I don't think that is the same, since I am required to do it by using Criteria API. Thanks anyway.
comment on: http://stackoverflow.com/q/21659576
type: Comment

amazon-elastic-beanstalk
tag name: amazon-elastic-beanstalk
type: Tag
tags question: http://stackoverflow.com/q/21665758
tags question: http://stackoverflow.com/q/21580919

http://stackoverflow.com/comment/32764507
type: Comment
has text: The value displaying may be due to browser caching..add some random values along with url as querystring and please check. example http://www.myurl.com?randomVal=somerandomValue.
comment on: http://stackoverflow.com/q/21674440
score: 0
type: QuestionComment

http://stackoverflow.com/a/21578275
answers question: http://stackoverflow.com/q/21577453
upvote count: 1
score: 1
has body: Are you asking why do we need the notation List&lt;?&gt; when the simpler List is equivalent? Using the wildcard is more explicit but the simpler syntax is required for backwards compatibility with pre-generics code. So you can use either interchangeably but there is also a third way of declaring this list which is also equivalent. List&lt;? extends Object&gt; list; This list will contain only objects of type Object. Since everything in Java extends from Object this is basically the same as saying unbounded. Personally of the three I would probably use the first one because it is concise while still explicitly stating what the List should contain. If you just declared it as a List without a generic argument then it could be mistaken for a pre-generics list. When would you ever want to use this? From experience I have only used this kind of unbounded list with legacy code. I was always taught to only put objects of one common type into a list (like a list of customers etc). However, people don't always write nice code and at times I've had to deal with lists containing different types. In these cases it was hard to move to a proper genericised list so I had to make do with an unbounded list. It is possible that you may have a legitimate cause for an unbounded list. It depends what you want to do with those objects. If once they've been added to the list you only need to call methods from the Object class (like toString) or perhaps the List interface (like size), then perhaps you have a genuine use case for an unbounded list.
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/21577453

http://stackoverflow.com/comment/32615031
has text: Why do you want to use Ant? If you're not building Java programs, using Ant will actually make things more complex.
comment on: http://stackoverflow.com/q/21583042
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21571240
tagged with: switch-statement
has answer: http://stackoverflow.com/a/21571376
tagged with: if-statement
has answer: http://stackoverflow.com/a/21571334
answer count: 5
has comment: http://stackoverflow.com/comment/32582772
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21571327
has comment: http://stackoverflow.com/comment/32582903
has comment: http://stackoverflow.com/comment/32582719
has title: How can I make this if-else statement into a switch statement?
type: Question
has answer: http://stackoverflow.com/a/21571293
score: 0
has answer: http://stackoverflow.com/a/21571300
tagged with: java
has body: Here is my if-else statement: public static void main(String[] args) { Scanner input = new Scanner (System.in); int number; System.out.println("Enter Integer: "); number = input.nextInt(); if (number % 7 == 0) { System.out.println(number + " is divisible by 7"); } else { System.out.println(number + " isn't divisible by 7"); } }

http://stackoverflow.com/q/21661515
has comment: http://stackoverflow.com/comment/32741235
has answer: http://stackoverflow.com/a/21661810
has answer: http://stackoverflow.com/a/21661574
has body: I have a jnlp application that loads and executes a jar file ( client ) on a users computer. The user uses this jar to communicate with a server that provides a services. I've seen users using javassit and javasnoop to alter the functionality of the client. Is there any way I can remotelly detect changes created by the previously mentionted utilities ? For example, can I checksum the classes locally and send the result to the server ( who knows the correct checksum of each class ) ?
has answer: http://stackoverflow.com/a/21661857
type: Question
tagged with: bytecode
tagged with: java
score: 0
answer count: 3
tagged with: security
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32825848
has title: Bytecode injection countermeasures in jar files

http://stackoverflow.com/a/21657218
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/21657147
upvote count: 1
has body: You have a mess of code thrown together and half it it isn't needed. To find if a symbol is not defined, look at the line of code in your IDE where it is complaining and see why that variable is not in scope. If you only write the code you need, there is less chance of making a mistake, and it is easier to see where the mistake is. This is how I would write it public class DividesAB { public static void main(String[] args) { int a = 208, b = 7; System.out.printf("a: %,d divides b: %,d is %s%n", divides(a, b)); } //write your code here public static boolean divides(int a, int b){ return a % b == 0 || b % a == 0; } }
type: Answer

http://stackoverflow.com/comment/32622317
comment on: http://stackoverflow.com/a/21593171
type: AnswerComment
score: 0
type: Comment
has text: *"How do you take those nice screenshots?"* See [How do I create a screenshot to illustrate a post](http://meta.stackexchange.com/questions/99734/how-do-i-create-a-screenshot-to-illustrate-a-post)?

http://stackoverflow.com/a/21573273
has comment: http://stackoverflow.com/comment/32587686
type: Answer
has body: You need to modify you validateAffiliate(Affiliate affiliate) method of the AffiliateService class. You have never initialized the Data Source which is causing NPE to occur. Check this: private Affiliate validateAffiliate(Affiliate affiliate) { this.affiliate=affiliate; if(affiliate!=null){ AffiliateDAO afd=new AffiliateDAO(); // This was causing NPE. Data source must be set before using it. afd.setDataSource(passDataSourceInstance); afd.insertAffiliate(affiliate); }
upvote count: 2
accepted answer of: http://stackoverflow.com/q/21573193
has comment: http://stackoverflow.com/comment/32588860
has comment: http://stackoverflow.com/comment/32588119
answers question: http://stackoverflow.com/q/21573193
score: 2
has comment: http://stackoverflow.com/comment/32588724
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/32666536
comment on: http://stackoverflow.com/q/21618575
type: QuestionComment
has text: @user3083578 use `.equals()` to compare object, not `==`
type: Comment
score: 0

http://stackoverflow.com/comment/32653385
type: Comment
type: QuestionComment
has text: What means "doesn't work"? In a sense, almost any piece of software doesn't work.
score: 0
comment on: http://stackoverflow.com/q/21611037

http://stackoverflow.com/tag/pdf
tags question: http://stackoverflow.com/q/21548552
tags question: http://stackoverflow.com/q/21627918
tags question: http://stackoverflow.com/q/21638628
type: Tag
tag name: pdf
tags question: http://stackoverflow.com/q/21597534
tags question: http://stackoverflow.com/q/21546232
tags question: http://stackoverflow.com/q/21577944
tags question: http://stackoverflow.com/q/21612400
tags question: http://stackoverflow.com/q/21557905
tags question: http://stackoverflow.com/q/21601153
tags question: http://stackoverflow.com/q/21664709
tags question: http://stackoverflow.com/q/21665780

http://stackoverflow.com/comment/32659174
score: 0
type: QuestionComment
type: Comment
has text: @Jimothy The question involved Strings, but I had converted it to a char array when this discussion came up.
comment on: http://stackoverflow.com/q/21614298

http://stackoverflow.com/comment/32895849
type: AnswerComment
has text: Yes I've got only one origin. Can you explain the last paragraph in detail please. Or provide a little example.
type: Comment
comment on: http://stackoverflow.com/a/21697138
score: 0

http://stackoverflow.com/q/21658335
has answer: http://stackoverflow.com/a/21658392
has body: Hashtable and Collections.synchronizedMap are thread safe but still compound operations like if (!map_obj.containsKey(key)) { map_obj.put(key, value); } needs external synchronization as: synchronized(map_obj) { if (!map_obj.containsKey(key)) { map_obj.put(key, value); } } Suppose we have ConcurrentHashMap(CHM) instead of Hashtable or HashMap. CHM provides an alternative putIfAbsent() method for the above compound operation, thus removing the need of external synchronization. But suppose there is no putIfAbsent() provided by CHM. Then can we write following code: synchronized(concurrenthashmap_obj) { if (!concurrenthashmap_obj.containsKey(key)) { concurrenthashmap_obj.put(key, value); } } I mean can we use external synchronization on CHM object?Will it work? For above compound operation there is putIfAbsent() method in CHM but how can we achieve thread safety for other compound operations if we are using CHM. I mean can we use external synchronization on CHM object?
has answer: http://stackoverflow.com/a/21658503
has answer: http://stackoverflow.com/a/21658377
favorite count: 0
has answer: http://stackoverflow.com/a/21658378
type: UnansweredQuestion
score: 11
has answer: http://stackoverflow.com/a/21658390
tagged with: collections
downvote count: 1
has answer: http://stackoverflow.com/a/21658411
tagged with: java
tagged with: thread-safety
has title: ConcurrentHashMap and compound operations
type: Question
upvote count: 12
answer count: 6

http://stackoverflow.com/comment/32620055
type: QuestionComment
type: Comment
has text: There is essentially a `main` method somewhere else in Android and that one does `new Activity()` and calls `activity.onCreate(someContext)`. The rest is standard java, class initialization is done once (i.e. `static` variables), then instance initialization (fields, constructors, ..)
comment on: http://stackoverflow.com/q/21591708
score: 0

http://stackoverflow.com/q/21593565
has title: What exception is thrown while creating a file in java
score: 0
has comment: http://stackoverflow.com/comment/32623740
has comment: http://stackoverflow.com/comment/32622474
has comment: http://stackoverflow.com/comment/32622424
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/72411478
has body: import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; public class Filewrite { public static void main(String args[]) { try{ String content="This is my world"; File f=new File("D:/abc.txt"); }catch(IOException i) { i.printStackTrace(); } } } Compilation of the above code gives an error: IO exception is never thrown by this corresponding try block. What exception may be thrown while creating a file?
answer count: 4
has answer: http://stackoverflow.com/a/21594080
tagged with: java
has answer: http://stackoverflow.com/a/21593630
has answer: http://stackoverflow.com/a/21593585
type: Question

http://stackoverflow.com/q/21663225
type: Question
answer count: 2
upvote count: 0
score: -3
has body: I really don't understand why i get a nullpointerexception on this one. Been struggling with this code for hours now and really can't figure it out.. Hope you see anything, and let me know if you need any more code. public void createForest() { String name = textField_name.getText(); String location = textField_location.getText(); String squaretemp = textField_squaremetre.getText(); String treesorts = textField_treesorts.getText(); String pricetemp = textField_price.getText(); // Convert double squaremetre = Double.parseDouble(squaretemp); double price = Double.parseDouble(pricetemp); forestOwnerCtr.createForest(name, location, squaremetre, treesorts, price); forestOwnerCtr.printForestList(); } My error in console is: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at GUI.CreateForest.createForest(CreateForest.java:131) at GUI.CreateForest$2.actionPerformed(CreateForest.java:104) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) at java.awt.Component.processMouseEvent(Component.java:6414) at javax.swing.JComponent.processMouseEvent(JComponent.java:3275) at java.awt.Component.processEvent(Component.java:6179) at java.awt.Container.processEvent(Container.java:2084) at java.awt.Component.dispatchEventImpl(Component.java:4776) at java.awt.Container.dispatchEventImpl(Container.java:2142) at java.awt.Component.dispatchEvent(Component.java:4604) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4279) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4209) at java.awt.Container.dispatchEventImpl(Containe…
tagged with: nullpointerexception
has comment: http://stackoverflow.com/comment/32743894
has answer: http://stackoverflow.com/a/21663719
has comment: http://stackoverflow.com/comment/32743942
has answer: http://stackoverflow.com/a/21663372
has comment: http://stackoverflow.com/comment/32743898
favorite count: 0
possible better answer: http://stackoverflow.com/a/21663372
has title: Can anyone spot why i have a nullpointerexception?
has comment: http://stackoverflow.com/comment/32743863
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21663719
tagged with: java
downvote count: 3
has comment: http://stackoverflow.com/comment/32743903
has comment: http://stackoverflow.com/comment/32743867

http://stackoverflow.com/a/21703519
downvote count: 0
has body: I faced a similar problem but in Javascript. Someone answered it for me with a recursive algorithm here: Convert parent-child array to tree It might not be perfect as-is but hopefully it will give you a starting point.
type: Answer
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/21570138

http://stackoverflow.com/q/21597534
tagged with: itext
has comment: http://stackoverflow.com/comment/32630391
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32630081
tagged with: java
accepted answer: http://stackoverflow.com/a/21617347
tagged with: forms
type: Question
has comment: http://stackoverflow.com/comment/32632142
answer count: 1
has title: PDF acroforms not being copied properly in itext
tagged with: http://stackoverflow.com/tag/pdf
has answer: http://stackoverflow.com/a/21617347
has body: So I have this PDF form and set the fields to it: PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest + i + ".pdf")); AcroFields form = stamper.getAcroFields(); form.setField("name", "Bruno Lowagie"); form.setField("adress", "ADDRESS"); form.setField("dates", "January 1, 2010"); form.setField("titles", "blah blah blah"); stamper.close(); reader.close(); However when i try to copy all the files to a another file, Fields only appear on focus of the fields, pelase help Document document = new Document(); PdfCopy pcf = new PdfCopy(document, new FileOutputStream(ALL_CUSTOMER_FILE)); pcf.setMergeFields(); document.open(); int documentnumber = 0; for (String input : inputs) { PdfReader reader = new PdfReader(input); documentnumber++; renameFields(reader, documentnumber); pcf.addDocument(reader); } pcf.close(); document.close();
score: 0

eclipse-rcp
tags question: http://stackoverflow.com/q/21580564
tags question: http://stackoverflow.com/q/21607480
tags question: http://stackoverflow.com/q/21582108
tags question: http://stackoverflow.com/q/21625476
type: Tag
tags question: http://stackoverflow.com/q/21562408
tags question: http://stackoverflow.com/q/21660030
tags question: http://stackoverflow.com/q/21655669
tags question: http://stackoverflow.com/q/21627459
tags question: http://stackoverflow.com/q/21574744
tags question: http://stackoverflow.com/q/21587190
tags question: http://stackoverflow.com/q/21657300
tags question: http://stackoverflow.com/q/21569981
tag name: eclipse-rcp
tags question: http://stackoverflow.com/q/21610806
tags question: http://stackoverflow.com/q/21607537

http://stackoverflow.com/comment/32710807
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21644142
has text: Thanks for your input. I copied the SSCE to the end now. And I feel you on the formatting issue.
score: 0

http://stackoverflow.com/q/21518208
tagged with: java
type: Question
tagged with: nested-class
has title: Referencing inner class instances from the outer class
has answer: http://stackoverflow.com/a/21518238
possible better answer: http://stackoverflow.com/a/21518493
accepted answer: http://stackoverflow.com/a/21518238
has body: I've just started working through the Java tutorials again and I decided to spend some time playing with nested classes. The working copy I've made is a Bicycle class which could have zero or more Rider class instances within it. From within an instance of Bicycle, I'd like to be able to work with instances of Riders. In the example below, my Bicycle has an ArrayList which holds its Riders, but I'd like to avoid having to maintain this list if possible. My question is this. Is there another way to reference instances of Rider from Bicycle, or do I have to maintain my own list? //Outer Class contains zero or more Inner Classes public class Bicycle { //ArrayList of Inner Class instances private List&lt;Rider&gt; Riders = new ArrayList&lt;Rider&gt;(); class Rider { private String riderName; protected Rider(String newRiderName) { this.riderName = newRiderName; } protected String GetRiderName(){ return riderName; } } //When creating an Outer Class, we can instantiate zero or more Inner Classes, by name public Bicycle(String... startingRiderName) { //Loop through all Inner Class instance names and create an Inner Class for each for (String newRiderName : startingRiderName) { Riders.add(new Rider(newRiderName)); } } //Public method to return an array of Inner Class instance names public String[] GetRiderNames() { String[] riderNames = new String[Riders.size()]; // Just in case we mess up and ask the ArrayList for an out of bounds index try { for (int riderIndex = 0; riderIndex &lt; Riders.size(); riderIndex++) { riderNames[riderIndex] = Riders.get(riderIndex).GetRiderName(); } return riderNames; } catch (IndexOutOfBoundsException e) { return null; } } }
has answer: http://stackoverflow.com/a/21518493
score: 0
answer count: 2
upvote count: 1
downvote count: 1
favorite count: 0
type: AnsweredQuestion

http://stackoverflow.com/comment/32646721
comment on: http://stackoverflow.com/a/21569668
type: AnswerComment
score: 0
type: Comment
has text: In the servlet, try reading and closing the input stream before getting the output stream. That's all I can think of...

http://stackoverflow.com/q/21668919
has answer: http://stackoverflow.com/a/21669167
tagged with: java
has comment: http://stackoverflow.com/comment/32754262
type: Question
has comment: http://stackoverflow.com/comment/32754372
has body: When i looked up the implementation of CharMatcher and notice a field WHITESPACE_MULTIPLIER=1682554634 , then i set this value to 1582554634 , running the testcase CharMatcherTest#testWhitespaceBreakingWhitespaceSubset, of course it failed. After that I changed testWhitespaceBreakingWhitespaceSubset to only invoke WHITESPACE.apply((char)c) without assert, print the index in the method of WHITESPACE.matches int index=(WHITESPACE_MULTIPLIER * c) &gt;&gt;&gt; WHITESPACE_SHIFT) finally found that index collided after changed the WHITESPACE_MULTIPLIER from 1682554634 to 1582554634 No doubt, 1682554634 is well designed , my question is how can I infer this "magic number"?` Upon Martin Grajcar's proposal, I try to write the "magic number generator" as follows and worked : char[] charsReq = WHITESPACE_TABLE.toCharArray(); Arrays.sort(charsReq); OUTER: for (int WHITESPACE_MULTIPLIER_WANTTED = 1682553701; WHITESPACE_MULTIPLIER_WANTTED &lt;= 1682554834; WHITESPACE_MULTIPLIER_WANTTED++) { int matchCnt = 0; for (int c = 0; c &lt;= Character.MAX_VALUE; c++) { int position = Arrays.binarySearch(charsReq, (char) c); char index = WHITESPACE_TABLE.charAt((WHITESPACE_MULTIPLIER_WANTTED * c) &gt;&gt;&gt; WHITESPACE_SHIFT); if (position &gt;= 0 &amp;&amp; index == c) { matchCnt++; } else if (position &lt; 0 &amp;&amp; index != c) { matchCnt++; } else { continue OUTER; } } // all valid if ((matchCnt - 1) == (int) (Character.MAX_VALUE)) { System.out.println(WHITESPACE_MULTIPLIER_WANTTED); } } if changed the sequence of characters(swap \u2001 \u2002 position) in WHITESPACE_TABLE the algorithms has no solution (changed the loop end condition to Integer.MAX_VALUE). as the IntMath.gcd implementation is refer to http://en.wikipedia.org/wiki/Binary_GCD_algorithm my question is : where can i find the material of CharMatcher.WHITESPACE.match implementation?
has comment: http://stackoverflow.com/comment/32755641
has comment: http://stackoverflow.com/comment/32754147
score: 0
upvote count: 1
has comment: http://stackoverflow.com/comment/32754538
answer count: 1
downvote count: 1
favorite count: 0
type: UnansweredQuestion
has title: About the CharMatcher.WHITESPACE implementation
tagged with: guava

http://stackoverflow.com/a/21575337
has body: You can't insert util date into sql date java.util.Date utilDate = affiliate.getDate(); java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime()); Now, you can insert sqlDate as ps.setDate(6, sqlDate);
has comment: http://stackoverflow.com/comment/32589907
answers question: http://stackoverflow.com/q/21575253
upvote count: 4
downvote count: 0
type: Answer
score: 4

http://stackoverflow.com/a/21590402
has comment: http://stackoverflow.com/comment/32617412
accepted answer of: http://stackoverflow.com/q/21590117
score: 1
answers question: http://stackoverflow.com/q/21590117
type: AcceptedAnswer
upvote count: 1
type: Answer
has body: There are two major modifications to make this code work. First the PrintWriter must be declared and instantiated outside of the loop. And the calls to println must occur inside of the loop. Second, the doubles must be converted to a String prior to printing and substring appropriately. Scanner in = new Scanner(System.in); System.out.print("How many times? "); int numOfTimes = in.nextInt(); double hrTotal = 0; double minTotal = 0; PrintWriter p = new PrintWriter("Times.txt"); for (int i = 1; i &lt;= numOfTimes; i++) { System.out.println("\nEnter time in military time notation: "); System.out.print("Hour "); double hrs1 = in.nextDouble(); System.out.print("Minute "); double min1 = in.nextDouble(); hrTotal += hrs1; minTotal += min1; String hrs = String.valueOf(hrs1); String min = String.valueOf(min1); p.println(hrs.substring(0, hrs.indexOf(".")) + min.substring(0,min.indexOf("."))); } p.close(); Before this change your code was adding the two doubles hrs1 and mins1 using actual arithmetic and it was using the static variables you had declared at the top of the class. static double hrs1; static double min1; You should remove these static doubles since they are really never used. Because the call to println was outside of the loop, it was causing the static doubles to be referenced instead of hrs1 and mins1 declared and assigned inside the loop. You thought you were using the locals variables declared in the loop but they were never in scope.
downvote count: 0

http://stackoverflow.com/comment/32714371
score: 0
comment on: http://stackoverflow.com/a/21645699
type: AnswerComment
type: Comment
has text: I tried to type it like this `timer.start();` It doesn't have any errors like it does before. However, when I tried running it, errors come out.

http://stackoverflow.com/comment/32554473
score: 0
comment on: http://stackoverflow.com/a/21542833
type: Comment
has text: Thank you for the help. The ID 4 did exist but did nothing. My connection automaticely had `conn.setAutoCommit(false)` and when I set it to `conn.setAutoCommit(true)` and then add an `conn.commit()` in the end , then it worked. I still don't really get why though, so I'm gonna re-read-up on transactions and try to figure out why it would work ( everything else works ). Thank you once again.
type: AnswerComment

http://stackoverflow.com/comment/32727742
comment on: http://stackoverflow.com/a/21652666
score: 0
type: AnswerComment
has text: I have changed superclass `Car` a bit and now it has `miles` and `gallons` implemented. Every type of car inherits those fields and they can be set for each car differently. It should work this way, I'm new at Java also, just trying to help.
type: Comment

http://stackoverflow.com/q/21672990
has comment: http://stackoverflow.com/comment/32761864
has comment: http://stackoverflow.com/comment/32761781
has answer: http://stackoverflow.com/a/21673188
favorite count: 0
has comment: http://stackoverflow.com/comment/32761095
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32761941
score: 1
has comment: http://stackoverflow.com/comment/32762188
has title: display image in jsp from path in struts2 action variable
tagged with: java
upvote count: 1
has comment: http://stackoverflow.com/comment/32765266
has comment: http://stackoverflow.com/comment/32761000
type: Question
has comment: http://stackoverflow.com/comment/32764760
has answer: http://stackoverflow.com/a/21673153
downvote count: 0
has comment: http://stackoverflow.com/comment/32760886
has body: i have a struts2 action which has a variable for an image which i want to display in a jsp page. when i display the value of the variable using the following: &lt;s:property value="variableName" /&gt; i get the absolute path of the image file. but when i try the following: &lt;img src='&lt;s:property value="variableName" /&gt;' /&gt; i get a blank there. i have even tried the following: &lt;img src="${variableName}" /&gt; EDIT: i have done some thinking. the path of the image which is set is in temp folder of tomcat. is it because of that that i am unable to access it? to no effect. what may be the issue in this?
tagged with: struts2
answer count: 2

http://stackoverflow.com/q/21538998
tagged with: wiki
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/32528535
has body: I have a huge xml file from wiktionary that I need to parse for a class project. I only need to extract data from a set of 200 lines, which start at line 395,000. How would I go about only scanning that small number of lines? Is there some sort of built in property for line number?
score: 0
has title: Dealing with specific lines when parsing XML docs in Java
has answer: http://stackoverflow.com/a/21547747
tagged with: parsing
tagged with: http://stackoverflow.com/tag/xml
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21539099
tagged with: java

http://stackoverflow.com/q/21573758
has title: Import Image in Graphics
tagged with: java
has answer: http://stackoverflow.com/a/21573865
score: -1
tagged with: image
possible better answer: http://stackoverflow.com/a/21586584
tagged with: import
type: Question
answer count: 2
upvote count: 0
linked to: http://stackoverflow.com/q/21525019
accepted answer: http://stackoverflow.com/a/21573865
has body: I have the following code, and I am struggling to what to do after I have the JLabel loaded. How do I show it and give it coordinates as to where to be placed? I tried some solutions on the web, but they dont quite seem to work by giving errors like "Cant find getCodeBased" and similar. Can someone please help? I am still a beginner, so please dont be harsh. import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; import java.awt.Image; public class ChessBoard extends JFrame implements ActionListener { private JButton button; private JPanel panel; JLayeredPane layeredPane; public static void main(String[] args) { ChessBoard demo = new ChessBoard(); demo.setSize(900,900); demo.createGUI(); demo.setVisible(true); } private void createGUI() { setDefaultCloseOperation(EXIT_ON_CLOSE); Container window = getContentPane(); window.setLayout(new FlowLayout()); panel = new JPanel(); panel.setPreferredSize(new Dimension(800,800)); panel.setBackground(Color.white); window.add(panel); button = new JButton("start"); window.add(button); button.addActionListener(this); } public void actionPerformed(ActionEvent event) { int xLeft; int yTop; Graphics paper = panel.getGraphics(); paper.setColor(Color.black); paper.fillRect(0,0,800,800); paper.setColor(Color.white); xLeft = 0; for (int i = 100; i &lt; 800; i += 100) { paper.drawLine(i,0,i,800); } for (int i = 100; i &lt; 800; i += 100) { paper.drawLine(0, i, 800, i); } for (int j = 1; j &lt; 9; j++) { paper.setColor(new Color(238, 221, 187)); for (int k = 100 * ((j+1) % 2); k &lt; 800; k+=200) { paper.fillRect (k, (j-1) * 100, 100, 100); } paper.setColor(new Color(204,136,68)); for (int i = 100 * (j%2); i &lt; 800; i+=200) { paper.fillRect(i, (j-1) * 100, 100, 100); } } } public void paint(Graphics g) { JLabel piece = new JLabel( new ImageIcon(getClass().getResource("Rooka8.png"))); } } P.S. Managed to fix it myself, by trying posting the code below in the ActionPerformed method, as well as import java.awt.…
favorite count: 0
has comment: http://stackoverflow.com/comment/32588574
tagged with: swing
downvote count: 1
has answer: http://stackoverflow.com/a/21586584
type: AnsweredQuestion

http://stackoverflow.com/comment/32760861
has text: Where are you stuck? Did you try something?
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21672727

http://stackoverflow.com/a/21677034
downvote count: 0
type: AcceptedAnswer
score: 4
answers question: http://stackoverflow.com/q/21546433
has body: I found the solution for this. Before this, I had copied the folder src/main/config into src/main/resouces in netbeans so it took that folder as package. So the folder name - config/db/1.0.0 got changed to config/db/1/0/0, but when I created new folder in resources folder, it worked and all the files in folder 1.0.0 are accessible correctly. Now, my folder structure is like this: resources config db 1.0.0 db.changelog.201412120101.xml 1.1.0 2.0.0 db.changelog.xml I can access db.changelog.xml file from my Spring class as, springLiquibaseObj.setChangeLog("classpath:db.changelog.xml"); and other changelog files from db.changelog.xml file as, &lt;include file="classpath:config/db/1.0.0/db.changelog-201412120101.xml" relativeToChangelogFile="false" /&gt;.
type: Answer
accepted answer of: http://stackoverflow.com/q/21546433
upvote count: 4

http://stackoverflow.com/q/21522341
score: 77
tagged with: java-stream
upvote count: 77
has title: Collection to stream to a new collection
linked to: http://stackoverflow.com/q/122105
has answer: http://stackoverflow.com/a/21522635
has comment: http://stackoverflow.com/comment/32495646
tagged with: java-8
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21526973
tagged with: java
possible better answer: http://stackoverflow.com/a/21522635
type: Question
has body: I'm looking for the most pain free way to filter a collection. I'm thinking something like Collection&lt;?&gt; foo = existingCollection.stream().filter( ... ). ... But I'm not sure how is best to go from the filter, to returning or populating another collection. Most examples seem to be like "and here you can print". Possible there's a constructor, or output method that I'm missing.
downvote count: 0
has comment: http://stackoverflow.com/comment/32495571
has answer: http://stackoverflow.com/a/62853691
has answer: http://stackoverflow.com/a/21526973
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/21522612

http://stackoverflow.com/comment/33816619
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/21546990
type: Comment
has text: As I said, "This is likely to wreak havoc with the caret and edit controls."

http://stackoverflow.com/q/21526544
has title: Number format of ValueBox<Double>
tagged with: gwt
has comment: http://stackoverflow.com/comment/32509678
has body: I found a strange bug. I have a class derived from ValueBox&lt;Double&gt; to display numbers. I add some styling to it to make it prettier using setStyleName(); It has worked well for some time now, but just now I noticed a strange bug. If I set a value greater than 999 the display is blanked. I figured out that if I remove my call this.getElement().setAttribute("type", "number"); everything works as it should. I suspect the problem is that values over 999 is displayed as 1.000 and that is not acceptable as a number. It work in Firefox, but fails in Chrome/Chromium. No wonder since Firefox ignores the type attribute anyway. So there are two ways to solve it. get it accepted as a number change the formatting to leave out or change the separator But how?
downvote count: 0
has comment: http://stackoverflow.com/comment/32502856
has comment: http://stackoverflow.com/comment/32504216
favorite count: 0
type: UnansweredQuestion
tagged with: http://stackoverflow.com/tag/html
has comment: http://stackoverflow.com/comment/32511265
answer count: 0
score: 1
tagged with: java
upvote count: 1
type: Question

http://stackoverflow.com/comment/32705192
type: Comment
has text: I'll include a runnable jar demo. Thanks!
comment on: http://stackoverflow.com/q/21640493
score: 0
type: QuestionComment

http://stackoverflow.com/q/21594859
tagged with: servlets
upvote count: 1
favorite count: 0
type: UnansweredQuestion
has title: Cookie encryption and decryption using Servlet filters
tagged with: encryption
answer count: 0
downvote count: 0
tagged with: cookies
score: 1
tagged with: java
type: Question
has body: Is any function or api available to intercept addCookie() so that the cookies set by the servlet will be encrypted using servlet filters. And when the getCookies() is invoked the filter would decrypt it and give the response back to web server. Actually all this is done to prevent XSS attack. I am not able to find any documentation or info. regarding encryption and decryption of cookies using servlet Filters.. Any help would be gratefull.

http://stackoverflow.com/a/21552332
answers question: http://stackoverflow.com/q/21552303
downvote count: 0
type: Answer
upvote count: 1
score: 1
has body: Yes, this can be achieved. If you have a reference to your CheckBox you can call the methods of the Checkable interface: setChecked(boolean), isChecked() and toggle().

http://stackoverflow.com/comment/32509571
type: QuestionComment
has text: so when i change the formate so what do you think it will be correct result
score: 0
comment on: http://stackoverflow.com/q/21529351
type: Comment

http://stackoverflow.com/a/21555153
upvote count: 2
has body: In general, code is represented once, no matter how many objects there are. The OO concept of objects "having" methods is just an abstraction. So, in essence, regardless of whether you method is instanced or static, behind the scenes it still "belongs" to the class. For final methods, the call uses static binding (it's already predetermined which method will be called, based on the type of the expression). For virtual methods, something more interesting happens. Depending on the implementation, either the object contains the address to the correct method (not the method itself, again) or the runtime reflects on that object to determine its actual class and find the appropriate method in the hierarchy.
type: Answer
score: 2
answers question: http://stackoverflow.com/q/21554988
downvote count: 0

http://stackoverflow.com/a/21595045
has body: This will help you out. try{ ArrayList&lt;WebElement&gt; cells = (ArrayList&lt;WebElement&gt;) driver.findElements(By.tagName("td")); log4j.info("Value = "+input_type+" is stored in array from Webpage for "+keyword+" "); for(WebElement type : cells) { if(type.getAttribute("name").equals("your correct name here")) { type.sendKeys("ABC"); } } return true; }catch(Throwable e){ return false; } You need to use Array list like this and you can compare your Name in which you wanna fill value Or wanna do any operation like getText(), click() etc. Enjoy!
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/32641514
has comment: http://stackoverflow.com/comment/32641561
has comment: http://stackoverflow.com/comment/32641041
score: 0
answers question: http://stackoverflow.com/q/21591027
type: Answer
has comment: http://stackoverflow.com/comment/32642697
has comment: http://stackoverflow.com/comment/32640520

http://stackoverflow.com/comment/32707202
has text: As a matter of fact, [yes](http://www.frischcode.com/2013/11/clean-up-after-yourself.html).
comment on: http://stackoverflow.com/q/21642032
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/a/21599833
answers question: http://stackoverflow.com/q/21599451
score: 4
type: Answer
has comment: http://stackoverflow.com/comment/32633736
has comment: http://stackoverflow.com/comment/32633527
has body: You may want to have a look on Zip4j Key features: Create, Add, Extract, Update, Remove files from a Zip file Read/Write password protected Zip files Supports AES 128/256 Encryption Supports Standard Zip Encryption Supports Zip64 format Supports Store (No Compression) and Deflate compression method Create or extract files from Split Zip files (Ex: z01, z02,...zip) Supports Unicode file names Progress Monitor
upvote count: 4
has comment: http://stackoverflow.com/comment/32633963
downvote count: 0

http://stackoverflow.com/q/21534891
has answer: http://stackoverflow.com/a/21534910
type: Question
answer count: 2
downvote count: 4
possible better answer: http://stackoverflow.com/a/21534931
upvote count: 0
has answer: http://stackoverflow.com/a/21534931
has title: Unfortunately (App Name) Has Stopped Working?
score: -4
favorite count: 0
tagged with: android
accepted answer: http://stackoverflow.com/a/21534910
type: AnsweredQuestion
has body: I am new to Java, and, particularly, Android Development. I have a menu and two other items work on the menu (MainActivity, and a Splash Screen), but when I run this class, Gentile, from the menu the App crashes: public class Gentile extends Activity { Random rand = new Random(); Button ranNumBut; int ranNum = rand.nextInt(50) + 1; TextView display2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ranNumBut= (Button) findViewById(R.id.rand); display2 = (TextView) findViewById(R.id.tvDisplay2); ranNumBut.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { display2.setText("ranNum"); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } }
tagged with: java

http://stackoverflow.com/comment/32600916
comment on: http://stackoverflow.com/q/21581383
score: 0
type: Comment
has text: There is a log4j SMTP appender, but I don't know if you can have it send logs or whatever on a schedule.
type: QuestionComment

http://stackoverflow.com/comment/32872712
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21667425
has text: @LyubenTodorov The keyspace already exists.
type: Comment

http://stackoverflow.com/q/21669363
has comment: http://stackoverflow.com/comment/32755145
has answer: http://stackoverflow.com/a/21669517
has title: Java how is a main method invked by JVM
tagged with: jvm
duplicate of: http://stackoverflow.com/q/4446542
has comment: http://stackoverflow.com/comment/32755286
downvote count: 2
tagged with: multithreading
linked to: http://stackoverflow.com/q/4446542
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21669517
tagged with: java
has comment: http://stackoverflow.com/comment/32755008
has comment: http://stackoverflow.com/comment/32755349
has comment: http://stackoverflow.com/comment/32754849
type: Question
has body: A friend of mine told me that in java, there is a main group which in-turn has a main thread and this thread contains a main method. But he wasn't able to explain me how the main thread is invoked by JVAM. Could any one explain how this is implemented by JVM. I have tired searching for an answer of this in Google but that did not yield any good result.
has comment: http://stackoverflow.com/comment/32754829
upvote count: 0
score: -2
answer count: 1
linked to: http://stackoverflow.com/q/17432963
favorite count: 0

http://stackoverflow.com/a/21667446
answers question: http://stackoverflow.com/q/21667356
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32755069
accepted answer of: http://stackoverflow.com/q/21667356
type: Answer
has body: The first problem is that if hasNextInt() is false, you need to do something to get the scanner past the illegal input. If you don't, the scanner's cursor (which points to the next input to be looked at) will remain in the same place forever and ever, leading to an infinite loop. If you execute this when hasNextInt() is false: sc.nextLine(); that will flush out everything else on the line, allowing the user to type in new input. This fix isn't enough; when I added this, I got other exceptions, which I think are related to the fact that you're opening a new Scanner for each input line. This shouldn't be necessary. You can initialize sc to a new Scanner when a TheValidator is created; and you might need to add a close method to TheValidator that closes the scanner.
has comment: http://stackoverflow.com/comment/32751835
score: 0

http://stackoverflow.com/comment/41572516
comment on: http://stackoverflow.com/a/21632640
score: 3
type: AnswerComment
type: Comment
has text: FYI, for .NET developers, Visual Studio shows these comments when you hover your mouse over a method name -- even for private methods -- so for .NET code, it makes sense to do this.

http://stackoverflow.com/a/36191887
has body: Here you go with a simple HashMap technique , refer the Below code for Caluclating average and find the Beststudent from it,Understand it well , I might help you Thanks... import java.util.*; public class QueQue { public static float getAverage(HashMap&lt;String, ArrayList&lt;Integer&gt;&gt; hm, String name) { ArrayList&lt;Integer&gt; scores; scores = hm.get(name); if (scores == null) { System.out.println("NOT found"); } int sum = 0; for (int x : scores) { sum += x; } return (float) sum / scores.size(); } // The best students from these Key-Value Pair public static String getBestStudent(HashMap&lt;String, ArrayList&lt;Integer&gt;&gt; hm) { double max = 0; String beststudent = null; for (Map.Entry&lt;String, ArrayList&lt;Integer&gt;&gt; x : hm.entrySet()) { String name = x.getKey(); double average = getAverage(hm, name); if (average &gt; max) { max = average; beststudent = name; } } return beststudent; } public static void main(String[] args) { HashMap&lt;String, ArrayList&lt;Integer&gt;&gt; hm = new HashMap&lt;&gt;(); hm.put("Peter", new ArrayList&lt;&gt;()); hm.get("Peter").add(10); hm.get("Peter").add(10); hm.get("Peter").add(10); hm.put("Nancy", new ArrayList&lt;&gt;()); hm.get("Nancy").add(7); hm.get("Nancy").add(8); hm.get("Nancy").add(8); hm.put("Lily", new ArrayList&lt;&gt;()); hm.get("Lily").add(9); hm.get("Lily").add(9); hm.get("Lily").add(8); System.out.println("Find the average of the Peter"); float num = getAverage(hm, "Peter"); System.out.println(num); String name = getBestStudent(hm); System.out.println(name); } }
downvote count: 0
answers question: http://stackoverflow.com/q/21666273
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/comment/32540708
comment on: http://stackoverflow.com/a/21547984
score: 0
type: AnswerComment
type: Comment
has text: Now error getting after putting ";" as "The import View cannot be resolved"

http://stackoverflow.com/a/21646229
upvote count: 3
answers question: http://stackoverflow.com/q/21645250
type: AcceptedAnswer
has body: May be you are looking for something like this: //You can bind key to JComponent, So whenever you press ENTER on 'JComponentit does desired operation say Transfer Focus to nextJComponent`, like: jComponent.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "TransferFocus"); jComponent.getActionMap().put("TransferFocus", action); //You can bind key to JButton, So whenever you press ENTER on 'JButtonit does desired operation say Click theJButton`, like: jButton.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "DoClick"); jButton.getActionMap().put("DoClick", action); //action AbstractAction action = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if(e.getSource() instanceof JButton){ JButton button = (JButton) e.getSource(); button.doClick(); } else if(e.getSource() instanceof JComponent){ JComponent component = (JComponent) e.getSource(); component.transferFocus(); } } };
type: Answer
score: 3
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21645250

http://stackoverflow.com/comment/32574785
has text: You never initialize `member` in `groupclass`; it's `null`. What is the confusion?
comment on: http://stackoverflow.com/q/21566605
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/a/21581246
score: 0
has body: If you want something solid to organize all your communication layer checkout Spring for Android , then you can easily implement in a transparent way all what you need example of POST in JSON
type: Answer
answers question: http://stackoverflow.com/q/21579756

http://stackoverflow.com/comment/32578149
comment on: http://stackoverflow.com/a/21568259
type: AnswerComment
score: 0
type: Comment
has text: Yes, can you explain how I could get to my answer because I don't really understand the entire concept of loops in general.

http://stackoverflow.com/q/21667864
has title: Use DecimalFormat to get varying amount of decimal places
has answer: http://stackoverflow.com/a/21668553
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/32815632
has comment: http://stackoverflow.com/comment/32752518
has body: So I want to use the Decimal Format class to round numbers: double value = 10.555; DecimalFormat fmt = new DecimalFormat ("0.##"); System.out.println(fmt.format(value)); Here, the variable value would be rounded to 2 decimal places, because there are two #s. However, I want to round value to an unknown amount of decimal places, indicated by a separate integer called numPlaces. Is there a way I could accomplish this by using the Decimal Formatter? e.g. If numPlaces = 3 and value = 10.555, value needs to be rounded to 3 decimal places
type: Question
has answer: http://stackoverflow.com/a/21667955
has answer: http://stackoverflow.com/a/21667917
accepted answer: http://stackoverflow.com/a/21667917
has comment: http://stackoverflow.com/comment/32829941
has comment: http://stackoverflow.com/comment/32771670
possible better answer: http://stackoverflow.com/a/21668015
downvote count: 0
tagged with: string
has answer: http://stackoverflow.com/a/21668015
has comment: http://stackoverflow.com/comment/32782359
favorite count: 0
has comment: http://stackoverflow.com/comment/32815700
has comment: http://stackoverflow.com/comment/32753125
score: 6
upvote count: 6
tagged with: decimalformat
answer count: 4

junit
type: Tag
tags question: http://stackoverflow.com/q/21549380
tags question: http://stackoverflow.com/q/21673375
tags question: http://stackoverflow.com/q/21611366
tags question: http://stackoverflow.com/q/21673658
tags question: http://stackoverflow.com/q/21556073
tags question: http://stackoverflow.com/q/21586409
tags question: http://stackoverflow.com/q/21627799
tags question: http://stackoverflow.com/q/21553342
tags question: http://stackoverflow.com/q/21627479
tags question: http://stackoverflow.com/q/21585892
tags question: http://stackoverflow.com/q/21591851
tag name: junit
tags question: http://stackoverflow.com/q/21624592
tags question: http://stackoverflow.com/q/21628582
tags question: http://stackoverflow.com/q/21520853
tags question: http://stackoverflow.com/q/21612890
tags question: http://stackoverflow.com/q/21608074
tags question: http://stackoverflow.com/q/21613422
tags question: http://stackoverflow.com/q/21654057
tags question: http://stackoverflow.com/q/21536085
tags question: http://stackoverflow.com/q/21677315
tags question: http://stackoverflow.com/q/21592922
tags question: http://stackoverflow.com/q/21607137
tags question: http://stackoverflow.com/q/21620484
tags question: http://stackoverflow.com/q/21582378
tags question: http://stackoverflow.com/q/21595642
tags question: http://stackoverflow.com/q/21586244
tags question: http://stackoverflow.com/q/21637070
tags question: http://stackoverflow.com/q/21555921
tags question: http://stackoverflow.com/q/21552204

http://stackoverflow.com/comment/32666507
has text: Please refer to this answer: http://stackoverflow.com/questions/12002948/how-to-setup-jndi-for-glassfish-3-1-2-for-a-stand-alone-client/19055514#19055514
comment on: http://stackoverflow.com/q/21605583
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/21710097
score: 0
has body: I agree what has been already posted about not implementing parse functions yourself. Instead of DOM/SAX/STAX parsers though, I would suggest using JDOM or XOM, which are external libraries. Related discussions: What Java XML library do you recommend (to replace dom4j)? Should I still be using JDOM with Java 5 or 6? My gut feeling is that jdom is the one most java developers use. Some use dom4j, some xom, some others, but hardly anybody implements these parsing functions themselves.
answers question: http://stackoverflow.com/q/21534340
type: Answer

http://stackoverflow.com/comment/32674863
score: 0
has text: It could be done using reflection, I imagine, but there's really no reason to. Use some kind of collection as all the answers have suggested.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21620551

http://stackoverflow.com/a/21532370
answers question: http://stackoverflow.com/q/21532234
has body: for(int k=2; k&lt;total.length; k++);{ You need to remove the ; symbol from your loop as 'k' will not be resolved in the loop as you have terminated it. The format is for(x, x, x) { The next thing to look at now is: Dice: 1 Rolls: 1 Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 7 at Lab1.main(Lab1.java:26) Hint: total[i] = 0; // this line is the problem. Look at your &lt;= in the loop. for (int i=0; i&lt;total.length; i++) Simply chaging it to &lt; results in this: Dice: 1 Rolls: 1 Sum Frequency Percentage 2 1 0 3 0 0 4 0 0 5 0 0 6 0 0
upvote count: 1
type: Answer
downvote count: 0
score: 1

http://stackoverflow.com/q/21549135
tagged with: java
has comment: http://stackoverflow.com/comment/32543037
has comment: http://stackoverflow.com/comment/32542808
has comment: http://stackoverflow.com/comment/32542720
answer count: 2
downvote count: 2
has body: I have a code block for (i=0;i&lt;size;i++) { do job; } initially this job task was executed sequentially (as shown above) but later I made multithreaded with normal threads (inner runnable class implementation) like, for (i=0;i&lt;size;i++) { new threadingclass(some args) } runnable threadingclass { pub void run () { do job; } } this worked fine with some thread limit (till system resources were enough) so to avoid resource overloading I implemented same code with standard theadpool implementation (threadpool,executor service and worker thread implementation) threadexecutor t=new threadexecutor(size) for (i=0 ; i&lt;size ; i++) { t.execute(new threadingclass(some args)) } runnable threadingclass { pub void run () { do job; } } now scenario was like, I wanted to run loop for 25 times (no. of threads), I tried with all 3 implementations sequential : takes 7 min approx normal multithreading : 40 sec multithreading with threadpool (size : 100) : 2 min approx I am bit confused why normal threading and thredpool implementation timings differ so much and internally also threadpool does not involve much complex logic. any help is appreciated. Thanks in advance
has comment: http://stackoverflow.com/comment/32542883
has comment: http://stackoverflow.com/comment/32542804
has comment: http://stackoverflow.com/comment/32542813
has comment: http://stackoverflow.com/comment/32544645
has title: why threadpool implementation is slower than normal threads
favorite count: 0
has answer: http://stackoverflow.com/a/21549459
has comment: http://stackoverflow.com/comment/32542741
has comment: http://stackoverflow.com/comment/32543266
type: UnansweredQuestion
tagged with: multithreading
score: 6
has answer: http://stackoverflow.com/a/21549432
upvote count: 8
has comment: http://stackoverflow.com/comment/32545173
type: Question
tagged with: performance

http://stackoverflow.com/q/21596036
type: Question
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/22321576
tagged with: ibm-mq
type: UnansweredQuestion
has title: MQ-7 connectivity issue
has answer: http://stackoverflow.com/a/21610532
tagged with: java
has body: Hi below is the code I used to check the connectivity String qManager=""; int openOptions = CMQC.MQOO_FAIL_IF_QUIESCING + CMQC.MQOO_INPUT_SHARED + CMQC.MQOO_INQUIRE+CMQC.MQOO_BROWSE; try{ Hashtable props = new Hashtable(); props.put(CMQC.HOST_NAME_PROPERTY, "IP"); props.put(CMQC.PORT_PROPERTY, port_num); props.put(CMQC.CHANNEL_PROPERTY, "SYSTEM.DEFAULT.LOCAL.QUEUE"); MQQueueManager qMgr = new MQQueueManager("QM", props); MQQueue destQueue = qMgr.accessQueue("Q_name", openOptions); System.out.println("Connected"); destQueue.close(); qMgr.disconnect(); }catch(MQException mqe){ System.out.println(mqe.reasonCode); } } } When I run the program I get this Exception MQJE001: An MQException occurred: Completion Code 2, Reason 2009 MQJE016: MQ queue manager closed channel immediately during connect 2009 Closure reason = 2009 MQJE001: Completion Code 2, Reason 2009 Kindly help me

http://stackoverflow.com/comment/32722686
comment on: http://stackoverflow.com/q/21650634
has text: @AnkurShanbhag It is in windows.
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/a/21653202
accepted answer of: http://stackoverflow.com/q/21653048
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/74343363
type: Answer
upvote count: 19
has body: An array in Java is an object. When you create an array via new, it's created on the heap and a reference value (analogous to a pointer in C) is returned and assigned to your variable. In C, this would be expressed as: int *array = malloc(10 * sizeof(int)); When you pass that variable to a method, you're passing the reference value which is assigned (copied) to the local (stack) variable in the method. The contents of the array aren't being copied, only the reference value. Again, just like passing a pointer to a function in C. So, when you modify the array in your method via that reference, you're modifying the single array object that exists on the heap. You commented that you made a "copy" of the array via int[] temp=test ... again, this only makes a copy of the reference value (pointer) that points to the single array in memory. You now have three variables all holding the same reference to the same array (one in your main(), two in your method). If you want to make a copy of the array's contents, Java provides a static method in the Arrays class: int[] newArray = Arrays.copyOf(test, test.length); This allocates a new array object on the heap (of the size specified by the second argument), copies the contents of your existing array to it, then returns the reference to that new array to you.
score: 19
answers question: http://stackoverflow.com/q/21653048

http://stackoverflow.com/comment/32720348
has text: I haven't get exception, I got the result `0.0`.
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21649800

http://stackoverflow.com/comment/32709304
type: Comment
comment on: http://stackoverflow.com/q/21643307
has text: @developerknownasInsane No need for apologies, what people mostly prefer to see is a change. I see the change (and got notified of that comment). :)
score: 0
type: QuestionComment

http://stackoverflow.com/comment/51886782
comment on: http://stackoverflow.com/a/21586648
score: 0
type: AnswerComment
has text: @pWoz Sorry this reply is late, but no I didn't. We wound up dropping Groovy for Clojure and Jersey for Compojure.
type: Comment

http://stackoverflow.com/comment/32757147
has text: java-code is correct. Is $P{SOME_PARAM} displayed as "some string" in band, which contain chart? (make Text Field and place it in this band for check)
comment on: http://stackoverflow.com/q/21631233
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32595246
has text: Ok, that whole question was a little bit stupid, I converted a scala example, and it seems like scala depends different from Java here. I did not test well engouth, sorry for that.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21558458
score: 0

custom-exceptions
type: Tag
tag name: custom-exceptions
tags question: http://stackoverflow.com/q/21521574

java-ee-6
tags question: http://stackoverflow.com/q/21536727
type: Tag
tags question: http://stackoverflow.com/q/21602868
tags question: http://stackoverflow.com/q/21542601
tags question: http://stackoverflow.com/q/21551071
tag name: java-ee-6
tags question: http://stackoverflow.com/q/21618298

http://stackoverflow.com/a/21542029
has body: It's hard to tell, but I think you need to remove whitespace: double totalWithTip = subtotal + (getPercentage(satisfactionNumber) * subtotal); return totalWithTip; This code assumes a variable: int satisfactionNumber; and a method: double getPercentage(int satisfactionNumber) { // some impl }
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/32531300
has comment: http://stackoverflow.com/comment/32531250
answers question: http://stackoverflow.com/q/21541979

http://stackoverflow.com/a/21660164
upvote count: 5
has body: Use the org.eclipse.ui.startup extension point to specify a class that implements org.eclipse.ui.IStartup. This will be called early on during Eclipse initialization. So in the plugin.xml: &lt;extension point="org.eclipse.ui.startup"&gt; &lt;startup class="your class implementing IStartup"/&gt; &lt;/extension&gt; Class: public class Startup implements IStartup { @Override public void earlyStartup() { // you action } }
accepted answer of: http://stackoverflow.com/q/21660136
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/21660136
score: 5

http://stackoverflow.com/comment/32540327
type: AnswerComment
type: Comment
has text: Was my idea. You was too fast. Exactly this is the solution. Remember already checked chars.
comment on: http://stackoverflow.com/a/21547700
score: 0

http://stackoverflow.com/comment/32572822
type: QuestionComment
has text: You want to do this for each term, right?
comment on: http://stackoverflow.com/q/21565552
score: 0
type: Comment

linked-list
tags question: http://stackoverflow.com/q/21661251
tags question: http://stackoverflow.com/q/21627108
tags question: http://stackoverflow.com/q/21595050
tag name: linked-list
tags question: http://stackoverflow.com/q/21637562
tags question: http://stackoverflow.com/q/21567171
tags question: http://stackoverflow.com/q/21583472
tags question: http://stackoverflow.com/q/21571503
tags question: http://stackoverflow.com/q/21538388
type: Tag
tags question: http://stackoverflow.com/q/21592835
tags question: http://stackoverflow.com/q/21657194
tags question: http://stackoverflow.com/q/21591522
tags question: http://stackoverflow.com/q/21641041
tags question: http://stackoverflow.com/q/21592868
tags question: http://stackoverflow.com/q/21596845
tags question: http://stackoverflow.com/q/21565564
tags question: http://stackoverflow.com/q/21632621
tags question: http://stackoverflow.com/q/21641466
tags question: http://stackoverflow.com/q/21617098
tags question: http://stackoverflow.com/q/21562318
tags question: http://stackoverflow.com/q/21563996

http://stackoverflow.com/comment/32602246
has text: thanks Peter. I handled the close after 5 seconds using a Timer with a delay of 5 seconds. I had to put the code to close the dialog inside an invokeLater in the timer task. I also cancelled the TimerTask and the Timer inside the invokeLater. I'll work in the other question I had pending.
type: AnswerComment
comment on: http://stackoverflow.com/a/21580025
score: 0
type: Comment

http://stackoverflow.com/a/21563403
score: 3
downvote count: 0
answers question: http://stackoverflow.com/q/21563099
has body: new BitmapDrawable( BitmapFactory.decodeFile(file.getAbsolutePath()) );
upvote count: 3
has comment: http://stackoverflow.com/comment/32568993
type: Answer

http://stackoverflow.com/q/21515561
has comment: http://stackoverflow.com/comment/32486519
accepted answer: http://stackoverflow.com/a/21517639
has body: I am using the NCSO.jar api for lotus notes. Now I can create the connection remotely to the domino server. I tried to download the documents created by the lotus notes such as the .odt documents. But it is not success. my code: database = session.getDatabase(host, "names.nsf", false); DocumentCollection documentCollection = database.getAllDocuments(); The returned result is always same and not included any .odt files. So is there another way to download the documents created by ibm notes? for example, I use lotus notes created a documents like a test.odt which is saved under the myDocuments folder. I want use an external application to download this file.
tagged with: java
has title: Downloading Documents from lotus notes
type: Question
has comment: http://stackoverflow.com/comment/32487663
answer count: 1
score: 0
has answer: http://stackoverflow.com/a/21517639
tagged with: lotus-notes
has comment: http://stackoverflow.com/comment/32489883
type: AnsweredQuestion

http://stackoverflow.com/a/21645616
has body: If you "don't want open first frame again" then you must avoid creating a new instance of first and use a reference of your previous instance instead. So you need a reference... one way to give your second a reference to first is provide it in the constructor, like: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){ second sec = new second(this); //notice I'm passing a reference to this as an argument second's contstructor sec.jTextField1.setText(this.jTextField1.getText()); // this works sec.jTextField2.setText(this.jTextField2.getText()); sec.setVisible(true); Then you need to store the reference to first in your second class and use it to access textfields: private first f; public second(first referenceToFirst){ this.f=referenceToFirst; } ok, then use f field instead of instantiating a new first when clicking the button on second... private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){ //first f = new first(); //don't instantiate a new first, use the one you got in the constructor f.jTextField1.setText(this.jTextField3.getText()); f.jTextField2.setText(this.jTextField4.getText()); } Notes: I wouldn't make textfields public static, I'd rather provide getter methods. I suggest you adhere to naming conventions: use capital letters for classes and use significant names for variables.
has comment: http://stackoverflow.com/comment/32713310
answers question: http://stackoverflow.com/q/21643817
accepted answer of: http://stackoverflow.com/q/21643817
score: 0
type: AcceptedAnswer
type: Answer

http://stackoverflow.com/comment/32735894
type: AnswerComment
type: Comment
has text: Wow, Thank you so much Nizet, I've spent days to read about Thread safe, concurrency , etc. wish i could vote for u.
comment on: http://stackoverflow.com/a/21656748
score: 0

http://stackoverflow.com/comment/32628717
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21577997
has text: @gimby By implementing it the way I suggested you would occupy 80% of each processing unit (core), meaning 80% of the hardware-CPU. You are right that CPU is not clearly defined. Let's just suppose that as I am speaking of multiple CPUs I was not talking of one CPU ;)
type: AnswerComment

http://stackoverflow.com/comment/32696900
score: 0
type: Comment
type: QuestionComment
has text: First got to json.org and study the JSON syntax. There are two types of JSON structures, "objects" and "arrays". Everything is built by layering those together. "Objects" you access using keys, while "arrays" are accessed with a numeric index. Depending on the toolkit you use the "deserialized" JSON will be represented as plain old Java Maps ("objects") and Lists ("arrays") or special Map/List-like classes belonging to the JSON kit you use. (It's important to note that the JSON "object" is not the same as the Java "Object".)
comment on: http://stackoverflow.com/q/21636163

http://stackoverflow.com/a/47866543
type: Answer
has body: The TiledDrawable class doesn't support scaling i made a class that extends TiledDrawable and can be scaled. Preferable you dont want to scale down more than 0.1 it will be a performance hog (depending on the size of the texture) at that scale. So use with caution when scaling down. Note i didnt account for when the scale is set to zero so maybe create a method setScale where it throws an error when that happens. Use the ScaledTiledDrawable like this: ScaledTiledDrawable scaledTiledDrawable = new ScaledTiledDrawable( new TextureRegion( texture ) ); scaledTiledDrawable.getScale().set( 0.5f, 0.5f ); Here is the class: public class ScaledTiledDrawable extends TiledDrawable { private Vector2 scale = new Vector2(); private Affine2 transform = new Affine2(); private Matrix4 matrix = new Matrix4(); private Matrix4 oldMatrix = new Matrix4(); public ScaledTiledDrawable() { super(); } public ScaledTiledDrawable( TextureRegion region ) { super( region ); } public ScaledTiledDrawable( TextureRegionDrawable drawable ){ super( drawable ); } public Vector2 getScale() { return scale; } @Override public void draw( Batch batch, float x, float y, float width, float height ) { oldMatrix.set( batch.getTransformMatrix() ); matrix.set( transform.setToTrnScl( x, y, scale.x, scale.y ) ); batch.setTransformMatrix( matrix ); super.draw( batch, 0, 0, width / scale.x, height / scale.y ); batch.setTransformMatrix( oldMatrix ); } }
score: 0
answers question: http://stackoverflow.com/q/21647419

http://stackoverflow.com/comment/32484245
has text: Yes, this is what I meant.
type: Comment
comment on: http://stackoverflow.com/q/21515659
score: 0
type: QuestionComment

http://stackoverflow.com/comment/32587704
type: Comment
comment on: http://stackoverflow.com/a/21566722
score: 0
has text: Can you give an example how to hold multiple async streams for one client?
type: AnswerComment

http://stackoverflow.com/comment/32750493
has text: No, it didn't return anything. It *threw* an `UnmarshalException.` In other words it ***did*** give an error! Please edit the stack trace into your post. Why does it take two days to get the most basic information?
type: Comment
comment on: http://stackoverflow.com/q/21638322
type: QuestionComment
score: 1

http://stackoverflow.com/a/21544551
answers question: http://stackoverflow.com/q/21537148
type: Answer
score: 0
has body: You could use sealed class + case object. The only part you can't get with this approach is method values, but you could use this answer to implement method values like this: sealed class Status(val code: Int, val name: String, val description: String) object Status { def values: Set[Status] = macro SealedExample.values_impl[Status] case object OK extends Status(1, "Ok", "Okay") case object NOT_OK extends Status(5, "Not Ok", "Not Okay") case object BAD extends Status(10, "Bad", "Run for your life") } def doStuff(status: Status) = println(status.description) for {s &lt;- Status.values} doStuff(s) // Okay // Not Okay // Run for your life

http://stackoverflow.com/comment/32769586
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21678083
has text: you'll get your answer

http://stackoverflow.com/q/21529630
tagged with: twitter
downvote count: 1
type: Question
upvote count: 2
answer count: 2
has answer: http://stackoverflow.com/a/22128610
has body: I am trying to use scribe for authorization with twitter. When I try requestToken = service.getRequestToken() I get following error 14:10:11,305 ERROR [ajp-bio-8009-exec-4][IncludeTag:154] java.lang.IllegalArgumentException: Cannot get String from a null object at org.scribe.utils.Preconditions.check(Preconditions.java:80) at org.scribe.utils.Preconditions.checkNotNull(Preconditions.java:27) at org.scribe.utils.StreamUtils.getStreamContents(StreamUtils.java:20) at org.scribe.model.Response.parseBodyContents(Response.java:40) at org.scribe.model.Response.getBody(Response.java:66) at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:59) at org.apache.jsp.html.portlet.login.login_jsp._jspService(login_jsp.java:2432) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72) at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116) at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) I tried the answer mentioned in following posts but nothing worked scribe + twitter &gt; Cannot get String from a nul…
tagged with: scribe
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21592975
linked to: http://stackoverflow.com/q/21417920
has title: Twitter + Scribe + Cannot get String from a null object
score: 1
tagged with: java

http://stackoverflow.com/q/21677767
has comment: http://stackoverflow.com/comment/32769125
type: AnsweredQuestion
tagged with: if-statement
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32770630
has answer: http://stackoverflow.com/a/21677879
has answer: http://stackoverflow.com/a/21678004
type: Question
has title: if-else condition: AND evaluation mystery
answer count: 2
possible better answer: http://stackoverflow.com/a/21677879
favorite count: 0
tagged with: android
has comment: http://stackoverflow.com/comment/32768919
has comment: http://stackoverflow.com/comment/32769049
has body: I'm working on an app for Android. In my code I have the following lines: if (shape != null &amp;&amp; !created &amp;&amp; isTap(touchDown, event)) { DrawPrimitive newShape = listener.onTouch(event, shape); if (newShape != shape) canvas.onDrawingChanged(true); } created is a boolean member. I'm wondering because created is true but the runtime steps into my if even without calling the isTap method. If I change the ! to the false comparsion, everything works fine. if (shape != null &amp;&amp; created == false &amp;&amp; isTap(touchDown, event)) { DrawPrimitive newShape = listener.onTouch(event, shape); if (newShape != shape) canvas.onDrawingChanged(true); } So I'm wondering if the ! is not allowed. But even if so, why is my isTap method (in version one) not called and why is the inner code executed without evaluating all AND conditions.
upvote count: 2
has comment: http://stackoverflow.com/comment/32768949
accepted answer: http://stackoverflow.com/a/21678004
downvote count: 1

http://stackoverflow.com/comment/32540885
comment on: http://stackoverflow.com/a/21530716
has text: Maybe I've looked over this, but do I have to inject something by myself in the form?
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/32629940
comment on: http://stackoverflow.com/q/21597840
score: 0
type: Comment
type: QuestionComment
has text: Please donot downvote and close .If you r not clear about the question then please leave a comment

http://stackoverflow.com/comment/32527281
type: QuestionComment
has text: On my android device, I get a blank screen. in logcat i get E/Trace(28762): error opening trace file: No such file or directory (2)
comment on: http://stackoverflow.com/q/21539765
score: 0
type: Comment

http://stackoverflow.com/q/21583399
type: Question
possible better answer: http://stackoverflow.com/a/21583446
type: AnsweredQuestion
has title: "Could not resolve matching constructor" error when passing in constructor-arg for child class
has body: I have the following classes: public abstract class ParentClass { public ParentClass() { throw new RuntimeException("An ID must be specified."); } public ParentClass(String id) { this(id, DEFUALT_ARG_VALUE); } public ParentClass(String id, int anotherArg) { this.id = id; //stuff with anotherArg } public abstract void doInstanceStuff(); } public class ChildClass extends ParentClass { @Override public void doInstanceStuff() { //.... } } In my application context I have this: &lt;bean id="myChildInstance" class="com.foo.bar.ChildClass " scope="singleton"&gt; &lt;constructor-arg value="myId" /&gt; &lt;/bean&gt; The problem is that when the server starts up I get the following error: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ivpluginHealthCheckTest' defined in ServletContext resource [/WEB-INF/spring/root-context.xml]: Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities) Seeing the error, I tried adding the different attributes, but with no luck. I ended up with something like this: &lt;bean id="myChildInstance" class="com.foo.bar.ChildClass " scope="singleton"&gt; &lt;constructor-arg value="myId" index="0" type="java.lang.String" name="id" /&gt; &lt;/bean&gt; And I still get the same error. I tried adding the same constructors to my child class, and just call super() with the appropriate arguments for each one, and that seems to fix it. However, I don't want to have to add the same constructors in all my child instances and have to maintain those with the parent class. Is there some reason Spring has trouble calling an inherited constructor to instantiate the class? Is there something I can do to make this work?
tagged with: inheritance
has answer: http://stackoverflow.com/a/21583873
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/21583446
tagged with: constructor
has answer: http://stackoverflow.com/a/21583458
accepted answer: http://stackoverflow.com/a/21583458
tagged with: spring
tagged with: java

ksoap2
type: Tag
tags question: http://stackoverflow.com/q/21646260
tag name: ksoap2

http://stackoverflow.com/comment/32527293
type: Comment
has text: The InputStream is long gone by the time the sending is being done. As I said, ByteArrayDataSource copies all the data immediately. Try using a FileInputStream and the send should have the same performance as your InputStream. If you're using a FileDataSource and seeing much better performance with the same amount of data, we need more details on how you're measuring the performance and how to reproduce the problem. Try testing against (e.g.) Gmail to make sure it's not related to your server.
comment on: http://stackoverflow.com/a/21519842
type: AnswerComment
score: 0

http://stackoverflow.com/comment/34906457
type: AnswerComment
has text: He could be wrong about mapreduce which I think is perfect for what he is looking for. You control the number of mappers and this how many users in each parallel task.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21640892

http://stackoverflow.com/comment/32629713
comment on: http://stackoverflow.com/q/21597846
type: Comment
has text: possible duplicate of : http://stackoverflow.com/questions/728295/creating-multiple-log-files-of-different-content-with-log4j
score: 0
type: QuestionComment

http://stackoverflow.com/a/33432201
has body: This way youu can use text area with scroll : JTextArea txtArea = new JTextArea(40,100); txtArea.setAutoscrolls(true); txtArea.setBorder(BorderFactory.createLineBorder(Color.BLACK)); txtArea.setFont(new Font("courier new", Font.PLAIN, 12)); txtArea.setLineWrap(true); txtArea.setText(j); JScrollPane txtAreaScroll = new JScrollPane (txtArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); txtAreaScroll.setViewportView(txtArea); txtAreaScroll.setAutoscrolls(true); // now add scroll pane in frame
answers question: http://stackoverflow.com/q/21569624
score: 0
type: Answer

http://stackoverflow.com/comment/32600174
score: 0
type: Comment
comment on: http://stackoverflow.com/q/21581026
type: QuestionComment
has text: my question is, System.out.println(name + "---->" + (i-1)); This line is printing name, field firstname, instead of that print LINE.. everline has 0,1,2....if there is duplicate in firstname is not than, only 0 at line of line..

http://stackoverflow.com/a/21584534
has body: use
score: 0
answers question: http://stackoverflow.com/q/21583042
type: Answer

http://stackoverflow.com/a/21624253
score: 1
has comment: http://stackoverflow.com/comment/32675624
upvote count: 1
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/32676058
answers question: http://stackoverflow.com/q/21622463
has body: You can use three ways to redirecting from servlet. 1) Request Dispatcher :- RequestDispatcher dispatcher = getRequestDispatcher("jsp/servlet Page"); dispatcher.forward( request, response ); 2) Use Response send Redirect Method. HttpResponce.sendRedirect("jsp/servlet Page"); 3) Set Header Location :- response.setHeader("Location","jsp/servlet Page"); The Best Way is to use the Request Dispatcher, it perform in only one round trip.

http://stackoverflow.com/comment/32674112
type: Comment
comment on: http://stackoverflow.com/a/21622730
score: 0
type: AnswerComment
has text: Sorry, the `String` was a typo. Meant for `int` variables. Good catch though.

http://stackoverflow.com/comment/32670605
type: Comment
has text: May I ask one more question, please. Now, I am instantiating SensorActivity with Activity and Context as arguments. Would you normally do this? This seems? feels? inefficient.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21620561

http://stackoverflow.com/a/21551615
has comment: http://stackoverflow.com/comment/32551355
downvote count: 0
type: Answer
score: 1
has body: Have you tried calling revalidate(); repaint(); ? That might fix your issue, but what you are looking for is the JImagePanel class. It is a third-party util and should make your life much easier. Get the source here. Then, just add this panel to the root of the JFrame and viola!
upvote count: 1
answers question: http://stackoverflow.com/q/21550916

http://stackoverflow.com/comment/32601576
has text: Edit it into your answer.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/21581751
type: Comment

http://stackoverflow.com/comment/32548114
type: QuestionComment
comment on: http://stackoverflow.com/q/21529584
has text: Thanks for your help! My Eclipse's version is this one: Version: Kepler Service Release 1 Build id: 20130919-0819 I can't find a way to further specify the version...
score: 0
type: Comment

http://stackoverflow.com/comment/32621363
score: 0
type: Comment
has text: because i have print myint[a] variable i is just for looping
comment on: http://stackoverflow.com/a/21592958
type: AnswerComment

http://stackoverflow.com/comment/32542468
has text: @Mr.Starck Note that Teifi is talking about `Objects`, not `Object`. This is a new class with utility methods that was added in Java 7.
score: 1
comment on: http://stackoverflow.com/q/21548989
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32661918
has text: Might help to know what `out` and `in`are.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21616059
score: 0

http://stackoverflow.com/q/21657194
has answer: http://stackoverflow.com/a/21657397
type: AnsweredQuestion
has title: Adding to end of Linked Lists
has comment: http://stackoverflow.com/comment/32733434
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32733294
answer count: 1
has comment: http://stackoverflow.com/comment/32733364
accepted answer: http://stackoverflow.com/a/21657397
score: 0
has body: I am currently studying up on linked lists in Java. I have a sample program that works as expected for certain input, and not at all for other input. //Constructor in class List of People ListOfPeople() { Person listHead = new Person("LIST HEAD"); personList = listHead; lastPerson = listHead; numberPeople = 0; } //Adds person to the beginning of the list public void addFirst(Person newP) { newP.next = personList.next; personList.next = newP; numberPeople++; } //Adds person to the end of the list public void addLast(Person lastP) { lastPerson.next = lastP; lastPerson = lastP; numberPeople++; } For the Person class, I have the following code: //From the Person class String name; Person next; Person(String n) { name = n; next = null; } Suppose I add two different people to the beginning of the list: Person mulan = new Person("Mulan"); myFriends.addFirst(mulan); Person mushu = new Person("Mushu"); myFriends.addFirst(mushu); Then, the code works without problems. And I get the output: "Mushu, Mulan". HOWEVER, if I add one person at the beginning of the list, and another at the end, I get a NullPointerException. If I try to invoke the addLast(String name) method on both Person objects, there seems to be no problem. Any tips are highly appreciated!
tagged with: linked-list

http://stackoverflow.com/comment/32566112
type: QuestionComment
comment on: http://stackoverflow.com/q/21561879
score: 0
has text: Please post a stack trace
type: Comment

http://stackoverflow.com/comment/32566966
comment on: http://stackoverflow.com/a/21562519
score: 1
type: AnswerComment
has text: I feel like the OP is just _lazy_. I know a lazy developer when I see one. I didn't ask anyone what something meant, I google it or read it in a tutorial, docs etc. And if you're lazy to run the code to see for yourself what then, every 5 lines of code you'll ask someonelse if you wrote the right code?
type: Comment

http://stackoverflow.com/comment/32702636
type: Comment
comment on: http://stackoverflow.com/a/21638468
has text: you can make AsnycTask class in your Activity that contain the ListView and download them in this class
type: AnswerComment
score: 0

http://stackoverflow.com/a/21640151
type: Answer
has body: The problem is in your switching algorithm. You are assigning temp twice. int temp = Bub[x]; Bub[x] = Bub[x+1]; temp = Bub[x+1]; //Here should assign Bub[x+1] to temp //Example: Bub[x+1] = temp edit-Actually, there could be some improvement in the sorting algorithm itself, too. Personally, I like to do it this way: public class Sort { private static int[] array = { 3, 8, -1, 7, 0, 3 }; public static void main(String[] args) { for(int i = 0; i &lt; array.length - 1; i++) { for(int j = i + 1; j &lt; array.length; j++) { if(array[i] &gt; array[j]) { int temp = array[i]; array[i] = array[j]; array[j] = temp; } } } for(int i = 0; i &lt; array.length; i++) { System.out.println(array[i]); } } }
has comment: http://stackoverflow.com/comment/32704212
answers question: http://stackoverflow.com/q/21640027
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21640027
score: 0

http://stackoverflow.com/comment/32573309
score: 0
has text: one moment, i will add it, Done
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21565763

http://stackoverflow.com/q/21647419
has answer: http://stackoverflow.com/a/47866543
type: UnansweredQuestion
tagged with: android
has body: I have a table that is supposed to have checkerboard background. For that, I use tiled drawables like so: TiledDrawable boardBg; boardBg = new TiledDrawable(menuSkin.getTiledDrawable("boardBg")); boardTable.setBackground(boardBg); Then each tile has the size the drawable has by defualt, say 64px. What do I have to do so that each tile is larger? I tried boardBg.setMinWidth(500); boardBg.setMinHeight(500); but that doesn't have any effect.
tagged with: java
type: Question
tagged with: libgdx
score: 4
upvote count: 4
has title: How to set size of tiled drawables
answer count: 1
downvote count: 0
favorite count: 0

http://stackoverflow.com/a/21568157
score: 4
has comment: http://stackoverflow.com/comment/32577706
upvote count: 4
has body: grades variable is not initialized. You need to initialize it inside Student constructor: public Student(String name, String bNumber) { this.name=name; this.bNumber=bNumber; this.grades = new Grades(); } You may wish to initialize qualPts and numCred as well
accepted answer of: http://stackoverflow.com/q/21568102
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21568102
type: Answer

http://stackoverflow.com/comment/32714142
has text: Dammit, was it that simple? I swear, I need new glasses. Thanks though, I'll make your answer the correct one!
type: Comment
score: 1
comment on: http://stackoverflow.com/a/21646265
type: AnswerComment

http://stackoverflow.com/comment/32497992
type: AnswerComment
score: 0
type: Comment
has text: i have already tried that but character map does not work on &dash and mdash you can replace &#150; with a string
comment on: http://stackoverflow.com/a/21523662

http://stackoverflow.com/comment/32691223
comment on: http://stackoverflow.com/q/21633246
type: Comment
has text: Well, `wait(1)` is really "wait one millisecond." A millisecond is a very long time in terms of CPU process clocks, so the CPU basically gets to rest for a whole millisecond every... however long it takes to process `while(true)`.
type: QuestionComment
score: 2

http://stackoverflow.com/comment/32629957
has text: That means, for example, when a button is clicked as an AWT button uses the native code, the events are sent to that native code and then the AWT-Windows thread interacts with that native code to know what type of event has occured?
score: 0
comment on: http://stackoverflow.com/a/21597955
type: AnswerComment
type: Comment

http://stackoverflow.com/q/21521692
has title: Android send parameters server .create request
answer count: 2
has answer: http://stackoverflow.com/a/21522185
score: 0
tagged with: java
tagged with: http
has comment: http://stackoverflow.com/comment/32495340
has answer: http://stackoverflow.com/a/21521867
type: UnansweredQuestion
type: Question
tagged with: android
has body: i want to create request and i want to send to parameters to server,for example two strings(hello,hello) i googled about this and i wrote some code but i have debug error (my problem is a URL) i want to send 2 strings in this url http://*//**.aspx?deviceId={id}&amp;list={list} deviceID={id) is a firs string for example divice id and list={list} is second string just hello HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost( "http://****/***/******.aspx?deviceId={id}&amp;list={list}"); List&lt;NameValuePair&gt; nameValuePair = new ArrayList&lt;NameValuePair&gt;(2); nameValuePair.add(new BasicNameValuePair("id", android_id)); nameValuePair.add(new BasicNameValuePair("list","Hello")); try { httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } try { HttpResponse response = httpClient.execute(httpPost); Log.d("Http Response:", response.toString()); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } Toast.makeText(getApplicationContext(), android_id, Toast.LENGTH_LONG) .show(); } }

http://stackoverflow.com/a/21534254
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/21534188
downvote count: 0
type: Answer
has body: You're trying to access position i+1 or the Array. Since your for loop goes until the last element, you'll try to access 1 position after the last element, what causes the Out Of Bounds exception.

http://stackoverflow.com/q/21593278
answer count: 1
has comment: http://stackoverflow.com/comment/32622048
type: UnansweredQuestion
tagged with: regex
has title: What is Java Regex to match number then space then 3 alphabet char?
score: 0
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32621976
has answer: http://stackoverflow.com/a/21593373
has comment: http://stackoverflow.com/comment/32621934
has body: I want to validate the about of money with the currency Unit. 100 USD : valid 1.11 USD : not valid 1,12 USD : not valid 12 US : not valid So the valid string is "the number then space then 3 alphabet char". text.matches("^\\d+ [a-zA-Z]{3}*$") I got error: Exception caught: Dangling meta character '*' near index 16 ^\d+ [a-zA-Z]{3}*$ So how to fix it?

http://stackoverflow.com/q/21637067
score: 0
upvote count: 1
tagged with: android
favorite count: 0
type: UnansweredQuestion
downvote count: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32698749
type: Question
has comment: http://stackoverflow.com/comment/32698609
has comment: http://stackoverflow.com/comment/32698558
has comment: http://stackoverflow.com/comment/32698593
has body: So I am working on a news application which has a Arraylist TopNewsList with all the news from all categories. Now I have a category specific list of news, so I want to use the same arraylist in the adapter for different Listviews, I want the adapter to filter the news based on category id I provide (I have it in the arraylist), the Arraylist is actually - ArrayList&lt;HashMap&lt;String, String&gt;&gt; with id, news title, imageurl etc etc Note that I cannot use a copy , because there are fields like read/unread which should reflect across categories. This is my ArrayList FYI HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); // adding each child node to HashMap key =&gt; value map.put(TAG_CATEGORYID, id); map.put(TAG_TITLE, title); map.put(TAG_DESCRIPTON, description); map.put(TAG_CREATED, created); map.put(TAG_IMAGE, image); map.put(TAG_IMAGE2, image2); // adding HashList to ArrayList TopNewsList.add(map);
has title: Different ListViews filtered from same ArrayList
answer count: 1
tagged with: adapter
has answer: http://stackoverflow.com/a/21637386
tagged with: arraylist

http://stackoverflow.com/a/21557611
score: 0
has body: If this is your data: "Progressive Tax Ammount of brackets: 2 0.0 30000.0 0.0 45001.0 45000.0 0.2 " Then String taxType = readtax.next(); will be "Progressive" and String brackets = readtax.next(); will be "Tax". You should see the issue from there :) Stepping through the code with a debugger should make it obvious also.
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21557326
type: Answer
accepted answer of: http://stackoverflow.com/q/21557326

http://stackoverflow.com/q/21538488
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/21538695
tagged with: linux
upvote count: 0
type: UnansweredQuestion
downvote count: 2
tagged with: photo
has comment: http://stackoverflow.com/comment/32524901
type: Question
has comment: http://stackoverflow.com/comment/32524928
has body: I'm looking for a script to copy specific files from a disk to one other discarding all duplicated For examples .jpg ,.tiff,.nef I got a pretty messy backup of all my pictures and i want to copy all pics to others disk avoiding the duplicated one
has title: How to copy specific file from a disk
score: -2
tagged with: java

http://stackoverflow.com/a/21564525
upvote count: 1
has body: I don't see any problem in calling a setter in a constructor. In fact, if you plan to have setters carry additional logic, using the method gives you better encapsulation.
downvote count: 0
answers question: http://stackoverflow.com/q/21564478
type: Answer
score: 1

http://stackoverflow.com/comment/32762275
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/21671905
has text: Thank you for the answer but I'm using just dynamic jasper.

http://stackoverflow.com/q/21519021
has comment: http://stackoverflow.com/comment/32490467
has comment: http://stackoverflow.com/comment/32490330
has title: Count occurrence of integers in an array
possible better answer: http://stackoverflow.com/a/21519103
tagged with: java
has answer: http://stackoverflow.com/a/21519103
has comment: http://stackoverflow.com/comment/32490277
score: 0
has comment: http://stackoverflow.com/comment/32490781
accepted answer: http://stackoverflow.com/a/21519060
tagged with: arrays
has comment: http://stackoverflow.com/comment/32490457
has comment: http://stackoverflow.com/comment/32490297
favorite count: 0
has answer: http://stackoverflow.com/a/38393457
has comment: http://stackoverflow.com/comment/32510762
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/33664507
has body: I have an integer array: int[] numbers = new int[...n]; // n being limitless. Where all the numbers are between 0 and 100. Say numbers[] was equal to: [52, 67, 32, 43, 32, 21, 12, 5, 0, 3, 2, 0, 0]; I want to count how often each of those numbers occur. I've got a second array: int[] occurrences = new int[100];. I'd like to be able to store the amounts like such: for(int i = 0; i &lt; numbers.length; i++) { // Store amount of 0's in numbers[] to occurrences[0] // Store amount of 1's in numbers[] to occurrences[1] } So that occurrences[0] would be equal to 3, occurrences[1] would be equal to 0 etc. Is there any efficient way of doing this without having to resort to external libraries? thanks.
has answer: http://stackoverflow.com/a/21519060
upvote count: 1
has comment: http://stackoverflow.com/comment/32507618
downvote count: 1
type: Question

http://stackoverflow.com/q/21524128
has title: Difference between these setDefaultCloseOperation statements
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/21524310
has answer: http://stackoverflow.com/a/21524183
accepted answer: http://stackoverflow.com/a/21524183
type: Question
possible better answer: http://stackoverflow.com/a/21524310
has comment: http://stackoverflow.com/comment/32498658
score: 0
answer count: 2
has body: I'm unable to understand the Difference between these two statements: frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE); And frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Where frame is the Object of JFrame Class. These statements perform the same task.What is the difference?
has comment: http://stackoverflow.com/comment/32499660
tagged with: jframe
tagged with: swing

onclicklistener
tag name: onclicklistener
tags question: http://stackoverflow.com/q/21675620
tags question: http://stackoverflow.com/q/21638716
type: Tag
tags question: http://stackoverflow.com/q/21632011

http://stackoverflow.com/a/21527379
type: AcceptedAnswer
downvote count: 0
type: Answer
has body: android:name="com.example.judoapp.MainActivity" It's looking for the class MainActivity in com.example.judoapp. Either add it, or change that line to the real package of the Activity.
accepted answer of: http://stackoverflow.com/q/21527335
has comment: http://stackoverflow.com/comment/32504284
answers question: http://stackoverflow.com/q/21527335
score: 5
upvote count: 5

http://stackoverflow.com/comment/32525910
score: 0
has text: Never mind, I found out what was wrong. I exported the java file incorrectly out of the IDE. :/
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21538993

http://stackoverflow.com/comment/32620998
comment on: http://stackoverflow.com/q/21592759
type: QuestionComment
type: Comment
score: 1
has text: This code is legal (except that the `else if` at the beginning has to be part of an earlier `if`). Whether it's what you want, I can't tell. It's probably wrong that you're checking one variable (`plusMinusSign`) for `+` and a different variable (`letter`) for `-`.

http://stackoverflow.com/comment/32517873
has text: this book is also great and it can be understood by newbies (like you and me) http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference
score: 1
comment on: http://stackoverflow.com/q/21534316
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21564689
type: AcceptedAnswer
downvote count: 0
score: 1
type: Answer
upvote count: 1
accepted answer of: http://stackoverflow.com/q/21564658
has body: Character.getNumericValue() returns 10 for A because it is digit in number systems with bases beyond the decimal system (such as hexadecimal, all the way up to 35-base): &gt;&gt;&gt; int('A', 36) 10 &gt;&gt;&gt; int('Z', 36) 35 From the Character.getNumericValue() documenation: The letters A-Z in their uppercase ('\u0041' through '\u005A'), lowercase ('\u0061' through '\u007A'), and full width variant ('\uFF21' through '\uFF3A' and '\uFF41' through '\uFF5A') forms have numeric values from 10 through 35. This is independent of the Unicode specification, which does not assign numeric values to these char values. There is no direct Python equivalent; Character.getNumericValue() also interprets roman numerals, for example, you'd have to code such mappings yourself.
answers question: http://stackoverflow.com/q/21564658

http://stackoverflow.com/comment/32505396
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21527955
has text: This also won't compile. You are attempting to assign a value to `name` after it has already been assigned.
type: AnswerComment

http://stackoverflow.com/comment/32483497
comment on: http://stackoverflow.com/q/21515121
has text: Why don't you use if-else-if statements? 1st if can check for "1", second else-if for "2" and last else will by default work for your problem. You can even go for ternary operator for a single line solution.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32711695
comment on: http://stackoverflow.com/a/21644319
has text: Awh :(, Do you think you can show me a way for the recursive method to stop when the number becomes 1 or string has only one letter?
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32634964
has text: Because compiler has no idea which derived class instance is assigned to a variable with the `Base` type. Also variable `baseInstance` is of type `Base` which itself does not have method `SomeMethod` defined. If you want that all classes derived from `Base` had `SomeMethod` but not sure about implementation, make `Base` class abstract and define `SomeMethod` as abstract method, so you'll override later.
score: 2
comment on: http://stackoverflow.com/q/21601227
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21651882
accepted answer: http://stackoverflow.com/a/21916903
downvote count: 2
upvote count: 1
answer count: 1
favorite count: 0
has title: How to show image in between display tag library using?
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33195018
type: Question
has body: I am fetching all list of bean object, with I want to display images in between display tag columns from display tag library. How can I do? Also I want use Struts tag library in between display tag library. I did this but output not shown.
score: -1
tagged with: displaytag
tagged with: struts2
has answer: http://stackoverflow.com/a/21916903

http://stackoverflow.com/q/21660132
has title: Java Swing textfield issue
tagged with: jtextfield
type: Question
has comment: http://stackoverflow.com/comment/32738698
tagged with: user-interface
answer count: 1
score: 0
tagged with: netbeans
type: UnansweredQuestion
has body: I created a GUI using Netbeans which took asked the user to input the content in textfields and textareas. When I'm trying to use it in other classes, the text entered in the textfield does not appear when i use getText method on it. Rather in its place, the text which appears in the textfield specified using the edit text option in Netbeans, appears whenever getText method is used. Is the problem related to some sort of sequencing or order? Because I believe the text from the GUI, is being referenced before the user is actually entering it. public class GUI extends javax.swing.JFrame { public GUI() { initComponents(); } public void Grow(){ initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // &lt;editor-fold defaultstate="collapsed" desc="Generated Code"&gt; private void initComponents() { jTextField1 = new javax.swing.JTextField(); jPanel1 = new javax.swing.JPanel(); username = new javax.swing.JTextField(); UsernameLabel = new javax.swing.JLabel(); PasswordLabel = new javax.swing.JLabel(); subject = new javax.swing.JTextField(); SubjectLabel = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); message = new javax.swing.JTextArea(); jLabel1 = new javax.swing.JLabel(); salutation = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); sendbutton = new javax.swing.JButton(); password = new javax.swing.JPasswordField(); jTextField1.setText("jTextField1"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jPanel1.setBackground(new java.awt.Color(204, 204, 255)); jPanel1.setBorder(new javax.swing.border.LineBorder(java.awt.SystemColor.controlDkShadow, 3, true)); username.setText("Enter your text here"); UsernameLabel.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N UsernameLabel.setForeground(new java.awt.Color(255, 51, 51)); U…
tagged with: swing
has answer: http://stackoverflow.com/a/21661553
tagged with: java

http://stackoverflow.com/a/21519991
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/21519702
has comment: http://stackoverflow.com/comment/32492661
has comment: http://stackoverflow.com/comment/32550884
has comment: http://stackoverflow.com/comment/32494627
has comment: http://stackoverflow.com/comment/32492565
has comment: http://stackoverflow.com/comment/32492135
downvote count: 0
has comment: http://stackoverflow.com/comment/32493387
type: Answer
has body: To get the part between the last slash and the dot: String filename = str.replaceAll(".*?(?:/(\\w+)\\.\\w+$)?", "$1"); This regex has some special sauce added to return a blank if the target isn't found, by making the target optional and the leading expression reluctant.

http://stackoverflow.com/a/21553260
answers question: http://stackoverflow.com/q/21523794
type: AcceptedAnswer
has body: I have got the solution. Actually i was calling the method after typecasting proxy object into my action class object. But if i call it directly through proxy object then it calls all interceptor for given uri("/secure/profile_process.action") and even prep methods of my action class. Code snippet is below. @Test public void testExecute() throws Exception { ActionProxy proxy = getActionProxy("/secure/profile_process.action"); ProfileAction profileProxy = (ProfileAction) proxy.getAction(); profileProxy.setAppointmentDateCode("09/27/2011:D:8AM-12PM"); String result = proxy.execute(); assertEquals(result, "success"); } Cheers..Thank you
type: Answer
accepted answer of: http://stackoverflow.com/q/21523794
score: 0

http://stackoverflow.com/a/21559340
answers question: http://stackoverflow.com/q/21557972
has body: Use a TreeMultiset from Guava, or a similar class from another library.
score: 0
type: Answer

http://stackoverflow.com/a/21525658
answers question: http://stackoverflow.com/q/21525559
has comment: http://stackoverflow.com/comment/32501410
has comment: http://stackoverflow.com/comment/32501743
has body: You could an array and an interface (ie Runnable): Runnable[] runnables = new Runnable[] { new Runnable() { ... }, new Runnable() { ... }, new Runnable() { ... } }; Random random = new Random(); while (someCondition) { int randomInt = random.nextInt(runnables.length); runnables[randomInt].run(); }
type: Answer
has comment: http://stackoverflow.com/comment/32502103
has comment: http://stackoverflow.com/comment/32502041
has comment: http://stackoverflow.com/comment/32502472
score: 0
has comment: http://stackoverflow.com/comment/32501593
has comment: http://stackoverflow.com/comment/32502331

http://stackoverflow.com/q/21601321
has body: I have a GWT application. Where can I put an initialization code so it runs when the GWT devMode is up? For example, I want to put log("GWT is up...") before everything. I tried to put the code in a servlet, but it seems that they are executed once if it receives a request from client. I don't want that, I want it automatically run whenever the GWT server begins running
answer count: 1
has answer: http://stackoverflow.com/a/21601407
has comment: http://stackoverflow.com/comment/32852524
accepted answer: http://stackoverflow.com/a/21601407
has title: Where should I put an application level initialization code in gwt?
has comment: http://stackoverflow.com/comment/32635077
has comment: http://stackoverflow.com/comment/32635060
has comment: http://stackoverflow.com/comment/32635108
type: AnsweredQuestion
type: Question
tagged with: gwt
tagged with: java
score: 0
has comment: http://stackoverflow.com/comment/32635079

http://stackoverflow.com/q/21641800
possible better answer: http://stackoverflow.com/a/21641846
has title: Recursive method print each letter in a string 3 times backwards
has answer: http://stackoverflow.com/a/21641815
has answer: http://stackoverflow.com/a/21641846
has body: I'm working on a recursive method that will return and print in my main method, each letter of a string three backwards. The string being (args[1]). So for instance, if the string is "stack". It should output to: kkkcccaaatttsss So far I managed to print the string backwards. How should I go about printing each string three times? My code so far: public static void main(String[] args){ int number = Integer.parseInt(args[0]); String word = new String(""); word = args[1]; String methodddd = recursive1.method4(word, number); System.out.println(methodddd); } public static String method4(String word){ int length = word.length(); if (length == length*3){ return ""; } return word.substring(length-1, length) + method4(word.substring(0, length-1)); }
tagged with: string
favorite count: 0
tagged with: command-line
upvote count: 2
accepted answer: http://stackoverflow.com/a/21641815
tagged with: recursion
score: 2
type: AnsweredQuestion
tagged with: java
tagged with: methods
type: Question
answer count: 2
downvote count: 0

http://stackoverflow.com/q/21551661
type: Question
answer count: 1
has answer: http://stackoverflow.com/a/21551749
accepted answer: http://stackoverflow.com/a/21551749
tagged with: static
score: 0
tagged with: android
has title: advice with copying static list
type: AnsweredQuestion
tagged with: list
tagged with: java
has body: public class MainActivity extends Activity { static List&lt;Towar&gt; chosen_items; ...... } public class ItemOrder implements Serializable { static List&lt;Item&gt; item_ordered; .... } And I'm trying to do something like this: ItemOrder.item_ordered = new ArrayList&lt;Item&gt;(MainActivity.chosen_items.size()); Collections.copy(ItemOrder.item_ordered, MainActivity.chosen_items); I want to copy list from MainActivity.chosen_items to ItemOrder.item_ordered and I've got error like this : java.lang.IndexOutOfBoundsException: destination.size() &lt; source.size(): 0 &lt; 1

http://stackoverflow.com/q/21672727
has comment: http://stackoverflow.com/comment/32760861
tagged with: java
has comment: http://stackoverflow.com/comment/32760651
type: Question
has title: Prefix search using BinarySearch
has body: Using prefix string i need to display all possible string from ArrayList using BinarySearch. Is it possible tell me the wright way. BinarySearch(myList, SearchString);
answer count: 1
score: 0
has answer: http://stackoverflow.com/a/21675506
type: UnansweredQuestion

http://stackoverflow.com/comment/32669880
type: AnswerComment
comment on: http://stackoverflow.com/a/21620168
type: Comment
has text: Hey why -1. Can the one who did it explain the reason of his/her act?
score: 0

http://stackoverflow.com/comment/32534346
type: AnswerComment
has text: if I am initialing it there its terminating the program on before starting the above activity
comment on: http://stackoverflow.com/a/21544097
type: Comment
score: 0

http://stackoverflow.com/a/21673560
has body: I think there is no need of regex. String.contains(String chars) returns true if the source string have any occurrence of the argument string. For example: String str = "ABCDEFG"; if(str.contains("CD")){ System.out.println("Present"); }
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21673270
type: Answer
answers question: http://stackoverflow.com/q/21673270
has comment: http://stackoverflow.com/comment/32762144
upvote count: 1
score: 1

http://stackoverflow.com/a/21585651
score: 0
has body: dude you are not supposed to use == for string comparison instead use equals method. string1.equals(string2)
type: Answer
has comment: http://stackoverflow.com/comment/32610537
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/32610908
has comment: http://stackoverflow.com/comment/32608432
answers question: http://stackoverflow.com/q/21585536
has comment: http://stackoverflow.com/comment/32608980

http://stackoverflow.com/comment/32759084
comment on: http://stackoverflow.com/q/21671838
has text: Thank you for ur prompt comments.. the mistake was not declaring in my activity manifest.. thank you all.. :)
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21614411
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/21614643
has answer: http://stackoverflow.com/a/21614600
tagged with: sockets
linked to: http://stackoverflow.com/q/7521741
has title: ServerSocket for datagram type socket?
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32659140
type: Question
possible better answer: http://stackoverflow.com/a/21614600
has body: I have a ftp client-server program which currently uses TCP. I need to now make it work using UDP, so using datagram sockets instead. They way it was working was to create a ServerSocket which would listen for a connection, then give that connection to a Socket, and start a separate thread for that socket. But now using DatagramSocket, there's no equivalent DatagramServerSocket, so I've no idea how I can give clients separate sockets anymore. Is there a server socket for datagrams? import java.io.IOException; import java.net.*; public class Server { public static void main(String[] args) throws IOException { Socket sock; ServerSocket servSock = new ServerSocket(4444, 600); while(true){ sock = servSock.accept(); new ClientHandler(sock).start(); } } }
tagged with: java
has answer: http://stackoverflow.com/a/21614779
accepted answer: http://stackoverflow.com/a/21614779

http://stackoverflow.com/q/21584859
type: Question
tagged with: mule
answer count: 1
has comment: http://stackoverflow.com/comment/32695195
downvote count: 0
has answer: http://stackoverflow.com/a/21585322
accepted answer: http://stackoverflow.com/a/21585322
has comment: http://stackoverflow.com/comment/32614524
favorite count: 0
type: AnsweredQuestion
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32606941
upvote count: 1
has body: Why does this code allow someone to create an inbound message property in a Message Processor (like a Java component) message.setProperty("myProperty", PropertyScope.INBOUND" ); but this does not &lt;set-property value="100" propertyName="myProperty" /&gt; Per documentation, only message source should be able to create inbound property, then why is a Java component able to set inbound message property?
has title: inbound property mule create

http://stackoverflow.com/q/21641850
tagged with: hashcode
tagged with: java
answer count: 1
favorite count: 0
score: 0
has body: I got the issue that two integer resolved to the same hashcode in the testcase as below: public class Test { private final static Logger log = LoggerFactory.getLogger(Test.class); private final static LinkedHashMap&lt;Integer,Integer&gt; map = new LinkedHashMap&lt;Integer,Integer&gt;(); /** * @param args */ public static void main(String[] args) { int j=0; for(int i=0;i&lt;10000;i++){ ++j; int hash = System.identityHashCode(i); if(map.containsKey(hash)){ log.info("hashcode of key "+i+" was conflict with "+map.get(hash)+" hashcode was:"+hash); }else{ map.put(hash, i); } } log.info("length of map:"+map.size()+" expected:"+j); } } The output is as below: 2014-02-08 12:10:59,723 [main] INFO: hashcode of key 1947 was conflict with 422 hashcode was:9578500 &lt;reactive.lib.Test&gt; 2014-02-08 12:10:59,725 [main] INFO: hashcode of key 2246 was conflict with 1966 hashcode was:14850080 &lt;reactive.lib.Test&gt; 2014-02-08 12:10:59,736 [main] INFO: length of map:9998 expected:10000 &lt;reactive.lib.Test&gt; I expected that all Integer has a unique hashcode - can anyone explain? If it helps, this test was under JDK1.6 on Windows.
tagged with: java-6
has title: Two Integer resolved to the same hashcode in java (windows platform)
tagged with: integer
has comment: http://stackoverflow.com/comment/32707194
has answer: http://stackoverflow.com/a/21641858
accepted answer: http://stackoverflow.com/a/21641858
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/32706839
type: Question
type: AnsweredQuestion

http://stackoverflow.com/q/21644132
has comment: http://stackoverflow.com/comment/32711489
has body: I have a databaseHelper class in which I have the following function: public SQLiteDatabase returnDB(){ return DBHelper.getWritableDatabase(); } In my main class(Async Task -- onPreExecute): dbHelper = new DBAdapter(getApplicationContext()); dbHelper.open(); mDb = dbHelper.returnDB(); mDb.beginTransaction(); In doInBackground I process the query like: dbHelper.insert(dateToInsert, CONTACT_NAME, String.valueOf(days), String.valueOf(hou), CONTACT_IMAGE_URI, String.valueOf(min),String.valueOf(mon), String.valueOf(secon), CONTACT_ID, String.valueOf(weeks), String.valueOf(years)); Then in onPostExecute: mDb.endTransaction(); dbHelper.close(); But I get a database locked error, when I try to fetch values into listview immediately after the execution of Async task. Below is the LogCat: 02-08 14:40:06.587: E/SQLiteLog(6394): (5) database is locked 02-08 14:40:06.588: D/SQLiteConnection(6394): executeForString took 2505ms - failed, sql="PRAGMA journal_mode", exception="database is locked (code 5): , while compiling: PRAGMA journal_mode" 02-08 14:40:06.602: E/SQLiteDatabase(6394): Failed to open database '/data/data/com.exa.birthdayrem/databases/Bdr'. 02-08 14:40:06.602: E/SQLiteDatabase(6394): android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5): , while compiling: PRAGMA journal_mode 02-08 14:40:06.602: E/SQLiteDatabase(6394): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) 02-08 14:40:06.602: E/SQLiteDatabase(6394): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882) 02-08 14:40:06.602: E/SQLiteDatabase(6394): at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:627) 02-08 14:40:06.602: E/SQLiteDatabase(6394): at android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:313) 02-08 14:40:06.602: E/SQLiteDatabase(6394): at android.database.sqlite.SQLiteConnection.setWalModeFromConfiguration(SQLiteConnection.java:287) 02…
tagged with: android
has comment: http://stackoverflow.com/comment/32710781
has comment: http://stackoverflow.com/comment/32710944
has comment: http://stackoverflow.com/comment/32711086
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21644858
has title: Trying to increase speed of bulk inserts in Sqlite.
tagged with: java
has comment: http://stackoverflow.com/comment/32711178
has comment: http://stackoverflow.com/comment/32710839
type: Question
has comment: http://stackoverflow.com/comment/32711656
accepted answer: http://stackoverflow.com/a/21644858
score: 0
has comment: http://stackoverflow.com/comment/32710758
has comment: http://stackoverflow.com/comment/32710990
tagged with: sqlite
answer count: 1

http://stackoverflow.com/comment/32634696
has text: Then tempUser.getPhoneNumber() is null. Just check why it is not seting the value. I mean debug the code.
score: 2
comment on: http://stackoverflow.com/q/21600799
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21578284
accepted answer of: http://stackoverflow.com/q/21577160
answers question: http://stackoverflow.com/q/21577160
has comment: http://stackoverflow.com/comment/32596651
has comment: http://stackoverflow.com/comment/32594995
downvote count: 0
has comment: http://stackoverflow.com/comment/32635757
type: Answer
has body: If your class is a JavaBean, I'd advise against accessing the fields directly, instead I'd use the JavaBeans / BeanInfo mechanism. You can do that either by using the Introspector directly or through a helper library like Apache Commons / BeanUtils or Spring's BeanWrapper abstraction. Check this previous answer of mine for reference: Java Reflection: How can i get the all getter methods of a java class and invoke them
score: 1
upvote count: 1
type: AcceptedAnswer

http://stackoverflow.com/comment/32615298
type: AnswerComment
has text: StringBuilder features `reverse`on it's own... :)
type: Comment
comment on: http://stackoverflow.com/a/21589219
score: 0

http://stackoverflow.com/q/21620592
tagged with: java
tagged with: methods
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/21620710
tagged with: validation
has comment: http://stackoverflow.com/comment/32669544
tagged with: arrays
has comment: http://stackoverflow.com/comment/32669560
has comment: http://stackoverflow.com/comment/32669605
score: 0
possible better answer: http://stackoverflow.com/a/21620726
has body: This method allows the user to input the rainfall for every month of the year. I'm trying to prevent data less than zero from being stored in the array. I'm using a do-while loop, but I can't seem to figure out how to check if the input is less than zero. Thanks for your help guys, cheers! public static double[] getRainFall() { double[] rainfallMonths = new double[12]; double[] rainfall = new double[12]; do { for(int x = 0; x &lt; rainfallMonths.length; x++) { System.out.print("What is the rainfall for month #" + (x + 1) + ": "); rainfallMonths[x] = keyboard.nextDouble(); rainfall[x] = rainfallMonths[x]; if(rainfallMonths &lt; 0) { System.out.println("Input is Invalid"); } } }while(rainfallMonths &lt; 0); for(int count = 0; count &lt; rainfallMonths.length; count++) { System.out.println("Rainfall Month #" + (count + 1) + ": " + rainfall[count]); } return rainfall; }
has answer: http://stackoverflow.com/a/21620726
accepted answer: http://stackoverflow.com/a/21620710
has title: I'm trying to create an error message if the data entered in an array is less than zero, input validation
tagged with: loops
type: AnsweredQuestion

http://stackoverflow.com/q/21578771
type: UnansweredQuestion
downvote count: 3
has body: import javax.swing.*; import java.awt.*; import java.awt.event.*; public class MyCalculatorGUI extends JFrame implements ActionListener { JButton tripled, doubled; JTextField input, output; JPanel p1, p2; MyCalculatorGUI() { Container c = getContentPane(); tripled = new JButton("Triple"); tripled.addActionListener(this); doubled = new JButton("Doubled"); doubled.addActionListener(this); input = new JTextField("Input a number here."); output = new JTextField("Result.."); p1.add(doubled); p1.add(tripled); p2.add(input); p2.add(output); c.add(p1); c.add(p2); setVisible(true); setSize(400,400); } public void actionListener(ActionEvent e) { } public static void main(String[] args) { MyCalculatorGUI output = new MyCalculatorGUI(); } public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub } } Eclipse is having a problem with my code where it is MyCalculatorGUI, it says the local variable is not used. Can somebody help me fix this?? I have recently just moved to Eclipse and everything I have tried to fix this isn't working for me.
upvote count: 1
has answer: http://stackoverflow.com/a/21578863
type: Question
has comment: http://stackoverflow.com/comment/32595857
has answer: http://stackoverflow.com/a/21579421
score: -2
tagged with: java
tagged with: eclipse
has answer: http://stackoverflow.com/a/21578823
has answer: http://stackoverflow.com/a/21579070
tagged with: local
has answer: http://stackoverflow.com/a/21578912
has comment: http://stackoverflow.com/comment/32627209
tagged with: variables
favorite count: 0
answer count: 5
has title: Local variable not used [JAVA]

http://stackoverflow.com/comment/32755584
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21669242
has text: I have been getting " The method firstMisMatch(java.lang.String, java.lang.String) is undefined for the type CheckPasswords" error. I really appreciate the help man.
score: 0

http://stackoverflow.com/q/21625632
score: 2
answer count: 0
tagged with: java
has comment: http://stackoverflow.com/comment/32678662
type: Question
has comment: http://stackoverflow.com/comment/32680403
has body: I've a very strange exception on simple request/response to my server. I tested it when my site is used only by me, and the size of the response shouldn't exceed a few kilobytes. Question: What does that mean? Where should I try to fix it? Code: public class Peer implements WebSocketListener { private org.eclipse.jetty.websocket.api.Session session; public void sendResponse(Response response) { try { String stringifiedResponse = Utils.objectToJson(response); //just simple fasterxml mapping if (stringifiedResponse.length() &gt; 30000) { LoggerFactory.getLogger(Peer.class).debug("Big Response = " + stringifiedResponse); } session.getRemote().sendString(stringifiedResponse); //BufferOverflowException!!! } catch (IOException ex) { // Do something! } } public void onWebSocketConnect(org.eclipse.jetty.websocket.api.Session session) { this.session = session; this.session.getPolicy().setMaxTextMessageBufferSize(2097152); this.session.getPolicy().setMaxBinaryMessageSize(2097152); this.session.getPolicy().setMaxBinaryMessageBufferSize(2097152); this.session.getPolicy().setInputBufferSize(2097151); Engine.addPeer(this); } } Stacktrace: java.nio.BufferOverflowException at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:357) at org.eclipse.jetty.websocket.common.extensions.compress.PerMessageDeflateExtension.outgoingFrame(PerMessageDeflateExtension.java:229) at org.eclipse.jetty.websocket.common.extensions.ExtensionStack.outgoingFrame(ExtensionStack.java:273) at org.eclipse.jetty.websocket.common.WebSocketRemoteEndpoint.uncheckedSendFrame(WebSocketRemoteEndpoint.java:297) at org.eclipse.jetty.websocket.common.WebSocketRemoteEndpoint.blockingWrite(WebSocketRemoteEndpoint.java:97) at org.eclipse.jetty.websocket.common.WebSocketRemoteEndpoint.sendString(WebSocketRemoteEndpoint.java:380) at com.levi9.levirs.core.Peer.sendResponse(Peer.java:48) at com.levi9.levirs.communication.user.UserRequestHandler$Login.handle(UserRequestHandler.java:42) at com.levi9.levirs.core.Peer.onWebSoc…
downvote count: 0
tagged with: websocket
favorite count: 0
has comment: http://stackoverflow.com/comment/32680638
upvote count: 2
type: UnansweredQuestion
tagged with: jetty
has title: Websocket: java.nio.BufferOverflowException exception

http://stackoverflow.com/comment/32489203
has text: This is the best solution. Alternatively, you can use a canvas.
comment on: http://stackoverflow.com/a/21514841
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32631815
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21598788
has text: @edubriguenti Sorry the two import files got truncated when i was posting. edited the question. but the problem remains :(

http://stackoverflow.com/comment/32565058
type: Comment
score: 0
has text: I also had to add `java.rmi.server.hostname` but I thought that one only controlled the 'call-me-back' address, i.e. the address embedded in the exported objects, so I didn't think it was related to the issue at hand.
type: AnswerComment
comment on: http://stackoverflow.com/a/21558616

http://stackoverflow.com/comment/32739869
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21661054
type: Comment
has text: Check this http://en.wikipedia.org/wiki/Bitwise_operation about shifting. 110 (6) shifted to 1 bit to right >>1 : 011 (3 = 6/2)

http://stackoverflow.com/a/21524016
answers question: http://stackoverflow.com/q/21523897
type: Answer
score: 0
has body: I think E10 equivalent to 10^10(10 to the power of 10), is that true? Yes. Proof: Use BigDecimal#toPlainString: System.out.println(new BigDecimal(2.0E10).toPlainString()); Output will be 20000000000. Meaning that E10 is 1010. ∎

http://stackoverflow.com/comment/32747475
type: QuestionComment
comment on: http://stackoverflow.com/q/21665036
type: Comment
has text: There will always be more clarifying questions: are you attempting to change the overall value of the internal `BigInteger` to only have 10 digits? Are you only returning the value of the truncated `BigInteger`? If either are true, then you should explore the API on Strings - notably `substring`.
score: 0

http://stackoverflow.com/a/21578724
accepted answer of: http://stackoverflow.com/q/21576502
type: Answer
answers question: http://stackoverflow.com/q/21576502
has comment: http://stackoverflow.com/comment/32595946
has body: In this case you need to extend JSONP MessageBodyWriter called JSONWithPaddingProvider from Jersey 1. It's unfortunate that JSONWithPaddingProvider#isJavascript() is private otherwise it would be easier: @Provider public class CustomJSONWithPaddingProvider extends JSONWithPaddingProvider { @Override public void writeTo(final JSONWithPadding t, final Class&lt;?&gt; type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap&lt;String, Object&gt; httpHeaders, final OutputStream entityStream) throws IOException, WebApplicationException { final boolean isJavascript = mediaType .getSubtype().endsWith("+javascript"); final MediaType mt = isJavascript ? new MediaType("application", "javascript") : mediaType; super.writeTo(t, type, genericType, annotations, mt, httpHeaders, entityStream); } }
score: 3
type: AcceptedAnswer
downvote count: 0
upvote count: 3

http://stackoverflow.com/comment/32680275
score: 0
comment on: http://stackoverflow.com/q/21627097
type: Comment
type: QuestionComment
has text: It was enough to just scan the *Related Questions* which this site was offering you while you were writing the question. See it on the sidebar to the right: [Loose blocks of code](http://stackoverflow.com/questions/20916650/loose-blocks-of-code?rq=1)

http://stackoverflow.com/comment/32733697
comment on: http://stackoverflow.com/a/21657250
type: AnswerComment
score: 0
type: Comment
has text: you didn't define 'keyboard'. define that before use

http://stackoverflow.com/comment/32528536
type: Comment
comment on: http://stackoverflow.com/a/21540326
score: 0
type: AnswerComment
has text: What's not useful about this answer?

http://stackoverflow.com/comment/32591713
comment on: http://stackoverflow.com/q/21576404
has text: Remove the project from Eclipse and afterwards delete the Eclipse specific files (.settings, .classpath, .project) and import the project from scratch.
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/32732452
score: 0
comment on: http://stackoverflow.com/a/21655763
type: Comment
type: AnswerComment
has text: I will post the updated code in a new question tomorrow, at least I'm making progress.

http://stackoverflow.com/q/21638622
upvote count: 1
has answer: http://stackoverflow.com/a/21640607
downvote count: 0
answer count: 1
favorite count: 0
type: UnansweredQuestion
tagged with: selenium-webdriver
score: 1
has comment: http://stackoverflow.com/comment/32701446
tagged with: selenium
has body: I have to check a link, for example I clicking a link and then browser open a different page (lets say click on "About Us" and you get directed to "about us" page). I have to verify that I navigate to the right page with a right URL. My question is how to made a test fail (not just print url in the console) if instead of "About Us" page browser direct me to home page. Any recommendations? I am using webdriver with java.
type: Question
has comment: http://stackoverflow.com/comment/32736171
tagged with: java
has title: How to made test "fail" if browser direct to a wrong URL

http://stackoverflow.com/a/21570090
has body: try this String s = String.format("%0" + numberOfDigits + "d", amount);
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21569931
answers question: http://stackoverflow.com/q/21569931
type: Answer
score: 2
upvote count: 2

http://stackoverflow.com/a/21633628
upvote count: 1
answers question: http://stackoverflow.com/q/21629718
score: 1
downvote count: 0
type: Answer
has body: Answering based on your comment iam getting Invalid config value: appServerPortalDir=/home/naveen/Naveen/PortalDev/liferay-portal-6.2.0-ce-ga1/tom‌​cat-7.0.42/webapps/root error at &lt;plugin&gt; Typically the correct directory name for the webapplication deployed on tomcat is called ROOT (note the capital letters). Try setting to appServerPortalDir=...(shortened).../tom‌​cat-7.0.42/webapps/ROOT
has comment: http://stackoverflow.com/comment/32711500

http://stackoverflow.com/a/21571894
score: 72
has comment: http://stackoverflow.com/comment/126360051
has comment: http://stackoverflow.com/comment/106009044
has comment: http://stackoverflow.com/comment/37906559
has comment: http://stackoverflow.com/comment/116416864
type: Answer
has comment: http://stackoverflow.com/comment/116404972
has comment: http://stackoverflow.com/comment/96952759
upvote count: 72
has comment: http://stackoverflow.com/comment/37908486
has comment: http://stackoverflow.com/comment/38102474
downvote count: 0
has body: The easiest way is to use the countQuery attribute of the the @Query annotation to provide a custom query to be used. @Query(value = "SELECT v FROM VisitEntity v LEFT JOIN FETCH v.comments …", countQuery = "select count(v) from VisitEntity v where …") List&lt;VisitEntity&gt; getVenueVisits(@Param("venueId") long venueId, …);
has comment: http://stackoverflow.com/comment/83135571
has comment: http://stackoverflow.com/comment/116426688
accepted answer of: http://stackoverflow.com/q/21549480
has comment: http://stackoverflow.com/comment/116413919
answers question: http://stackoverflow.com/q/21549480
type: AcceptedAnswer

http://stackoverflow.com/q/21661899
tagged with: java
upvote count: 21
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21662982
score: 21
possible better answer: http://stackoverflow.com/a/51385877
has title: Get all Antlr parsing errors as list of string
has answer: http://stackoverflow.com/a/51385877
accepted answer: http://stackoverflow.com/a/21662982
answer count: 2
downvote count: 0
tagged with: jvm
favorite count: 0
has body: How can I get all parsing errors of Antlr in a list of strings? I use antlr as follows: ANTLRInputStream input = new ANTLRInputStream(System.in); grLexer lexer = new grLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); grParser parser = new grParser(tokens); ParseTree tree = parser.formula(); System.out.println(tree.toStringTree(parser)); For example line 1:0 token recognition error at: '(' line 1:1 token recognition error at: ')' line 1:2 token recognition error at: '(' How can I find out that parsing is executed without an error? I would stop if there is only one parsing error. For example if(tree.hasError()) // FOR EXAMPLE return;
tagged with: antlr4
tagged with: parsing

http://stackoverflow.com/q/21611334
tagged with: debugging
has answer: http://stackoverflow.com/a/21612107
answer count: 1
downvote count: 0
favorite count: 0
type: UnansweredQuestion
has body: So I am trying to publish an Android app to the store, and I get the error message to remove all debugging from the app. Well I started to do research and the only thing I can find are post from nearly 4 years ago and people saying to use ProGuard. Well I am not exactly a Android Developer, and I don't really know any Java. I am using Android Studio to create a simple WebView application for my website. So what files and exact code do I add/remove to so I can get this published. I have added the below code the AndroidManifest.xml to the activity: android:debuggable="false" What else? I don't know exactly where to put the code I have seen in past StackOverflow questions. Is ProGuard now integrated into Android? I'm so confused. EDIT** I have made sure that there are zero calls to Log, and there are no startMethodTracing() and stopMethodTracing() in my code. I am simply following the guide on how to create a simple webview app. I have created only one class myself. Also I cannot find the project.properties file in Android studio.
tagged with: android
score: 1
tagged with: java
upvote count: 1
has title: Remove debug logging in Android Studio
type: Question

http://stackoverflow.com/q/21644737
answer count: 5
has answer: http://stackoverflow.com/a/21644768
has comment: http://stackoverflow.com/comment/32711506
has body: How to declare empty array so that I can enter any number of elements I want. I have tried following codes but they are not working. String newValues[] = new String[]; String newValues[] = new String[] {};
type: AnsweredQuestion
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/21644753
upvote count: 1
possible better answer: http://stackoverflow.com/a/21644773
type: Question
has title: Can we declare empty arrays in Java?
tagged with: arrays
downvote count: 0
has answer: http://stackoverflow.com/a/21644773
has answer: http://stackoverflow.com/a/21644798
favorite count: 0
has answer: http://stackoverflow.com/a/21644826
accepted answer: http://stackoverflow.com/a/21644826

apache
tag name: apache
tags question: http://stackoverflow.com/q/21558795
tags question: http://stackoverflow.com/q/21675444
tags question: http://stackoverflow.com/q/21570476
tags question: http://stackoverflow.com/q/21574478
tags question: http://stackoverflow.com/q/21595241
tags question: http://stackoverflow.com/q/21628464
tags question: http://stackoverflow.com/q/21626465
tags question: http://stackoverflow.com/q/21544245
tags question: http://stackoverflow.com/q/21572564
tags question: http://stackoverflow.com/q/21517275
tags question: http://stackoverflow.com/q/21530724
tags question: http://stackoverflow.com/q/21645438
tags question: http://stackoverflow.com/q/21674323
tags question: http://stackoverflow.com/q/21587566
tags question: http://stackoverflow.com/q/21538222
tags question: http://stackoverflow.com/q/21647362
tags question: http://stackoverflow.com/q/21678082
tags question: http://stackoverflow.com/q/21572303
tags question: http://stackoverflow.com/q/21537792
tags question: http://stackoverflow.com/q/21606710
tags question: http://stackoverflow.com/q/21658410
tags question: http://stackoverflow.com/q/21631699
tags question: http://stackoverflow.com/q/21571582
tags question: http://stackoverflow.com/q/21610186
tags question: http://stackoverflow.com/q/21588499
type: Tag
tags question: http://stackoverflow.com/q/21569127
tags question: http://stackoverflow.com/q/21603085
tags question: http://stackoverflow.com/q/21615850
tags question: http://stackoverflow.com/q/21554110
tags question: http://stackoverflow.com/q/21645478
tags question: http://stackoverflow.com/q/21585857

http://stackoverflow.com/comment/32702184
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21630930
has text: @MickJ, no problem! This is actually quite an interesting (and rare?) way of using Querydsl and we would love to hear how it pans out (http://twitter.com/querydsl).

http://stackoverflow.com/q/21523996
type: AnsweredQuestion
tagged with: wsdl
downvote count: 0
score: 1
tagged with: tomcat
favorite count: 0
type: Question
has title: WSDL over HTTPS in Java
tagged with: soap
has answer: http://stackoverflow.com/a/21524133
accepted answer: http://stackoverflow.com/a/21524133
upvote count: 1
tagged with: web-services
answer count: 1
tagged with: java
linked to: http://stackoverflow.com/q/5158537
has body: We have a java client (not a web app, just a simple batch written in Java) which has to connect to a web service over https. The Web Service lies in an Apache Tomcat Server (7.0) but I do not link directly to it because there is an IIS reverse proxy which exposes the service over https, so the certificates are in the IIS layer not in Tomcat. I notice something strange in the WSDL, i.e. the Service section still has an address like this &lt;soap:address location="http://myApp.it:80/Questionario/CallQuestionario"/&gt; as it does also the type section : &lt;xsd:schema&gt; &lt;xsd:import namespace="http://www.test.it" schemaLocation="http://myApp:80/Questionario/CallQuestionario?xsd=1"/&gt; &lt;/xsd:schema&gt; I still see the location and schemaLocation pointing to an http not https! In fact I get an error when trying to connect to the Web Service: com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection refused: connect Do you think there is some work to do in the IIS layer to fix this problem? Even if I try to connect using Soap-UI I have this error: java.lang.Exception: Failed to load url; https://myApp.it:80/Questionario/CallQuestionario?wsdl, 0 - it looks like the analysis of the Web Service failed. PS: Instead if I create a certificate for Tomcat using the keytool utility and I configure Tomcat editing the server.xml file I notice that, without changing the code of the service, the section gets automaticly updated with the url value in https both in service and type section. In this case (Web Service deployed on Tomcat in https) , after importing the certificate in the client using the following lines of code System.setProperty("javax.net.ssl.trustStore", "[PATH_TO_THE_CERTIFICATE]"); System.setProperty("javax.net.ssl.trustStorePassword", "[PWD]"); System.setProperty("javax.net.ssl.trustStoreType", "JKS"); everything works as it is expected to .

http://stackoverflow.com/a/21541103
has comment: http://stackoverflow.com/comment/32529684
accepted answer of: http://stackoverflow.com/q/21541052
answers question: http://stackoverflow.com/q/21541052
score: 1
upvote count: 1
type: AcceptedAnswer
type: Answer
downvote count: 0
has body: JPanel is opaque by default, meaning that anything that it covers will not be painted. Try making the JPanel transparent by using JPanel#setOpaque and passing it false

http://stackoverflow.com/comment/32745296
type: QuestionComment
type: Comment
score: 2
comment on: http://stackoverflow.com/q/21663948
has text: Show us what you have so far! It's better in my opinion, if someone helps you out with your existing code, than if someone writes it for you! You will learn more from it.

http://stackoverflow.com/a/21620436
score: 17
has body: If there is no "libs" folder then create one then click Project> Android Tools >Add support Library. This will help you. Finally clean the project and restart Eclipse
upvote count: 20
has comment: http://stackoverflow.com/comment/37542073
answers question: http://stackoverflow.com/q/21619305
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21619305
has comment: http://stackoverflow.com/comment/92621386
type: Answer
downvote count: 3

http://stackoverflow.com/comment/32658323
type: AnswerComment
has text: I think this is the correct solution. The scanning is being done in the child context and should be done in the parent. Remove the scanning from the mvc config and add this annotation.
type: Comment
comment on: http://stackoverflow.com/a/21534879
score: 0

http://stackoverflow.com/comment/32642356
has text: You need the `beans.xml` files for CDI to work.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21602411

http://stackoverflow.com/q/21584419
score: 1
tagged with: java
tagged with: formatting
has title: Autoformat HTML-Strings in Java
type: Question
has comment: http://stackoverflow.com/comment/32606402
has comment: http://stackoverflow.com/comment/32606169
has answer: http://stackoverflow.com/a/21584559
accepted answer: http://stackoverflow.com/a/21584559
upvote count: 1
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/32606506
favorite count: 0
tagged with: string-formatting
has comment: http://stackoverflow.com/comment/32606812
has comment: http://stackoverflow.com/comment/32606773
has body: I am autogenerating HTML-Strings in Java. Unfortunately in the output everything appears in a long row. It's too much effort to put \n or \t before the Output-String due to sometimes I'm containing several objects in each other (Like Divs and Tables). Are there some frameworks available which support HTML-Autoformat in Java? Thanks
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/139076

http://stackoverflow.com/q/21629128
upvote count: 1
answer count: 1
favorite count: 0
tagged with: geometry
accepted answer: http://stackoverflow.com/a/21629213
has body: Circle c1 = new Circle(20); c1.relocate(200,200); //Set X and Y What I want to do is make the circle move in circles around an invisible center of rotation. How can that be achieved? Thanks. Edit: I have extremely poor trigonometry skills.
has comment: http://stackoverflow.com/comment/32683789
tagged with: physics
has comment: http://stackoverflow.com/comment/32683703
type: AnsweredQuestion
tagged with: 2d
has answer: http://stackoverflow.com/a/21629213
tagged with: java
downvote count: 1
type: Question
has title: How to make a circle move in circles?
score: 0

http://stackoverflow.com/q/21646694
has title: How to get anonymous values from a thread's stackframe (Java Debug Interface/JDI)
type: UnansweredQuestion
tagged with: interface
has answer: http://stackoverflow.com/a/21649793
tagged with: anonymous
has body: Note: This is regarding the Java Debug Interface (JDI). I know there's the option to get a thread's stackframe, and from that a list of all visible variables and their values. However, I don't know how to get anonymous values, that is values not stored in a variable but "internally" on the stack (or maybe something else?). Things like results from if-evaluations, comparisons, etc. For instance let's say we have this in our code: if(array[i] &gt; x) How/where is that piece of data (i.e. the result: true or false) stored at runtime and what classes or methods within the JDI provide me access to it? Thanks
tagged with: java
type: Question
tagged with: debugging
score: 0
answer count: 1

restful-architecture
type: Tag
tags question: http://stackoverflow.com/q/21608974
tag name: restful-architecture

http://stackoverflow.com/q/21564278
duplicate of: http://stackoverflow.com/q/2236599
has answer: http://stackoverflow.com/a/21564466
has comment: http://stackoverflow.com/comment/32570165
answer count: 3
score: 2
has comment: http://stackoverflow.com/comment/32570870
accepted answer: http://stackoverflow.com/a/21564466
has body: Let's say i have a method being called by passing an object. public String retrieveXyz(Criteria criteria){ //get some info out of criteria and do something. } Is it a good practice to make the criteria final so that this handler cannot be used to target some other object other than the passed one or its an overhead as this doesn't protect the object state from getting changed. public String retrieveXyz(final Criteria criteria){ //get some info out of criteria and do something. }
favorite count: 0
has title: Why is it considered good practice to mark method parameters as final?
has comment: http://stackoverflow.com/comment/32571197
has comment: http://stackoverflow.com/comment/32585127
has comment: http://stackoverflow.com/comment/32571122
type: AnsweredQuestion
tagged with: oop
possible better answer: http://stackoverflow.com/a/21564439
linked to: http://stackoverflow.com/q/12019978
upvote count: 3
tagged with: final
tagged with: java
has answer: http://stackoverflow.com/a/21564439
has comment: http://stackoverflow.com/comment/32587712
has comment: http://stackoverflow.com/comment/32570127
linked to: http://stackoverflow.com/q/316352
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/32570348
has comment: http://stackoverflow.com/comment/32570206
has answer: http://stackoverflow.com/a/21564482
has comment: http://stackoverflow.com/comment/32570198
has comment: http://stackoverflow.com/comment/32570140

http://stackoverflow.com/comment/32707194
type: QuestionComment
score: 0
has text: This is what a hash value is.
comment on: http://stackoverflow.com/q/21641850
type: Comment

http://stackoverflow.com/a/57868789
type: Answer
has body: In case you need to draw 3 or more circles follow this pattern: <?xml version="1.0" encoding="utf-8"?> <padding android:bottom="20dp" android:left="20dp" android:right="20dp" android:top="20dp" /> <size android:width="100dp" android:height="100dp" /> <stroke android:width="20dp" android:color="#0000ff" /> <padding android:bottom="20dp" android:left="20dp" android:right="20dp" android:top="20dp" /> <size android:width="100dp" android:height="100dp" /> <stroke android:width="20dp" android:color="#00ff00" /> <size android:width="100dp" android:height="100dp" /> <solid android:color="#ff0000" /> The result: Note that unlike other answers here, this solutions does not paint circles on top of other circles, which avoids overdraw.
downvote count: 0
score: 16
has comment: http://stackoverflow.com/comment/122788116
answers question: http://stackoverflow.com/q/21613308
upvote count: 16

http://stackoverflow.com/q/21676497
tagged with: eclipse
has body: I tried to install adt 23.3.0 in Eclipse Kepler, but I have a problem. I tried every thing such as run as administrator or uncheck contact all update sites ... But I still have the same problem. I use Windows 8.1 and the error is: Cannot complete the install because one or more required items could not be found. Software being installed: Android Development Tools 22.3.0.v201310242005-887826 (com.android.ide.eclipse.adt.feature.group 22.3.0.v201310242005-887826) Missing requirement: Android Development Tools 22.3.0.v201310242005-887826 (com.android.ide.eclipse.adt.feature.group 22.3.0.v201310242005-887826) requires 'org.eclipse.wst.sse.core 0.0.0' but it could not be found
type: Question
has answer: http://stackoverflow.com/a/24224238
has comment: http://stackoverflow.com/comment/32766646
score: 0
answer count: 1
has title: android development tool error in eclipse kepler and windows 8.1
type: UnansweredQuestion
tagged with: android
has comment: http://stackoverflow.com/comment/32767252
linked to: http://stackoverflow.com/q/4249695
tagged with: java

http://stackoverflow.com/a/21646766
score: 0
type: Answer
has body: So, the thing is, 404 is not really an exception. Filters marked with DispatcherType.ERROR are invoked when I set &lt;error-page&gt; in web.xml.
answers question: http://stackoverflow.com/q/21643934

http://stackoverflow.com/a/21539860
downvote count: 0
has comment: http://stackoverflow.com/comment/32549583
accepted answer of: http://stackoverflow.com/q/21526077
has comment: http://stackoverflow.com/comment/32529813
has body: You add an AjaxEventBehavior to a AjaxEditableMultiLineLabel that is NOT CORRECT. The AjaxEditableMultiLineLabel is a Panel that contains two components: Label Editor (textarea) Any of Ajax behavior has to be add to any of these components. In your case you have to add a behavoir to the editor. (following full working example is on https://repo.twinstone.org/projects/WISTF/repos/wicket-examples-6.x/browse ) The markup Form Result [result placeholder] The code snippet final IModel<String> textModel = Model.of("initial text"); Form<String> form = new Form<>("form", textModel); add(form); AjaxEditableMultiLineLabel<String> textArea = new AjaxEditableMultiLineLabel<String>( "text", textModel) { private static final long serialVersionUID = 1L; @Override protected FormComponent<String> newEditor(MarkupContainer parent, String componentId, IModel<String> model) { final FormComponent<String> editor = super.newEditor(parent, componentId, model); editor.add(new AjaxFormComponentUpdatingBehavior("keyup") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { System.out.println("Ajax update for textArea " + editor.getDefaultModelObjectAsString()); } }); return editor; } }; textArea.setCols(50); textArea.setRows(20); form.add(textArea); form.add(new SubmitLink("submit")); add(new Label("result", textModel)); WARNING: PREVIOUS CODE IS REALLY VERY SLOW The code is very slow, becuase each keypress/release makes following: Call the server with the content of textarea Invoke code on the server side (update, render, etc.) Send back the whole result tag as html in an XML response (AJAX) Replace the whole result tag It is slow on localhost, in a real internet is definitely not usable. SOLUTION Use a simple jQuery updating (JavaScript, jQuery is built in Wicket 6) The code snippet with jQuery updating final IModel<String> textModel = Model.of("initial text"); final Label result = new Label("result", textModel); result.setOutputMar…
upvote count: 2
has comment: http://stackoverflow.com/comment/32539963
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32547152
type: Answer
answers question: http://stackoverflow.com/q/21526077
score: 2

http://stackoverflow.com/comment/32527112
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21539458
has text: Okay, ran a test program with the code: package test: public static void main(string[] args { System.out.println("Testing"); Seems to be working now on the laptop.

http://stackoverflow.com/a/21521156
has body: This line is getting overwritten with the line in the for loop: Cell c2=ws.createRow(1).createCell(1);
type: Answer
has comment: http://stackoverflow.com/comment/32493885
answers question: http://stackoverflow.com/q/21521123
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/32493805
upvote count: 2
has comment: http://stackoverflow.com/comment/32493793

http://stackoverflow.com/comment/32658969
type: AnswerComment
has text: @user3267108 every class extends Object, so you can always override the toString() method to make it print whatever you want.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21614403

http://stackoverflow.com/a/21532700
has comment: http://stackoverflow.com/comment/32515076
has comment: http://stackoverflow.com/comment/32562171
downvote count: 0
answers question: http://stackoverflow.com/q/21532101
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/32540387
upvote count: 2
has body: The following works for me and has the same behaviour as you describe. The Main Activity stays below the Settings activity, while the SettingsActivity slides from bottom to top upon creation. And vice versa. The SettingsActivity slides down (revealing the MainActivity below), when finishing no_change.xml &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;set xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;translate android:duration="700" android:fromYDelta="0" android:toYDelta="0" /&gt; &lt;alpha android:duration="700" android:fromAlpha="1.0" android:toAlpha="1.0" /&gt; &lt;/set&gt; push_up.xml &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;set xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;translate android:duration="700" android:fromYDelta="100%p" android:toYDelta="0" /&gt; &lt;alpha android:duration="700" android:fromAlpha="1.0" android:toAlpha="1.0" /&gt; &lt;/set&gt; push_down.xml &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;set xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;translate android:duration="700" android:fromYDelta="0" android:toYDelta="100%p" /&gt; &lt;alpha android:duration="700" android:fromAlpha="1.0" android:toAlpha="1.0" /&gt; &lt;/set&gt; MainActivity.java //somewhere in your code where the Settings activity is started MainActivity.this.startActivity( new Intent( MainActivity.this, SettingsActivity.class ) ); overridePendingTransition( R.anim.push_up, R.anim.no_change ); SettingsActivity.java // somewhere in your code where the Settings Activity is finished finish(); overridePendingTransition( R.anim.no_change, R.anim.push_down );
has comment: http://stackoverflow.com/comment/32561918
has comment: http://stackoverflow.com/comment/32561157

http://stackoverflow.com/comment/32717278
comment on: http://stackoverflow.com/q/21648095
type: QuestionComment
has text: _"but there is error from the IDE in term of using Integer.parsInt()"_ And what is this error? Note that `r` is a boolean.
score: 1
type: Comment

http://stackoverflow.com/comment/32544885
comment on: http://stackoverflow.com/a/21549961
score: 0
type: Comment
has text: @ Daniel :I m using Apache Tomcat Server, yeah i am starting and stopping server from Eclipse IDE
type: AnswerComment

http://stackoverflow.com/comment/32574033
type: Comment
type: QuestionComment
has text: Please clarify greatly the problems you may be having, because your question is impossible to answer as written, at least for me. More info and pertinent code, please.
score: 0
comment on: http://stackoverflow.com/q/21566221

http://stackoverflow.com/comment/32611982
comment on: http://stackoverflow.com/q/21587385
type: QuestionComment
score: 2
has text: @SotiriosDelimanolis: Correction: `add` returns a `boolean`, not a `Boolean`, and regardless of the type of the list: it's an indication of whether the list changed.
type: Comment

http://stackoverflow.com/comment/32769507
has text: Usually resource ids are not corrupted, you can drag and drop or copy paste xml file from one project to another. Rarely this things happen... But glad my answer helping you somehow...
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21677501

http://stackoverflow.com/comment/32760014
score: 0
has text: It got scanned twice. Once when processing "src", next time when processing "src/plugin". (Just a guess.)
comment on: http://stackoverflow.com/a/21669449
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32635530
comment on: http://stackoverflow.com/q/21600823
type: Comment
type: QuestionComment
has text: For better help sooner, post a [MCTaRE](http://stackoverflow.com/help/mcve) (Minimal Complete Tested and Readable Example). I truly doubt that getting the mouse position is taking so long.
score: 1

http://stackoverflow.com/q/21569655
tagged with: eclipse
type: Question
has answer: http://stackoverflow.com/a/21585917
has body: I am working on eclipse JUNO which has been customized by the company I work for.When i click on a particular menu,it's not working the way it should.So i wanted to go through the code which is responsible for that or may be which plugin gets called when I click it.How can i do it?
answer count: 1
has comment: http://stackoverflow.com/comment/32582100
score: 0
has title: How to debug eclipse backend code?
tagged with: eclipse-plugin
has comment: http://stackoverflow.com/comment/32582305
has comment: http://stackoverflow.com/comment/32587498
accepted answer: http://stackoverflow.com/a/21585917
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/a/21636816
type: Answer
has body: There is no remove method for Array. You can use the Arraylist.remove() method.
downvote count: 0
score: 3
answers question: http://stackoverflow.com/q/21636767
has comment: http://stackoverflow.com/comment/32698078
has comment: http://stackoverflow.com/comment/32698031
upvote count: 3

http://stackoverflow.com/comment/55425672
type: Comment
has text: If you use containsInAnyOrder, you should first make sure both lists have the same size... If `actual.getList()` happens to contain `"item1", "item3", "item2"`, the test will pass and maybe you want to make sure it only contains the items listed... In that case you could use `assertThat(actual.getList().size(), equalTo(2));` before the containsInAnyOrder, this way you make sure both lists have the same contents.
type: AnswerComment
comment on: http://stackoverflow.com/a/21628859
score: 4

http://stackoverflow.com/comment/32510041
type: AnswerComment
type: Comment
has text: Did you run `mvn clean install` ?
comment on: http://stackoverflow.com/a/21530438
score: 0

http://stackoverflow.com/a/32214318
has body: uses session.get(*.class, id); but do not load function
upvote count: 2
score: -3
downvote count: 5
has comment: http://stackoverflow.com/comment/54082007
answers question: http://stackoverflow.com/q/21574236
type: Answer

http://stackoverflow.com/a/21623024
answers question: http://stackoverflow.com/q/21622570
has body: You link the files on your html page in the head of the document. &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;link rel="stylesheet" href="../css/main.css"&gt; &lt;script src="../js/main.js"&gt;&lt;/script&gt; &lt;/head&gt; ... Some people recommend linking javascript at the end of the document (just before the closing body tag) so that the visible elements can be rendered first before the javascript is parsed. Just to clarify, css must be in the head; javascript can be anywhere and possibly/probably optimal at the end.
downvote count: 0
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/comment/32593487
comment on: http://stackoverflow.com/a/21576193
has text: I delete the write in the pom.xml and it still works.
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32761818
comment on: http://stackoverflow.com/a/21673087
score: 0
has text: Nevermind, I read the Javadoc :) I really didn't expect such a difference in behavior.
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32634732
type: Comment
comment on: http://stackoverflow.com/q/21601010
type: QuestionComment
has text: I tried clicking on that plus, but it is not what I want.
score: 0

http://stackoverflow.com/a/21528270
type: Answer
upvote count: 1
has body: What i can conclude is, that you want to sort a List which has duplicates present in it. You are expecting a simple library function for both of these tasks. As far as I know, there is no such library function using which you can remove duplicates and sort it alsol; in case of Lists. Preferrably, you can copy the List contents in a set. Since, TreeSets is sorted, you will not need to sort it explicitly unless and until you want on the basis of some object or specific attribute. This would be an apt solution since, SETS cannot have duplicates where as LISTS can. import java.util.ArrayList; import java.util.Collections; import java.util.TreeSet; import java.util.List; import java.util.Set; public class TestList { public TreeSet copySet(List ls) { TreeSet s = new TreeSet(); s.addAll(ls); return s; } public static void main(String[] args) { List ls = new ArrayList(); ls.add(1); ls.add(1); ls.add(2); ls.add(5); ls.add(4); ls.add(4); TestList obj = new TestList(); TreeSet s1 = obj.copySet(ls); System.out.println(ls); System.out.println(s1); } }
has comment: http://stackoverflow.com/comment/32508769
score: 1
answers question: http://stackoverflow.com/q/21527859
downvote count: 0
has comment: http://stackoverflow.com/comment/32508404

http://stackoverflow.com/tag/html
tags question: http://stackoverflow.com/q/21591252
tags question: http://stackoverflow.com/q/21573368
tags question: http://stackoverflow.com/q/21641734
tags question: http://stackoverflow.com/q/21610810
tags question: http://stackoverflow.com/q/21641642
tags question: http://stackoverflow.com/q/21674139
tags question: http://stackoverflow.com/q/21658541
tags question: http://stackoverflow.com/q/21651519
tags question: http://stackoverflow.com/q/21616653
tags question: http://stackoverflow.com/q/21627587
tags question: http://stackoverflow.com/q/21550575
tags question: http://stackoverflow.com/q/21621157
tags question: http://stackoverflow.com/q/21656222
tags question: http://stackoverflow.com/q/21593988
tags question: http://stackoverflow.com/q/21577990
type: Tag
tags question: http://stackoverflow.com/q/21594979
tags question: http://stackoverflow.com/q/21642268
tags question: http://stackoverflow.com/q/21646246
tags question: http://stackoverflow.com/q/21554308
tags question: http://stackoverflow.com/q/21622570
tags question: http://stackoverflow.com/q/21661471
tags question: http://stackoverflow.com/q/21615714
tags question: http://stackoverflow.com/q/21554026
tags question: http://stackoverflow.com/q/21569988
tags question: http://stackoverflow.com/q/21596702
tags question: http://stackoverflow.com/q/21577522
tags question: http://stackoverflow.com/q/21557905
tags question: http://stackoverflow.com/q/21523199
tags question: http://stackoverflow.com/q/21668372
tags question: http://stackoverflow.com/q/21542006
tags question: http://stackoverflow.com/q/21601153
tags question: http://stackoverflow.com/q/21553290
tags question: http://stackoverflow.com/q/21525784
tags question: http://stackoverflow.com/q/21569138
tags question: http://stackoverflow.com/q/21531371
tags question: http://stackoverflow.com/q/21534467
tags question: http://stackoverflow.com/q/21550156
tags question: http://stackoverflow.com/q/21520419
tags question: http://stackoverflow.com/q/21526544
tags question: http://stackoverflow.com/q/21552315
tag name: html
tags question: http://stackoverflow.com/q/21677926
tags question: http://stackoverflow.com/q/21625882
tags question: http://stackoverflow.com/q/21569238
tags question: http://stackoverflow.com/q/21594611
tags question: http://stackoverflow.com/q/21647943
tags question: http://stackoverflow.com/q/21654734
tags question: http://stackoverflow.com/q/21517486
tags question: http://stackoverflow.com/q/21658621
tags question: http://stackoverflow.com/q/21592406
tags question: http://stackoverflow.com/q/21555002
tags question: http://stackoverflow.com/q/21556067

http://stackoverflow.com/comment/32527248
has text: it highlighted the scanner input and and some the error was: unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21539641

http://stackoverflow.com/a/21573390
score: 0
has body: You can try submitting files through curl. $file_name_with_full_path = realpath('./sample.jpeg'); $post = array('extra_info' =&gt; '123456','file_contents'=&gt;'@'.$file_name_with_full_path); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$target_url); curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); $result=curl_exec ($ch); curl_close ($ch); And to login to a specific website and keep cookies you can make a function similar to this: public static function curlResult ($url, $getHeaders = false, $data) { $options = array( CURLOPT_RETURNTRANSFER =&gt; true, // return web page CURLOPT_HEADER =&gt; false, // return headers CURLOPT_FOLLOWLOCATION =&gt; true, // follow redirects CURLOPT_ENCODING =&gt; "", // handle all encodings CURLOPT_USERAGENT =&gt; "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1", CURLOPT_AUTOREFERER =&gt; true, // set referer on redirect CURLOPT_CONNECTTIMEOUT =&gt; 120, // timeout on connect CURLOPT_TIMEOUT =&gt; 120, // timeout on response CURLOPT_MAXREDIRS =&gt; 10, // stop after 10 redirects CURLOPT_COOKIESESSION =&gt; true, CURLOPT_COOKIEJAR =&gt; dirname(__FILE__) . '/cookie.txt', CURLOPT_COOKIEFILE =&gt; dirname(__FILE__) . '/cookie.txt' ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); if ($data != false) { curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_POST, $data?1:0); } $content = curl_exec( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); if ($getHeaders) { return $header; } return $content; } Then use the function something like: // Login curlResult('urltologin', false, array('username' =&gt; 'test', 'password' =&gt; 'demo'); // Upload curlResult('urltoupload', false, array(file_contents'=&gt;'@'.$file_name_with_full_path));
type: Answer
answers question: http://stackoverflow.com/q/21573368

http://stackoverflow.com/q/21652919
tagged with: escaping
score: -1
has answer: http://stackoverflow.com/a/21653064
answer count: 2
has body: In my Java web app I pull a property from the database and send it to the view/browser layer via the controller. In the HTML, I am expecting the string to look like this: 9" nails Instead it looks like this: "9\" nails" So I plugged Apache StringEscapeUtils into my service layer and ran unescapeJava() on the property. The result became this: "9" nails" A slight improvement but still not right. So my question is whether this is not just a String escaping issue but a more fundamental data issue. In other words, if what I have to do to achieve the desired output is to strip double quotes from the beginning and end of this property, there is a potential to affect other rows of data in unexpected ways - in which case I would have to visually inspect the entire database to make sure I am not displaying some other rows incorrectly based on the meaning of the double quotes character in those other strings. Any direction here would be appreciated. Thanks.
has answer: http://stackoverflow.com/a/21653027
downvote count: 1
tagged with: string
favorite count: 0
has title: Do I have a data issue or a string escaping issue and how do I fix it?
tagged with: stringescapeutils
has comment: http://stackoverflow.com/comment/32726013
has comment: http://stackoverflow.com/comment/32725948
tagged with: double-quotes
type: AnsweredQuestion
upvote count: 0
possible better answer: http://stackoverflow.com/a/21653027
tagged with: java
accepted answer: http://stackoverflow.com/a/21653064
type: Question

http://stackoverflow.com/comment/32744729
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21663672
score: 1
has text: It would be useful to see your LogCat

http://stackoverflow.com/q/21569780
has comment: http://stackoverflow.com/comment/32582218
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/32580494
downvote count: 0
has answer: http://stackoverflow.com/a/21569887
has comment: http://stackoverflow.com/comment/32580559
favorite count: 0
has body: I had some success with this site, and I hope I find more excellent programmers to assist me. So I am at my wit's end with this code. I am very new to programming, especially exceptions. I have looked very hard through my course material and sought help, but I have been quite unsuccessful. I am trying to create an improved parser that will override another parser. It reads a .txt file with student information of it including an ID, a name, a grade, and an optional email address and optional comment as tokens in a String separated by commas. The override checks for errors in each token and throws an exception called ParserException. The exception will check the code and then return an error message if the error is unfixable. For example, if a student puts in an AB for the grade, the exception will flag and check if the input is a valid grade (which it is) and then return, if it is not, then it will throw a ParserException, in this case throw new ParserException(ParserException.GRADE_INVALID_GRADE,lineIndex); This shows that the does not work and sends out a message GRADE_INVALID on the line indexLine I have a list of what I need to have as an output: Any violation of the file format specified in the Input File Format Description section above should result in an ParcerException with an appropriate message Duplicate IDs are not allowed Grade values must be a float (92.0) or a letter grade and not an integer I have all the code to correct and check for errors, but I cannot figure out how to get the try-catch to work. Here's is the override code: @Override public ParserResult parseLine(int lineIndex) { String[] tokens = lines.get(lineIndex).split(","); ArrayList&lt;Integer&gt; idList = new ArrayList&lt;Integer&gt;(); Integer studentId; String name; String grade; String email; String comments; boolean isFloat; float gradeFinal; String editName; studentId = new Integer(tokens[0]); ParserResult result; try{ return super.parseLine(lineIndex); } catch(ParserException e){ // …
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32580574
has title: Exception organization assistance?
upvote count: 1
has answer: http://stackoverflow.com/a/21569912
score: 1
tagged with: java

http://stackoverflow.com/q/21675392
type: Question
downvote count: 0
has answer: http://stackoverflow.com/a/21675761
has body: Below I have a small test program than can verify if the content of a String is full supported in codepage CP852 or not. Is there a more elegant way of doing this? public class CodepageTest { public static void main(String[] args) { try { String test = "æøå123"; String test2 = new String(test.getBytes("CP852"), "CP852"); System.out.println(test); System.out.println(test2); System.out.println("String supported in codepage: " + (test.equals(test2))); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } } Output: æøå123 ???123 String supported in codepage: false
answer count: 1
favorite count: 0
upvote count: 2
has title: Verifying if a String is fully supported in a specific codepage
accepted answer: http://stackoverflow.com/a/21675761
tagged with: codepages
score: 2
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/q/21577260
type: Question
has body: i represents rows and y represents columns in a connect 4 game, I am trying to change the color of the circle depending on the column the user has selected but this code keeps giving an error type mismatch cannot convert state to string. public enum State{ RED, YELLOW, BLANK; }
tagged with: java
has answer: http://stackoverflow.com/a/21577385
has title: Java Changing State
upvote count: 2
has answer: http://stackoverflow.com/a/21577370
downvote count: 0
favorite count: 0
answer count: 3
has answer: http://stackoverflow.com/a/21577325
score: 2
has comment: http://stackoverflow.com/comment/32592772
type: UnansweredQuestion

http://stackoverflow.com/a/21641864
has comment: http://stackoverflow.com/comment/32706922
type: AcceptedAnswer
downvote count: 0
score: 4
type: Answer
has comment: http://stackoverflow.com/comment/32707287
upvote count: 4
accepted answer of: http://stackoverflow.com/q/21641849
answers question: http://stackoverflow.com/q/21641849
has body: Here is your problem: sum += sum + array[i][j]; sum += sum + array[i][j] is the same as sum = sum + sum + array[i][j] (you added sum twice) Should be: sum = sum + array[i][j]; Or sum += array[i][j]; If you want to print the sum of each row only, reset your sum to 0 for each iteration on outer for-loop for (int i = 0; i &lt; array.length; i++){ sum=0; .... If you want to print the sum of each column only, you need to add this: int[] colSum =new int[array[0].length]; Then inside for-loop , add colSum[j]+=array[i][j]; So finally you will have this: int[] colSum =new int[array[0].length]; for (int i = 0; i &lt; array.length; i++){ for (int j = 0; j &lt; array[i].length; j++){ sum += array[i][j]; colSum[j] += array[i][j]; } System.out.println("Print the sum of rows =" + sum); } for(int k=0;k&lt;colSum.length;k++){ System.out.println("Print the sum of columns =" + colSum[k]); }
has comment: http://stackoverflow.com/comment/32707111
has comment: http://stackoverflow.com/comment/32707012
has comment: http://stackoverflow.com/comment/32707369
has comment: http://stackoverflow.com/comment/32706971

http://stackoverflow.com/comment/32701674
type: AnswerComment
has text: @PeterLawrey - A String doesn't necessarily wrap a `char[]`.
type: Comment
comment on: http://stackoverflow.com/a/21638667
score: 0

http://stackoverflow.com/comment/32707279
type: Comment
has text: Thanks ! it worked ... btw my output is giving me a "?" character at the first position in the output String
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21642130

http://stackoverflow.com/comment/32750906
type: AnswerComment
has text: I was but then I started using my phone (Galaxy S4)
score: 0
comment on: http://stackoverflow.com/a/21651616
type: Comment

http://stackoverflow.com/comment/32578861
type: Comment
has text: Thanks anyway. The odd thing is that I get no error at all. It just doesn't work.
comment on: http://stackoverflow.com/a/21547313
score: 0
type: AnswerComment

http://stackoverflow.com/a/21624197
answers question: http://stackoverflow.com/q/21624101
has body: You're closing the accepted socket in the wrong place. It needs to be inside the accept loop.
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/110680065
upvote count: 1
has comment: http://stackoverflow.com/comment/32676320
has comment: http://stackoverflow.com/comment/32675482

http://stackoverflow.com/a/21678404
has comment: http://stackoverflow.com/comment/32773282
type: Answer
score: 1
upvote count: 1
has body: One problem I see in MyCustomRealm is that you are expecting DataSource to be filled in at construction time. There are two ways to resolve this issue; one is to use constructor injection and the other is to use a post construct. Here would be using constructor injection: public class MyCustomRealm extends JdbcRealm { private final DataSource source; @Inject public MyCustomRealm(DataSource source) { super(); this.source = source; // source does not get injected setDataSource(source); } } Here is how you would do it with postConstruct: public class MyCustomRealm extends JdbcRealm { @Inject DataSource source; public MyCustomRealm() { super(); } @javax.annotation.PostConstruct private void postConstruct() { // source does not get injected setDataSource(source); } }
answers question: http://stackoverflow.com/q/21661645
downvote count: 0

http://stackoverflow.com/q/21578550
has answer: http://stackoverflow.com/a/21578626
tagged with: java
has title: Syntax error on token "+"
type: UnansweredQuestion
has body: I'm a new Computer Science student and I'm writing my first program that is using multiple classes. However, I'm getting an error with the getAddition() method, using all double values it won't actually allow me to add them together. public class SodaCanClass { private double SodaCanHeight; private double SodaCanRadius; private double SodaCanAddition; public double getSodaCanHeight(double height) { SodaCanHeight = height; System.out.println("Soda Can Height is: " + SodaCanHeight); return SodaCanHeight; } public double getSodaCanRadius(double radius) { SodaCanRadius = radius; System.out.println("Soda Can Height is: " + SodaCanRadius); return SodaCanRadius; } public void getAddition(double height, double radius){ SodaCanHeight = height; SodaCanRadius = radius; SodaCanHeight + SodaCanRadius = SodaCanAddition; //&lt;---- ERROR HERE } }
upvote count: 0
favorite count: 0
tagged with: token
type: Question
tagged with: double
score: -2
has comment: http://stackoverflow.com/comment/32595126
has comment: http://stackoverflow.com/comment/32595165
tagged with: syntax
downvote count: 2
answer count: 1

http://stackoverflow.com/comment/32595656
comment on: http://stackoverflow.com/a/21577942
type: AnswerComment
score: 0
type: Comment
has text: have you got any exception or it is hang ?

http://stackoverflow.com/a/21592517
has body: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if(keyCode == KeyEvent.KEYCODE_HOME){ Log.d("Jorgesys", "Home button pressed!!!"); } return super.onKeyDown(keyCode, event); } but hey! This no longer works as of 4.0 + , Read this: Capture Home Key Event Try with Back button: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK ) { Log.d("Jorgesys", "Back button pressed!!!"); } return super.onKeyDown(keyCode, event); } To stop the media player, you are using the method: isFinishing(): if the activity is finishing, returns true; else returns false, but you are only pausing the activity not finishing the activity. public void onPause() { if(this.isFinishing()){ //INCORRECT, Here you are pausing you activity not finishing. mp.stop(); } super.onPause(); } so change to: public void onPause() { if(mp.isPlaying()) { mp.stop(); } super.onPause(); } When your activity is on pause, evaluates if your MediaPlayer is playing, if this is true then stops the audio.
has comment: http://stackoverflow.com/comment/32621182
type: Answer
answers question: http://stackoverflow.com/q/21591563
score: 0

http://stackoverflow.com/comment/32743812
comment on: http://stackoverflow.com/q/21662252
has text: Hm, never had to use "String money = String.valueOf(cash);" Wasn't sure how it worked. How would you suggest making "cash" a printable String?
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/21539648
answers question: http://stackoverflow.com/q/21539515
score: -1
type: Answer
has body: Easy fix would be to multiply the outcome by 100, cast them to an int, then divide them by 100 again to a double. It might not be the most elegant solution, but it would work.. EDIT: apparently there's a more elegant solution, so forget it.
downvote count: 1
upvote count: 0
has comment: http://stackoverflow.com/comment/32527997

http://stackoverflow.com/comment/32621196
has text: You get the overflow at different numbers, see my second comment. It'kll get quite painfull to fully port an algorithm to javascript that may deal with numbers that are outside the 32 bit range ^^ It MAY be possible if you implemnt a class in javascript to hold the numbers and do all operations, manually producing any overflow that would occur in java.
score: 0
comment on: http://stackoverflow.com/q/21592234
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21607825
answers question: http://stackoverflow.com/q/21607570
has body: Sorry not enought reputation to comment, first of all you can use switches: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html, it is much easier for codes like this one, and maybe for organization you can use another function that is launched from this one (Just remember to put that strings univeral)
score: 1
upvote count: 1
downvote count: 0
type: Answer

http://stackoverflow.com/a/21625973
has comment: http://stackoverflow.com/comment/32679303
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32678994
upvote count: 5
answers question: http://stackoverflow.com/q/21624093
has comment: http://stackoverflow.com/comment/32682507
type: Answer
accepted answer of: http://stackoverflow.com/q/21624093
has body: To support fixing multiple problems at the same time your quick fix has to implement org.eclipse.ui.views.markers.WorkbenchMarkerResolution and must be registered using the extention point org.eclipse.ui.ide.markerResolution. The following example is from the Eclipse plug-in eclipse-pmd: &lt;extension point="org.eclipse.ui.ide.markerResolution"&gt; &lt;markerResolutionGenerator class="ch.acanda.eclipse.pmd.java.resolution.PMDMarkerResolutionGenerator" markerType="ch.acanda.eclipse.pmd.core.pmdMarker"&gt; &lt;/markerResolutionGenerator&gt; &lt;/extension&gt; It is indeed a bit tricky to create a CompilationUnit from an IMarker and even trickier to find the offending ASTNode. Have a look at the abstract class ASTQuickFix from eclipse-pmd. It creates a CompilationUnit from an IMarker and delegates finding the ASTNode to its subclasses which can define their own node finding strategy, e.g. NodeWithinPositionNodeFinder.
has comment: http://stackoverflow.com/comment/32678303
score: 5

http://stackoverflow.com/q/21548712
score: 0
has body: I am generating an alert from my servlet to the JSP during login like this: My dao: public boolean loginCredentialsAreValid(){ ......................... return true; } My Servlet: if(lmi.loginCredentialsAreValid()){ //Go to the Home Page }else{ request.setAttribute("valid", false); request.getRequestDispatcher("/WEB-INF/jsp/login.jsp"); } My Jsp: &lt;script type="text/javascript"&gt; if(${valid == 'false'}){ alert("Could Not Login\nInvalid Credentials"); } &lt;script&gt; My alert is getting generated Fine But After the Alert the Page is Reloaded without all the data I had Entered. My question is how do I validate login and after the Alert, the Credentials I had entered during login are left intact?
answer count: 1
accepted answer: http://stackoverflow.com/a/21554166
has title: Leave entered details intact after alert JSP
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21554166
tagged with: java
type: Question
tagged with: jsp
tagged with: javascript
tagged with: servlets

http://stackoverflow.com/a/21523390
accepted answer of: http://stackoverflow.com/q/21523195
has comment: http://stackoverflow.com/comment/32502132
upvote count: 2
answers question: http://stackoverflow.com/q/21523195
type: AcceptedAnswer
type: Answer
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/32561463
has body: If you want to do the text search use , the GAE Full text search https://developers.google.com/appengine/docs/java/search/
has comment: http://stackoverflow.com/comment/32502499

http://stackoverflow.com/comment/32709923
has text: How about split on commas then clean up the trailing spaces? Also, you need quantifiers in your regex. `\\w` matches a single character, not a word.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21643766
score: 0

http://stackoverflow.com/comment/32674825
type: QuestionComment
comment on: http://stackoverflow.com/q/21623787
score: 2
has text: It may not solve your problem, but setting the size is making it worse. The JScrollPane has a preffered size set. So by you setting the size of the frame, it limits space for other components.
type: Comment

http://stackoverflow.com/comment/32763930
type: Comment
has text: The question still relevant((
score: 0
comment on: http://stackoverflow.com/q/21672120
type: QuestionComment

http://stackoverflow.com/a/21622915
answers question: http://stackoverflow.com/q/21622596
downvote count: 0
score: 1
type: Answer
upvote count: 1
has body: The HTTP specification states, that all cookie data need to be send with each request, because probably the server needs it. If you do not want that, then do not store data inside cookies, but use a different method of storing this sensitive information. There is as well a good chance, that this sensitive information ends up in the access logs of the target server, another reason to not use cookies for that case.

http://stackoverflow.com/a/21522019
answers question: http://stackoverflow.com/q/21518697
has comment: http://stackoverflow.com/comment/32529123
upvote count: 4
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32517698
score: 4
accepted answer of: http://stackoverflow.com/q/21518697
has comment: http://stackoverflow.com/comment/32534720
has body: When you define the matching method expression in the Pointcut, it should match the actual method on which you would want to advice This is what your pointcut expression should be @Before("execution(public * com.rakuten.gep.sample.businesslogic.impl.SampleBusinessLogicImpl.updateSample(com.rakuten.gep.sample.entity.common.Sample,..) throws *Exception) &amp;&amp; args(sample,..)" +"|| execution(public * com.rakuten.gep.sample.businesslogic.impl.SampleBusinessLogicImpl.createSample(com.rakuten.gep.sample.entity.common.Sample,..) throws *Exception) &amp;&amp; args(sample,..)") Reason: In your case, the method signature is public Sample createSample(Sample sample) throws SampleException { public Sample updateSample(Sample sample) throws SampleException { But, your pointcut is @Before("execution(public * com.rakuten.gep.sample.businesslogic.impl.SampleBusinessLogicImpl.updateSample(com.rakuten.gep.sample.entity.common.Sample,..)) &amp;&amp; args(sample,..) throws *Exception" +"|| execution(public * com.rakuten.gep.sample.businesslogic.impl.SampleBusinessLogicImpl.createSample(com.rakuten.gep.sample.entity.common.Sample,..)) &amp;&amp; args(sample,..) throws *Exception") Notice that the throws *Exception is outside the method declaration in the pointcut expression. And that is why the pointcut expression doesnt match your method declaration. Move the throws *Exception within execution( and it will work. I just tried it. Clarifying the invocation of only one method. Yes, actually.. You do not need to specify the throws *Exception. It would suffice with just the method So, if you remove it completely, it would work perfectly fine, with both the method executions. Now, why update works is because, it is declared first in the Pointcut expression. So, the Pointcut matches the method declaration for updateSample() then it encounters the out of place *Exception and the || is applied to *Exception which actually is nothing. Now, if you just flip the pointcut expression the way it…
has comment: http://stackoverflow.com/comment/32516715
type: Answer

http://stackoverflow.com/comment/32579615
type: Comment
type: AnswerComment
has text: I have same xml that you have defined here. but this site have remove http and www words when i post it. So my web.xml is same as you defined here. Is there any other solution...?
score: 0
comment on: http://stackoverflow.com/a/21569250

http://stackoverflow.com/q/21559316
type: Question
answer count: 1
score: 0
has title: Selection sort with stepped output in java
has comment: http://stackoverflow.com/comment/32561431
has body: New to the site and have had some formal Java training. A problem has been presented for a selection sort algorithm. From the input of an array [ 80 50 -5 9 25 365] Pass 1 [-5 365] Pass 2 [-5 9 80 365] Pass 3 [-5 9 25 50 80 365] The selection sort isn't an issue, it is how to pull the data out in such a manner. Any help or suggestions?
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32560949
has answer: http://stackoverflow.com/a/21559832
has comment: http://stackoverflow.com/comment/32561175
has comment: http://stackoverflow.com/comment/32561702
tagged with: java

http://stackoverflow.com/comment/32670222
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21620983
has text: yeah i tried this method at first and that worked really nice. but i thought that we need to declare laf in the respective class itself.! :) thanks man. well another question, what if I have another class and wish to change it's LAF too? Just adding new class2(); to the main class will do?

http://stackoverflow.com/comment/33011032
type: AnswerComment
comment on: http://stackoverflow.com/a/21731002
score: 0
type: Comment
has text: Excellent! Thank you so much for the help and taking the time to write out the code. Got it implemented and working with my game nicely :)

http://stackoverflow.com/a/21580052
has comment: http://stackoverflow.com/comment/32598718
upvote count: 6
has comment: http://stackoverflow.com/comment/32599541
has comment: http://stackoverflow.com/comment/32599180
has comment: http://stackoverflow.com/comment/32599737
has comment: http://stackoverflow.com/comment/32599315
downvote count: 0
answers question: http://stackoverflow.com/q/21579826
has comment: http://stackoverflow.com/comment/32598186
has body: ImageLoader must be initializated only once. You initializate every time when getView() method is called. It's could be better initializate imageLoder in your class extended from application public class MyApp extends Application { public void onCreate() { super.onCreate(); ContextHolder.context = getApplicationContext(); // Create global configuration and initialize ImageLoader with this configuration ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) .memoryCache(new UsingFreqLimitedMemoryCache(5 * 1024 * 1024)) // 5 Mb (delete most not used image) .build(); ImageLoader.getInstance().init(config); } } Your adapter after that public class ArticleListAdapterHome extends ArrayAdapter&lt;ArticleHome&gt; { Typeface faceLight = Typeface.createFromAsset(getContext().getAssets(), "fonts/Roboto-Light.ttf"); Typeface faceBold = Typeface.createFromAsset(getContext().getAssets(), "fonts/Roboto-Bold.ttf"); private ImageLoader imageLoader; public ArticleListAdapterHome(Activity activity, List&lt;ArticleHome&gt; articles) { super(activity, 0, articles); imageLoader = ImageLoader.getInstance(); } @Override public View getView(int position, View convertView, ViewGroup parent) { Activity activity = (Activity) getContext(); LayoutInflater inflater = activity.getLayoutInflater(); View rowView; ArticleHome article = getItem(position); if (position == 0) { rowView = inflater.inflate(R.layout.item_ligne_home_premier, null); //////////////////////////////////////////////////////// ///// IMAGE /////////////////////////////////////////////////////// ImageView imgfirst = (ImageView) rowView.findViewById(R.id.imgimg) ; DisplayImageOptions options = new DisplayImageOptions.Builder() .cacheInMemory(true) .cacheOnDisc(true) .build(); imageLoader.displayImage(article.getImage(), imgfirst); ListView listV = (ListView)parent; boolean pauseOnScroll = false; // or true boolean pauseOnFling = true; // or false PauseOnScrollListener listener = new PauseOnSc…
type: Answer
score: 6

http://stackoverflow.com/comment/32765266
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21672990
has text: then i cant help you without seeing the html. !!
score: 0

http://stackoverflow.com/a/21645030
answers question: http://stackoverflow.com/q/21644822
has comment: http://stackoverflow.com/comment/32754161
upvote count: 4
accepted answer of: http://stackoverflow.com/q/21644822
has comment: http://stackoverflow.com/comment/32711969
type: AcceptedAnswer
score: 4
type: Answer
has body: When we deploy any web application on server.There is a path something like http://&lt;host&gt;:&lt;port&gt;/&lt;contextPath&gt; this to access that deployed webapp. Now you can set some specific folder in that live web directory where you can save image dynamically.Now with this Get Realpath you can get realpath of your webapp and then append your specified folder's path with that realpath you can save your images so that it will be independent from static path. Suppose as a example: I have one application ABC and deployed on http://www.xyz.com/ABC/ (Context path of deployed webapp). Now in database or in property file or in code I specified one folder named as profilepics in war file.In my method I will get realpath(context path) and append that folder name so path is like http://www.xyz.com/ABC/profilepics/ which store images uploaded by user.Donlt forget to add security to that folder if content stored in that directory is confidential.
has comment: http://stackoverflow.com/comment/32740200
downvote count: 0

http://stackoverflow.com/q/21591178
favorite count: 0
score: 0
has answer: http://stackoverflow.com/a/21591198
linked to: http://stackoverflow.com/q/457629
tagged with: return
duplicate of: http://stackoverflow.com/q/457629
upvote count: 2
downvote count: 2
has body: after c++ i am trying to learn some java, and i have a question about the code i have been working on. I am working on a Fraction class and i got stuck in reduce section. Since the method did not let me to return both "num" and "den", I had to return "n" This is my method public double reduce() { int n = num; int d = den; while (d != 0) { int t = d; d = n % d; n = t; } int gcd = n; num /= gcd; //num = num / greatestCommonDivisor den /= gcd; //den = den / greatestCommonDivisor return n; } I am trying to do "return num, den;" however it does not let me. and this is what i get to reduced test for 100/2 is 2.0 to reduced test for 6/2 is 2.0 when i run System.out.println("to reduced test for " + f4.toString() + " is " + f4.reduce()); System.out.println("to reduced test for " + f6.toString() + " is " +f6.reduce()); Why do i get the 2 when when i am supposed to get 50/1 and 3/1 ? If the IDE let me return num and den at the same time, would that have fixed it? Thanks
linked to: http://stackoverflow.com/q/16609269
accepted answer: http://stackoverflow.com/a/21591198
has comment: http://stackoverflow.com/comment/32618662
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/8557716
tagged with: java
has title: Java how to return two variables?
has answer: http://stackoverflow.com/a/21591223
type: Question
answer count: 2
possible better answer: http://stackoverflow.com/a/21591223

http://stackoverflow.com/comment/32631788
comment on: http://stackoverflow.com/q/21599133
score: 0
type: Comment
type: QuestionComment
has text: You can declare a variable and increment it using jstl as well

http://stackoverflow.com/a/21552293
upvote count: 6
has body: Aren't you making it hard on yourself here? Why not just iterate over the collection and assert for each element? for ( Foo foo : foos ) { assertThat( foo.getDate() , equalTo( barDate ) ); } Cheers,
has comment: http://stackoverflow.com/comment/32548484
accepted answer of: http://stackoverflow.com/q/21552204
answers question: http://stackoverflow.com/q/21552204
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32548177
has comment: http://stackoverflow.com/comment/32548916
score: 6
type: Answer

http://stackoverflow.com/comment/32553454
has text: But they still call the variadic version of `create`, so an array will be created either way, no?
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21555274

http://stackoverflow.com/a/21563812
accepted answer of: http://stackoverflow.com/q/21562135
type: Answer
answers question: http://stackoverflow.com/q/21562135
downvote count: 0
score: 1
has body: The document are trying to unmarshal does not match your XML schema. &lt;AccountInfo AccountID="640480"&gt; &lt;Location LocationID="1490075"/&gt; &lt;Location LocationID="8900561"/&gt; &lt;Location LocationID="2367782"/&gt; &lt;Location LocationID="2226598"/&gt; &lt;/AccountInfo&gt; To make it match the XML schema (see the targetNamespace and elementFormDefault attributes) and your JAXB mappings (see @XmlSchema annotation on the package-info class) you need to declare the namespace information. &lt;AccountInfo xmlns="http://www.cspire.com/omnia/schema" AccountID="640480"&gt; &lt;Location LocationID="1490075"/&gt; &lt;Location LocationID="8900561"/&gt; &lt;Location LocationID="2367782"/&gt; &lt;Location LocationID="2226598"/&gt; &lt;/AccountInfo&gt; Debugging Tip When you can't get JAXB to unmarshal an XML document, try populating the object model and marshalling it to see the XML document that JAXB is expecting.
upvote count: 1
type: AcceptedAnswer

http://stackoverflow.com/q/21626406
score: 5
upvote count: 5
tagged with: odata4j
has answer: http://stackoverflow.com/a/27519005
has comment: http://stackoverflow.com/comment/32679333
has comment: http://stackoverflow.com/comment/34271805
answer count: 1
has body: I am working with an App in Android. It uses a local host server in my PC to get some data. But I am getting warning in LotCat like this after running. 02-07 15:51:48.965: W/System.err(10339): com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 9090): connect failed: ECONNREFUSED (Connection refused) I am using a real device to connect to PC and run my App. android:permission:internet has been enabled in AndroidManifest.xml. The real device which I am using is hTC mobile with Androidv4.2.2. I am not using an asyncTask to call this webservice. Can anyone please help me....
downvote count: 0
has comment: http://stackoverflow.com/comment/32683761
favorite count: 0
has comment: http://stackoverflow.com/comment/32678804
type: UnansweredQuestion
tagged with: android
linked to: http://stackoverflow.com/q/21252879
has comment: http://stackoverflow.com/comment/77508631
has comment: http://stackoverflow.com/comment/32678858
linked to: http://stackoverflow.com/q/2333400
tagged with: java
has comment: http://stackoverflow.com/comment/32754594
has title: java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 9090): connect failed: ECONNREFUSED (Connection refused)
has comment: http://stackoverflow.com/comment/34223411
type: Question
duplicate of: http://stackoverflow.com/q/2333400

http://stackoverflow.com/comment/32757892
comment on: http://stackoverflow.com/q/21642862
score: 0
has text: What exactly do you mean, when you say "the resulting rectangle is a rectangle lined up with BCGF's edge"? Do you mean, that the edges of the resulting rectangle should be parallel to the edges of the second rectangle? If so, does it matter how ABDE is rotated or should it be rotated by the least possible degree so its edges are parallel?
type: QuestionComment
type: Comment

http://stackoverflow.com/a/21556477
type: Answer
upvote count: 1
score: 1
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21556056
has body: The file you are reading is not recorded in UTF-8. You need to know which encoding your file is in before you attempt to read it. If possible open it in whatever text editor you use to examine it and save it off in UTF-8 and try reading it again. (Some text editors will give the option of setting the encoding when you save the file.)
answers question: http://stackoverflow.com/q/21556056

http://stackoverflow.com/comment/32635276
score: 0
type: Comment
type: QuestionComment
has text: (e.hash == hash && ((k = e.key) == key || (key != null && key.equals(k))) returns false, but I don't see values.
comment on: http://stackoverflow.com/q/21600344

http://stackoverflow.com/comment/32527614
comment on: http://stackoverflow.com/q/21539765
score: 0
type: QuestionComment
has text: yes. The app works when I don't call ansGen()
type: Comment

http://stackoverflow.com/comment/32540592
type: QuestionComment
comment on: http://stackoverflow.com/q/21544656
has text: i have to select pixel value at random from difference pixel.If the connected pixel is present in the difference pixel list,i have to merge it to form a region.
score: 0
type: Comment

http://stackoverflow.com/comment/33358562
has text: @RamyaKarri please accept this answer if it was helpful for you
comment on: http://stackoverflow.com/a/21638408
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32662106
has text: Thanks for the nice explanation here and below. Unfortunately this isn't working for me. I just get an unable to locate element. I changed the XXXXX_list to be the table ID and put a segment of the student name in the [text()='Adams']". Is the problem possibly that I have no reference to the tr's. I select the table, then go straigh into looking at //td without first navigating through the tr's? I'm just guessing, I'm sure you'll know more. Thank you
type: Comment
comment on: http://stackoverflow.com/a/21605384
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32493883
type: QuestionComment
has text: Okay, so I have the following vmoptions and from what I can tell, this is the min I can run with. There isn't a noticeable difference one way or the other. -Xms6g -Xmx6g -XX:MaxPermSize=512m -XX:ReservedCodeCacheSize=512m -XX:+UseCompressedOops -XX:SoftRefLRUPolicyMSPerMB=50
comment on: http://stackoverflow.com/q/21520712
score: 0
type: Comment

http://stackoverflow.com/a/21619092
score: 2
upvote count: 2
has body: In gradle build system the minSdkVersion and targetSdkVersion defined in AndroidManifest.xml will be replaced by what you define in your build.gradle file, so I recommend you to remove &lt;uses-sdk /&gt; from AndroidManifest.xml and keep them in only build.gradle files to avoid confusions. You are getting merging failed error because the minSdkVersion and targetSdkVersion in different modules are not equal. minSdkVersion and targetSdkVersion must be equal in all build.gradle files inside a project. EDIT : Note : Don't set minSdkVersion = 7 to anywhere because most of the libraries like Google Play Services and all are using minSdkVersion =8. So try to use minSdkVersion = 8 everywhere in you app. Check your Gradle Console output for detailed report of conflicts. It will show which files in the project are cause of this error.
answers question: http://stackoverflow.com/q/21617080
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/32704046

http://stackoverflow.com/a/21676422
has comment: http://stackoverflow.com/comment/32815249
has comment: http://stackoverflow.com/comment/32815797
score: 0
upvote count: 1
downvote count: 1
has body: This question is certainly undecidable, yet you can find out how a certain combination of java compiler and JVM does it. As far as I can see, nothing could stop one from writing a java compiler that, when it sees a string constant, emits byte code to create that string in the heap in some way as long as the rules stated in the JLS concerning string literals are still maintained. For example, String.intern could maintain a global Map, and the compiler could compile a String literal like follows: create a char array of the desired size put character at index 0 put character at index 1 ... put character at index (length-1) construct the actual string object pass the String just created to String.intern and leave result on the stack Actually, one could have a pre-processor changing all string constants to (extra.HeapString.createString(new char[] { ... })) and have createString create a String instance in such a way that the rules for String literals hold. And you couldn't write a program that could detect if it was compiled from the original source or from the preprocessed one (except through reflection on extra.HeapString).
has comment: http://stackoverflow.com/comment/32766387
has comment: http://stackoverflow.com/comment/32768077
has comment: http://stackoverflow.com/comment/32815810
has comment: http://stackoverflow.com/comment/32815923
has comment: http://stackoverflow.com/comment/32766386
has comment: http://stackoverflow.com/comment/32780890
type: Answer
has comment: http://stackoverflow.com/comment/32811404
has comment: http://stackoverflow.com/comment/32766475
has comment: http://stackoverflow.com/comment/32810336
has comment: http://stackoverflow.com/comment/32776754
answers question: http://stackoverflow.com/q/21676143
has comment: http://stackoverflow.com/comment/32815643
has comment: http://stackoverflow.com/comment/32767428
has comment: http://stackoverflow.com/comment/32815896
has comment: http://stackoverflow.com/comment/32767694

http://stackoverflow.com/comment/32638501
type: AnswerComment
score: 0
type: Comment
has text: 5) http://azkaban.github.io/azkaban2/ is another way of creating DAG of workflows.
comment on: http://stackoverflow.com/a/21521191

http://stackoverflow.com/a/21678271
upvote count: 1
has body: a is global variable. setA() will set the value of a as 6. So every where the value of a will be six. getSeven() is returning 7 but you are not capturing it. So a will remain as it is. try it like this a=getSeven(); setA2(int n)is assigning n to 7 but not to a. try it like this public static void setA2(int n) { a = getSeven(); }
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/21678083
has comment: http://stackoverflow.com/comment/32770628

size
type: Tag
tag name: size
tags question: http://stackoverflow.com/q/21535189
tags question: http://stackoverflow.com/q/21553106

http://stackoverflow.com/q/21632011
tagged with: onclicklistener
tagged with: onclick
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/21632033
has title: The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (new DialogInterface.OnClickListener(){})
tagged with: listview
answer count: 2
score: 2
downvote count: 0
possible better answer: http://stackoverflow.com/a/21632040
has answer: http://stackoverflow.com/a/21632040
favorite count: 0
upvote count: 2
has answer: http://stackoverflow.com/a/21632033
tagged with: android
has body: Attempting to add an onClickListener to items in my listView and I'm getting an error stating: "The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (new DialogInterface.OnClickListener(){})" on the line: holder.imageView.setOnClickListener(new OnClickListener() { The author of this article mentioned the following: In your custom adapter class, you can try this code inside getView() method [java]holder.imageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(context, "Clicked on image", Toast.LENGTH_LONG).show(); } });[/java] It seems as if I might need to modify my current implementation - I'm just not sure exactly how. Source: public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; LayoutInflater inflater = context.getLayoutInflater(); if (convertView == null) { convertView = inflater.inflate(R.layout.list_item2, null); holder = new ViewHolder(); holder.txtSuccess = (TextView) convertView .findViewById(R.id.success); holder.txtCmd = (TextView) convertView.findViewById(R.id.cmd); holder.txtPrice = (TextView) convertView.findViewById(R.id.price); holder.imageView = (ImageView) convertView .findViewById(R.id.thumbnail); convertView.setTag(holder); holder.imageView.setOnClickListener(new OnClickListener() { public void onClick(View v) { Toast.makeText(context, "Clicked on image", Toast.LENGTH_LONG).show(); }
type: AnsweredQuestion

http://stackoverflow.com/comment/32551966
comment on: http://stackoverflow.com/a/21554130
type: Comment
has text: @Hustl3r28 A better way to write to a file: http://www.mkyong.com/java/how-to-write-to-file-in-java-bufferedwriter-example/
score: 1
type: AnswerComment

http://stackoverflow.com/a/21794250
downvote count: 0
has comment: http://stackoverflow.com/comment/33005057
type: Answer
accepted answer of: http://stackoverflow.com/q/21659598
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/33004904
has body: Check sample logica SMPP code. You can set delivery in the SubmitSM SubmitSM request = new SubmitSM(); request.setRegisteredDelivery(true); Did you run the 2 jar files that it logica comes with (smscsim.jar, smpptest.jar) when you set setRegisteredDelivery(1) you can clearly see that simulator sends delivery pdu and testclient receive it
answers question: http://stackoverflow.com/q/21659598
type: AcceptedAnswer

http://stackoverflow.com/a/21544790
score: 10
upvote count: 10
answers question: http://stackoverflow.com/q/21544716
has body: You're using raw types in your class definition (Item&lt;T&gt; is generic, but you're omitting the type parameter &lt;T&gt;), change it to: class Item&lt;T extends Comparable&lt;T&gt;&gt; implements Comparable&lt;Item&lt;T&gt;&gt; (Note the last &lt;T&gt;) The compareTo method will then have to be changed as well: public int compareTo(Item&lt;T&gt; o) { // again, use generics return getT().compareTo(o.getT()); }
type: Answer
downvote count: 0

http://stackoverflow.com/comment/32567146
comment on: http://stackoverflow.com/q/21562638
score: 0
type: Comment
type: QuestionComment
has text: So could you please paste those into the question? It would be quite helpful.

http://stackoverflow.com/a/21621364
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32766146
has body: Sounds suspiciously like a memory leak. Apply standard troubleshooting techniques - Azure is no different to running Java than any other environment. You need to do some load testing in your development environment that simulates your ~100k / 24 hour requests (that's 1.15 requests a second which doesn't sound all that high).
type: Answer
answers question: http://stackoverflow.com/q/21606710
accepted answer of: http://stackoverflow.com/q/21606710
score: 0

http://stackoverflow.com/comment/32664216
score: 0
has text: Java doesn't have pointers, and hence does not have the monadic `*` operator. You need to learn at least a modicum of both languages to translate between them.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21616965

http://stackoverflow.com/a/21525215
has body: Jakson is waiting for an adress object not a boolean value.Try to return a null instead of false.
type: Answer
has comment: http://stackoverflow.com/comment/32500560
answers question: http://stackoverflow.com/q/21524841
accepted answer of: http://stackoverflow.com/q/21524841
score: 0
has comment: http://stackoverflow.com/comment/32500738
type: AcceptedAnswer

http://stackoverflow.com/comment/32704269
has text: So for illustrating, you *roughly* want to 1. draw something, for example with `g.drawRect(x,y,w,h)`, and 2. obtain all pixels that have been affected by this drawing operation as an `Area` object. Is that right? IF this is what you meant: This might be a hassle. You should consider using `Shape` objects for drawing, as they can easily be converted into an `Area` object directly...
type: Comment
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/21635991

http://stackoverflow.com/comment/32684464
has text: That was not the issue, I'll explain in my answer.
type: AnswerComment
comment on: http://stackoverflow.com/a/21619491
score: 0
type: Comment

http://stackoverflow.com/comment/32630136
has text: I've left a comment. You expectations are misplaced. Yo can force Gc to occur via your tool, but not by just setting a reference to null.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21597840
type: Comment

http://stackoverflow.com/comment/32659491
comment on: http://stackoverflow.com/a/21613089
type: AnswerComment
score: 0
has text: No problem. I think Peter has already answered your subsequent question.
type: Comment

http://stackoverflow.com/a/21649854
has body: if you'll pull new question from server everytime you press on button. I suggest you to put those code into new method then just call method when you done work in onClick() method but if you just get all questions at once i suggest you to convert it to JSONObject as you did then do like ArrayList&lt;JSONObject&gt; list = new ArrayList&lt;JSONObject&gt;(); JSONArray names = json.names(); for(int i =0; i&lt;json.length();i++){ JSONObject innerJson = json.getJSONObject(names.optString(i)); /* put stuffs in object*/ /* add object to list */ list.add("parse object"); } after you got a list when you press next button you'll just get your object from the list instead
score: 0
has comment: http://stackoverflow.com/comment/32720695
has comment: http://stackoverflow.com/comment/32720452
type: Answer
has comment: http://stackoverflow.com/comment/32729797
answers question: http://stackoverflow.com/q/21649566

http://stackoverflow.com/a/21640863
accepted answer of: http://stackoverflow.com/q/21640117
has comment: http://stackoverflow.com/comment/32749263
type: Answer
answers question: http://stackoverflow.com/q/21640117
has body: There is no way to guarantee that an attempt to create a file in a directory is going to succeed. Even if you could determine that a directory is writeable, some other program could change something that causes that to no longer to be true ... an instant later. On some systems (e.g. Linux with SELinux in "enforcing" mode), a Java application does not know (and can't find out) about all of the preconditions for a successful creation. The Java security sandbox has a say in the issue ... if your application is sandboxed. The simplest and safest solution is to just attempt to create the file, and deal with the exceptions if it fails.
score: 3
upvote count: 3
has comment: http://stackoverflow.com/comment/131785480
downvote count: 0
type: AcceptedAnswer

http://stackoverflow.com/comment/32660830
comment on: http://stackoverflow.com/q/21615159
type: Comment
type: QuestionComment
has text: Yes. Unfortunately, Android throws RuntimeExceptions, especially when dealing with hardware. The fragment uses a `Camera` underneath, which will throw RuntimeExceptions occasionally since some manufacturers can't seem to develop solid drivers... But, everyone has bugs even the big dogs, I suppose :)
score: 0

http://stackoverflow.com/a/21616562
downvote count: 0
has body: You are printing out a reference to the seven strings and not not the 7 strings. To print out the String either use a for loop for (String str : array) { System.out.println(str); } or use the static Array method Arrays.toString(array);
answers question: http://stackoverflow.com/q/21616534
type: Answer
upvote count: 1
score: 1

http://stackoverflow.com/comment/32561366
type: Comment
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/21559566
has text: What do you mean "why does it work"? What do you _do_ with the `File`? A `File` in Java is simply a path, it is not a file handle. The dots are standard URI syntax.

http://stackoverflow.com/comment/32781285
has text: I am getting those escape char in Java String, I need to replace them with &gt; and &lt; before it goes to parser so parser will not fail
comment on: http://stackoverflow.com/a/21558705
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/21677496
type: Answer
has body: Rohit Jain is right: org.springframework.web.context.ContextLoader line 330ff. protected WebApplicationContext createWebApplicationContext(ServletContext sc) { Class&lt;?&gt; contextClass = determineContextClass(sc); if (!ConfigurableWebApplicationContext.class.isAssignableFrom(contextClass)) { throw new ApplicationContextException("Custom context class [" + contextClass.getName() + "] is not of type [" + ConfigurableWebApplicationContext.class.getName() + "]"); } ConfigurableWebApplicationContext wac = (ConfigurableWebApplicationContext) BeanUtils.instantiateClass(contextClass); return wac; } invoked by public WebApplicationContext initWebApplicationContext(ServletContext servletContext) and this is invoked by ContextLoaderListener.contextInitialized(ServletContextEvent event)
score: 1
upvote count: 1
accepted answer of: http://stackoverflow.com/q/21677275
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32769213
answers question: http://stackoverflow.com/q/21677275
downvote count: 0
has comment: http://stackoverflow.com/comment/32769346

http://stackoverflow.com/comment/32695493
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21635591
score: 0
has text: Because you're comparing one card with itself when `i` and `j` are same value.

http://stackoverflow.com/q/21585440
tagged with: android
has title: Android localization error
tagged with: java
has comment: http://stackoverflow.com/comment/32610020
type: Question
has comment: http://stackoverflow.com/comment/32608144
has body: Please help me! I have one simple app,where there are 'Editetext' ,Folders: values-ru,values,values-hy for localization.I want give Edittext hint from appropriate values folder. But confused ,and example for "en" ,take values from values-hy. Locale locale = new Locale("en"); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale; getApplicationContext().getResources().updateConfiguration(config, null); EditText ed=(EditText)findViewById(R.id.edit); ed.setHint(getResources().getString(R.string.text));`
has answer: http://stackoverflow.com/a/21585811
score: 0
answer count: 1
type: UnansweredQuestion

task
type: Tag
tag name: task
tags question: http://stackoverflow.com/q/21608732
tags question: http://stackoverflow.com/q/21580564

http://stackoverflow.com/comment/32857981
type: Comment
has text: Updated my answer. Your classes needed a bit of work. Hopefully this will help you understand some further java coding concepts.
comment on: http://stackoverflow.com/a/21626264
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32691051
type: Comment
comment on: http://stackoverflow.com/a/21627185
score: 0
type: AnswerComment
has text: Sorry sir I didnt get.It shows method related to JFileChooser.But I need the no of images within the folder image inside the project where the new images saved

http://stackoverflow.com/comment/32786564
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/21606602
has text: I had to add a bunch of other files to compile, it was along the right path. I"ll update my makefile
score: 0

http://stackoverflow.com/comment/32593284
type: Comment
has text: Thank you. It work! Can you tell my why did this work?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21576193

http://stackoverflow.com/q/21543022
tagged with: eclipse
type: Question
answer count: 2
accepted answer: http://stackoverflow.com/a/22559589
favorite count: 0
upvote count: 3
tagged with: android
has title: Setting build path in project.properties
possible better answer: http://stackoverflow.com/a/21655165
has answer: http://stackoverflow.com/a/22559589
has body: I've a android project which is built using ant (ant debug/release) to generate application executable. The dependent projects path has been set from project.properties as follows: android.library.reference.1=../../../backup/cocos2d-x-2.2.1/cocos2dx/platform/android/java android.library.reference.2=../../../backup/adt-bundle-mac-x86_64-20130522/sdk/extras/google/google_play_services/libproject/google-play-services_lib But The path is relative to my system. I wanted to modify the path with some environment variables like: android.library.reference.1=$COCOS_HOME/cocos2dx/platform/android/java But it doesn't works. Do I have to define it somewhere in ant build file? Any kind of help will be appreciated.
downvote count: 0
has answer: http://stackoverflow.com/a/21655165
tagged with: build
type: AnsweredQuestion
score: 3
tagged with: ant
tagged with: java

http://stackoverflow.com/a/23104111
has body: You should check you warning messages. It says several times that the reports were not found. Without any reports found there aren't any results on SonarQube. Try to find the reason why you project is not analysed by this "Code analyse tools". Maybe your tools are not up to date? Or the language of the project is another one then the selected of SonarQube (SonarQube selected "?" as it seems or you changed it for this post to a questionmark). here is an example of your own message: Sensor SurefireSensor... [sonar:sonar] 23:28:43.968 INFO - parsing /opt/app/ci/jenkins/home/jobs/company-ci-build_trunk/workspace/qa/sonar_temp/build/surefire-reports [sonar:sonar] 23:28:43.969 WARN - Reports path not found: /opt/app/ci/jenkins/home/jobs/company-ci-build_trunk/workspace/qa/sonar_temp/build/surefire-reports [sonar:sonar] 23:28:43.972 INFO - Sensor SurefireSensor done: 5 ms [sonar:sonar] 23:28:43.973 INFO - Sensor ResourceToFileMapper... [sonar:sonar] 23:28:43.973 INFO - Sensor ResourceToFileMapper done: 0 ms [sonar:sonar] 23:28:43.974 INFO - Sensor org.sonar.plugins.thucydides.ThucydidesSensor@c184a81... [sonar:sonar] 23:28:43.974 WARN - Thucydides reports not found in /opt/app/ci/jenkins/home/jobs/company-ci-build_trunk/workspace/scripts/target/site/thucydides [sonar:sonar] 23:28:43.974 INFO - Sensor org.sonar.plugins.thucydides.ThucydidesSensor@c184a81 done: 0 ms
answers question: http://stackoverflow.com/q/21618953
score: 0
type: Answer

http://stackoverflow.com/comment/32603793
type: AnswerComment
has text: Thanks. Will update the question. Where most ORM falls flat is that they assume a fully specified schema that can be mapped into concrete POJO, instead of more abstract and flexible list and map-like structure -- they're ignore the weak schema benefits of NOSQL databases.
type: Comment
comment on: http://stackoverflow.com/a/21573643
score: 0

http://stackoverflow.com/a/21592289
score: 5
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21592201
upvote count: 5
answers question: http://stackoverflow.com/q/21592201
type: Answer
has body: the problem is here .. ArrayList&lt;String&gt; hobbies = session.getAttribute("hobbies"); Try typecasting it as getAttribute always returns Object. ArrayList&lt;String&gt; hobbies = (ArrayList&lt;String&gt;)session.getAttribute("hobbies");
downvote count: 0

http://stackoverflow.com/a/21630152
has comment: http://stackoverflow.com/comment/32686429
has comment: http://stackoverflow.com/comment/32686400
type: Answer
has comment: http://stackoverflow.com/comment/32686220
upvote count: 2
score: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/32686404
has comment: http://stackoverflow.com/comment/32685588
has body: You could do: String input = "aaaAbbbb_ccccc1"; input.matches(".*[A-Z0-9 ._,-].*"); Input is just an example of course. This should work. Full Java code: import java.util.regex.Matcher; import java.util.regex.Pattern; public class MainRegex { /** * @param args */ public static void main(String[] args) { String input = "aaaAbbbb_ccccc1"; System.out.println(input.matches(".*[A-Z0-9 ._,-].*")); } } Explanation of the pattern on Regex101: http://regex101.com/r/fZ3mK0
has comment: http://stackoverflow.com/comment/32686061
has comment: http://stackoverflow.com/comment/32686551
answers question: http://stackoverflow.com/q/21629802
has comment: http://stackoverflow.com/comment/32685694
has comment: http://stackoverflow.com/comment/32685578
has comment: http://stackoverflow.com/comment/32685565

http://stackoverflow.com/a/21531179
answers question: http://stackoverflow.com/q/21530529
has body: h2 database uses GROUP as a reserved word and as long as you use it you will have errors at table generations and at other queries generated by hibernate. Either rename your model-class or use the class-level annotation @Table as documented in the JBoss hibernate reference (esp. Section 2.1.1.1) Example usage: @Entity @Table(name="group_table") public class Group {
accepted answer of: http://stackoverflow.com/q/21530529
score: 5
type: AcceptedAnswer
upvote count: 5
type: Answer
downvote count: 0

http://stackoverflow.com/q/21593404
type: UnansweredQuestion
downvote count: 1
has answer: http://stackoverflow.com/a/21593445
tagged with: java
score: -1
type: Question
answer count: 2
upvote count: 0
tagged with: applet
has comment: http://stackoverflow.com/comment/32622199
favorite count: 0
has body: I wrote http://pastebin.com/EwShF3YS for school; It's a simple java applet with a GUI pair of eyes that watches the cursor as it moves. It runs well in a compiler (NetBeans 7.4) , but for the life of me I'm having difficulty understanding why it doesn't run in a browser. I'm getting ClassNotFound exceptions. All the reading I've been doing suggests that a .class file isn't required because it's an applet, the browser should generate one at runtime. And if a class is required, how come NetBeans can run it without one? The HTML file is stored in the same directory as the .java - and it's real simple: WatchMe I've tried a variety of different things, different browsers, setting classpath; opening it on different computers. The result is always the same, ClassNotFound exception. The internet research I've been doing yields mostly unproductive answers, such as one person who completely reloaded his PC. I've noticed that if I fully qualify the path to WatchMe.class I get a hang/blank browser page. I'm completely out of ideas, so any suggestions or advice is welcome.
has title: ClassNotFoundException running simple applets
has answer: http://stackoverflow.com/a/21593527

http://stackoverflow.com/a/21633024
upvote count: 5
accepted answer of: http://stackoverflow.com/q/21632979
answers question: http://stackoverflow.com/q/21632979
score: 5
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/32691131
has comment: http://stackoverflow.com/comment/32691047
has body: Make that method generic: public static &lt;T extends Room&gt; T makeRoom(Class&lt;T&gt; roomClass) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException{ // This is enough, if you have 0-arg constructor in all your subclasses return roomClass.newInstance(); } and then invoke it like: MagicRoom magicRoom = MazeGame.makeRoom(MagicRoom.class);

http://stackoverflow.com/comment/32716448
type: Comment
score: 1
has text: Why would you use a switch statement? If you want each enum to have a department full name, then add it as a field of the enum, as you're doing with the department code. Or do you mean that the name of the enum (FINANCE, for example) is the department's full name? Enums have a name() method, which returns their name.
comment on: http://stackoverflow.com/q/21647628
type: QuestionComment

http://stackoverflow.com/comment/32681302
type: QuestionComment
comment on: http://stackoverflow.com/q/21626916
has text: GWT provides layout panels for this. See http://www.gwtproject.org/doc/latest/DevGuideUiPanels.html.
score: 1
type: Comment

http://stackoverflow.com/comment/32577520
has text: Thanks a lot Alex. It helped me a lot.. Good way of answering :)
type: AnswerComment
comment on: http://stackoverflow.com/a/21550227
type: Comment
score: 0

http://stackoverflow.com/q/21646912
has answer: http://stackoverflow.com/a/21647125
possible better answer: http://stackoverflow.com/a/21647302
has body: The point of this program is to remove certain sports teams and their members from a text file, then overwrite the original file with the new set of values. This is attempted by reading the values into an array, then looping through the array and deleting the name of the team and the next 2 lines but for some reason it stops going through the array after the index. I'm stuck, so any help would be great Code: private void RemoveSportsTeamButtonActionPerformed(java.awt.event.ActionEvent evt) { String ChosenTeam = ""; ChosenTeam = JOptionPane.showInputDialog("What Team Do you want to remove?"); ArrayList&lt;String&gt; Teamlist = new ArrayList&lt;String&gt;(); if (ChosenTeam.length() &gt; 0) { } else { Scanner Reader = null; try { Reader = new Scanner(new File("ListofSportTeams.txt")); } catch (FileNotFoundException ex) { } while (Reader.hasNext()) { Teamlist.add(Reader.next()); } Reader.close(); for (int count = 0; count &lt; Teamlist.size(); count++) { { if (Teamlist.get(count).equals(ChosenTeam)) { Teamlist.remove(count); Teamlist.remove(count + 1); Teamlist.remove(count + 2); } } } } } SportTeamList.txt = Team1 Jeff James Team2 Steve Peter
has title: Having problems reading from and deleting certain lines from a file?
type: AnsweredQuestion
tagged with: java.util.scanner
tagged with: java
tagged with: file
type: Question
has comment: http://stackoverflow.com/comment/32715249
accepted answer: http://stackoverflow.com/a/21647125
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/21647302

oracle-database
tags question: http://stackoverflow.com/q/21660678
tags question: http://stackoverflow.com/q/21533702
tags question: http://stackoverflow.com/q/21674661
tags question: http://stackoverflow.com/q/21545108
tag name: oracle-database
tags question: http://stackoverflow.com/q/21664968
type: Tag
tags question: http://stackoverflow.com/q/21671445
tags question: http://stackoverflow.com/q/21581253
tags question: http://stackoverflow.com/q/21670627
tags question: http://stackoverflow.com/q/21531067
tags question: http://stackoverflow.com/q/21617648
tags question: http://stackoverflow.com/q/21641835
tags question: http://stackoverflow.com/q/21570365
tags question: http://stackoverflow.com/q/21576525
tags question: http://stackoverflow.com/q/21629906
tags question: http://stackoverflow.com/q/21588854
tags question: http://stackoverflow.com/q/21622382
tags question: http://stackoverflow.com/q/21532656
tags question: http://stackoverflow.com/q/21628887
tags question: http://stackoverflow.com/q/21598828
tags question: http://stackoverflow.com/q/21670360
tags question: http://stackoverflow.com/q/21589155
tags question: http://stackoverflow.com/q/21602762
tags question: http://stackoverflow.com/q/21526251
tags question: http://stackoverflow.com/q/21676257
tags question: http://stackoverflow.com/q/21590633

http://stackoverflow.com/q/21597986
has comment: http://stackoverflow.com/comment/32630800
has title: not able to resolve java.net.UnknownHostException
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32631252
has comment: http://stackoverflow.com/comment/32629840
has comment: http://stackoverflow.com/comment/32631029
has comment: http://stackoverflow.com/comment/32631275
has comment: http://stackoverflow.com/comment/32629890
tagged with: asp.net
type: Question
has comment: http://stackoverflow.com/comment/32631367
tagged with: telnet
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/32631628
has comment: http://stackoverflow.com/comment/32631451
has body: am trying to connect to server using TelnetWrapper from apache.commons.net jar before some days it was working file but now suddenly its giving java.net.UnknownHostException am not able to figure out why can you please give me what could be the possible reason behind this because it was working fine before it suddenly started giving exceptions Thanks in advance complete exception is Wrapper: java.net.UnknownHostException: cmsrv3 java.lang.Exception: Error connecting to telnet server. at com.honeywell.corept.util.TelnetClient.&lt;init&gt;(TelnetClient.java:25) at com.honeywell.corept.cm21.TelnetClient.&lt;init&gt;(TelnetClient.java:18) at cm21.build.CM21Build.main(Build.java:576)
has comment: http://stackoverflow.com/comment/32632646
has comment: http://stackoverflow.com/comment/32632683
answer count: 0

android-gallery
tags question: http://stackoverflow.com/q/21617275
tag name: android-gallery
type: Tag

http://stackoverflow.com/q/21671582
has comment: http://stackoverflow.com/comment/32758276
tagged with: image
has comment: http://stackoverflow.com/comment/32758304
type: Question
has title: Image Processing Filters on Java
has answer: http://stackoverflow.com/a/21671676
answer count: 1
has body: Ok.. i'm making a project on Image processing on Java and uptill now i've comnpleted almost all the filters that has to do with RGB filtering. (b/w, sepia, etc) But now i want to add text to image where we get to select the string/jlabel we want to put in the image via a dialog box or a pop up textarea..(what i mean to say is that the text will be decided by the user) The Program accepts Pixelimage and returns pixel image too.. Now i'm quite new to image so plz it wud be vry helpfull if some1 can assist me with this..
favorite count: 0
score: 0
upvote count: 1
downvote count: 1
accepted answer: http://stackoverflow.com/a/21671676
type: AnsweredQuestion
tagged with: java
linked to: http://stackoverflow.com/q/10929524

http://stackoverflow.com/comment/32635323
type: Comment
comment on: http://stackoverflow.com/a/21601493
type: AnswerComment
has text: and what do I do with that element, so I can get the ItemObject id?
score: 0

http://stackoverflow.com/a/21663719
has body: forestOwnerCtr.createForest(name, location, squaremetre, treesorts, price); Please check this line. Something might be wrong with the object instantiation. From what you've posted above , can tell this much.
downvote count: 0
has comment: http://stackoverflow.com/comment/32744972
score: 1
answers question: http://stackoverflow.com/q/21663225
has comment: http://stackoverflow.com/comment/32745115
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32745067
type: Answer
accepted answer of: http://stackoverflow.com/q/21663225

http://stackoverflow.com/a/24025886
downvote count: 0
has body: Debugging the java source code I realized that the method containsKey checks two things on the searched key against every element in the key set: hashCode and equals; and it does it in that order. It means that if obj1.hashCode() != obj2.hashCode(), it returns false (without evaluating obj1.equals(obj2). But, if obj1.hashCode() == obj2.hashCode(), then it returns obj1.equals(obj2) You have to be sure that both methods -may be you have to override them- evaluate to true for your defined criteria.
upvote count: 8
type: Answer
score: 8
answers question: http://stackoverflow.com/q/21600344
has comment: http://stackoverflow.com/comment/106035000

http://stackoverflow.com/comment/32769615
comment on: http://stackoverflow.com/a/21678054
type: AnswerComment
has text: You know, he can learn by example maybe. I will add comments for better understanding :/
score: 0
type: Comment

http://stackoverflow.com/a/21591118
type: Answer
score: 2
has body: You could use JDBC batch processing (addBatch, executeBatch), which allows you to "stack" statements and send them all to the db engine to be executed at once. Here a starting point: http://viralpatel.net/blogs/batch-insert-in-java-jdbc/ But you would still need to split it up into separate statements, and add them one at a time. Java: splitting a comma-separated string but ignoring commas in quotes And, as @CHEBURASHKA has pointed out, it only returns the number of rows affected by each statement - no good if you want to ask for actual data from the tables.
downvote count: 0
has comment: http://stackoverflow.com/comment/32622494
answers question: http://stackoverflow.com/q/21590948
upvote count: 2
has comment: http://stackoverflow.com/comment/32620603

http://stackoverflow.com/a/21578725
has comment: http://stackoverflow.com/comment/32596698
answers question: http://stackoverflow.com/q/21578432
has comment: http://stackoverflow.com/comment/32597401
downvote count: 0
score: 8
upvote count: 8
type: Answer
has body: Just use the Enum.ordinal() method of an enum to get the ordered number from 0 to X which you can compare to your x variable: public class Game { public enum State { BLANK, // 0 RED, // 1 YELLOW // 2 } public State getState(int x, int y) { y = 1; for (x = 5; x &gt; 0; x--) { if (x == State.BLANK.ordinal() &amp;&amp; y == State.BLANK.ordinal()) { return State.RED; } //return State.BLANK; } return State.BLANK; } }

http://stackoverflow.com/comment/32625668
has text: Hi, how can I implement the limit size of the arrayList, I tried this but it did not work... if arrayList <= 6 I pasted my code method where the user can store stuff in. else print an error. but this was not working, what do I need to do with the else statement. Thanks.
type: Comment
comment on: http://stackoverflow.com/a/21595279
score: 0
type: AnswerComment

http://stackoverflow.com/a/21557290
answers question: http://stackoverflow.com/q/21557225
downvote count: 0
score: 5
has body: Will default object constructor construct a object with negative value for any of the member element. No. The Java class-members have default values as follows: int, long, short, char, byte default to 0. boolean defaults to false. Non-primitive members default to null. Have in mind that the Wrapper implementations will default also with null, because their instances are objects, not primitives.
type: AcceptedAnswer
upvote count: 5
accepted answer of: http://stackoverflow.com/q/21557225
type: Answer

http://stackoverflow.com/a/21535873
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/21535708
accepted answer of: http://stackoverflow.com/q/21535708
upvote count: 1
type: AcceptedAnswer
has body: major version numbers are as follows : J2SE 8 = 52, J2SE 7 = 51, J2SE 6.0 = 50, J2SE 5.0 = 49, JDK 1.4 = 48, JDK 1.3 = 47, JDK 1.2 = 46, JDK 1.1 = 45 (source : http://en.wikipedia.org/wiki/Java_class_file) try compiling with a JDK 1.7

http://stackoverflow.com/a/21538413
downvote count: 0
type: Answer
score: 1
has body: Inject the DataSource and EntityManagerFactory into the JpaTransactionManager bean. See class-level comment @ http://docs.spring.io/spring/docs/3.2.5.RELEASE/javadoc-api/org/springframework/orm/jpa/JpaTransactionManager.html for more info.
answers question: http://stackoverflow.com/q/21537211
upvote count: 1

http://stackoverflow.com/q/21615511
tagged with: swing
type: Question
has comment: http://stackoverflow.com/comment/32790579
has body: First of all, I apologize for the unruliness of this question, I tried to explain everything that was essential without leaving anything important out or giving anything extra, but I may not have done the best job. I would post code but there is just way too much of it tot be able to post. I am developing a game in Java, using no external libraries. I have a main class that also handles my Jframe. It sets everything up, such as size, title, etc, then starts a new Thread that handles everything else that's not basic setup. It's an loop that runs until the game is closed. It basically consists of update, then render. Those methods call the corresponding method in a state managing class, which contains an instance of a custom GUI class that I extend for all of my GUIs. I have it declared as a GUI rather than one of GUI's subclasses so that whenever I need to switch GUIs I can simply swap in a new one seamlessly. So the basic flow of the program is the threads update() -> state manager's update() -> GUI's update(), then the same thing for render. So my question is, since I have the Jframe declared outside of my thread, what is the best way to pass mouse input into the thread? If there was just a single object that I could grab and send into the GUI, it should be simple. But since there could potentially be multiple MouseEvents coming from the MouseAdapter between each frame, I can't seem to wrap my head around how to do this. The best idea I've come up with was to make an array of MouseEvents, then iterate through it in the update method. However, for some reason Eclipse kept giving me errors when. I tried to make the array, so I gave up on that in about a minute.
tagged with: mouseevent
score: 0
has comment: http://stackoverflow.com/comment/32791003
has title: Handling mouse input in a multi threaded game
has comment: http://stackoverflow.com/comment/32661043
answer count: 0
type: UnansweredQuestion
tagged with: java
tagged with: multithreading

http://stackoverflow.com/comment/32630384
score: 0
type: AnswerComment
has text: Finally, as a bonus, it is a good practice to check for availability of Google Play Services, more info here : http://developer.android.com/training/location/retrieve-current.html
comment on: http://stackoverflow.com/a/21598235
type: Comment

http://stackoverflow.com/q/21532053
score: 0
has comment: http://stackoverflow.com/comment/32513321
type: UnansweredQuestion
has title: Resource handling with plug ins
has comment: http://stackoverflow.com/comment/32513223
tagged with: java
linked to: http://stackoverflow.com/q/421280
has answer: http://stackoverflow.com/a/21532942
type: Question
answer count: 1
has comment: http://stackoverflow.com/comment/32516075
has body: I would like your opinion on my implementation on loading resources in my application that supports plug ins. In my main application I have a resource handler class that I have exposed to my plug ins. This class was created as a helper class when plug ins try to get their resources. public class ResourceHelper{ private Class&lt;?&gt; T; public ResrouceHandler(Class&lt;?&gt; T){ this.T = T; } public BufferedImage getImageResource(String path){ T.getClassLoader().getResource()... } } In order to use the helper the caller has to create an instance. ResourceHelper resourceHelper = new ResourceHelper(getClass()) But I would prefer to not use the getClass() method anymore but rather have the ResourceHelper get the current classloader on its own. I have tried using Thread.currentThread().getContextClassLoader() but it doesnt seem to work.

http://stackoverflow.com/q/21654601
tagged with: byte
has body: I created the byte array but don't know if this is the way you put strings of numbers into it. I am new to this byte array and am having trouble knowing if I did it right. public class AdditionOnlyInt implements BigInt { private byte[] data; public AdditionOnlyInt(String number) { data = new byte[number.length()]; number.replace("0",""); int i = 0; int counter = number.length(); while(i&lt;number.length()) { data[i] = (byte) number.charAt(counter); i++; } } } I have to get rid of the leading zeros then put the number in the array from least significant to most significant that is the reason for the counter variable
has comment: http://stackoverflow.com/comment/32729395
has comment: http://stackoverflow.com/comment/32731019
has comment: http://stackoverflow.com/comment/32729030
has comment: http://stackoverflow.com/comment/32729109
favorite count: 0
score: 2
upvote count: 2
type: UnansweredQuestion
type: Question
has title: Putting strings into byte arrays
tagged with: java
has answer: http://stackoverflow.com/a/21655751
answer count: 2
tagged with: arrays
downvote count: 0
tagged with: string
has answer: http://stackoverflow.com/a/21655857

http://stackoverflow.com/q/21532136
tagged with: struts2
has comment: http://stackoverflow.com/comment/32514367
has comment: http://stackoverflow.com/comment/34979978
answer count: 0
type: UnansweredQuestion
has body: I cannot make @javax.validation.Valid annotation work in hibernate,struts2 webapp. Here is my simple Entity with constraints: import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.NotEmpty; @Entity @Table(name = "user") public class User implements Serializable { @Id @GeneratedValue @Column(name = "user_id") private Long id; @NotEmpty @Length(max = 50, min = 3, message = "Name should be not less 3 and not more 50") @Column(name = "name", nullable = false) private String name; @Length(min = 6, max = 10) @Column(name = "password") private String password; @NotEmpty(message = "Please select a gender") @Column(name = "gender") private String gender; @NotEmpty(message = "Please select a country") @Column(name = "country") private String country; @Length(max = 100) @Column(name = "aboutYou") private String aboutYou; @Column(name = "mailinglist") private Boolean mailingList; Here is my UserAction class that uses @Valid annotation: public class UserAction extends ActionSupport implements ModelDriven<User> { @Valid private User user = new User(); private UserDao dao = new UserDao(); private List<User> users = new ArrayList<User>(); public String addUser() { dao.addUser(user); users = dao.listUsers(); return SUCCESS; } public List<User> getUsers() { return users; } public User getModel() { return user; } } Here is my jsp which should display error messages when hibernate constraints fail. Add user: <s:actionerror/> <s:form action="addUser"> <s:textfield key="name" /> <s:password key="password" /> <s:radio list="{'Male','Female'}" key="gender" /> <s:select list="{'India','USA','Ukraine'}" headerKey="" headerValue="Select" key="country" /> <s:textarea key="aboutYou" cols="20" rows="10" /> <s:checkbox key="mailingList" value="true" /> <s:submit value="Post" /> </s:form> When I submit empty form then no hibernate constraint works and new user is added to database and of course no error is displayed on jsp page. Don't you know what's wrong? …
has title: How to trigger validation with @Valid annotation in struts2?
has comment: http://stackoverflow.com/comment/32517881
tagged with: struts2-jsr303-plugin
tagged with: java
tagged with: hibernate
type: Question
score: 0
has comment: http://stackoverflow.com/comment/32515526
tagged with: bean-validation

http://stackoverflow.com/q/21535811
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32520510
has body: I am trying to find a regular expression pattern that takes the following data: static String testData = "0001,48;0451,0605\\,230001;0461,0606\\;230006;0431,0605230002"; and prints out to groups such as: Group 1: 0001,48; Group 2: 0451,0605\\,230001; Group 3: 0461,0606\\;230006; Group 4: 0431,0605230002; The pattern I have currently is not efficent in parsing the escape sequence that appears in '0605\,230001'. static String testPattern = "([\\d]{4}" + "[,]{1}"+ "(?:[[a-zA-Z0-9][\\;][\\,][\\(][\\)][\\s]]*)"+ "[;]{1})" ; The above pattern is only efficient in printing as mentioned: Group 1: 0001,48; Group 2: 0431,0605230001; Rest of the code: Pattern pattern=Pattern.compile(testPattern); Matcher matcher = pattern.matcher(testData); System.out.println("Test Matches: "+testData.matches(testPattern)); while(matcher.find()) { for (int i = 1; i &lt;= matcher.groupCount(); i++) { System.out.println("Group " + i + ": " + matcher.group(i)); } } Is there way where we can have the escape sequences in the pattern and also not escape them when we want it?
has comment: http://stackoverflow.com/comment/32520125
has answer: http://stackoverflow.com/a/21742102
score: 0
has answer: http://stackoverflow.com/a/21536089
accepted answer: http://stackoverflow.com/a/21536089
possible better answer: http://stackoverflow.com/a/21536109
has answer: http://stackoverflow.com/a/21536231
linked to: http://stackoverflow.com/q/21698185
has comment: http://stackoverflow.com/comment/32520018
answer count: 4
has title: regex include and exclude escape sequences
has comment: http://stackoverflow.com/comment/32519992
tagged with: regex
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21536109
has comment: http://stackoverflow.com/comment/32520056

http://stackoverflow.com/q/21574610
has title: Java Socket only works on "localhost" but not in private network
upvote count: 1
accepted answer: http://stackoverflow.com/a/21574872
tagged with: localhost
type: AnsweredQuestion
tagged with: subnet
has comment: http://stackoverflow.com/comment/32588452
has answer: http://stackoverflow.com/a/21574711
score: 1
tagged with: java
tagged with: timeout
has answer: http://stackoverflow.com/a/21574691
has answer: http://stackoverflow.com/a/21604724
type: Question
possible better answer: http://stackoverflow.com/a/21574691
downvote count: 0
has answer: http://stackoverflow.com/a/21574872
has answer: http://stackoverflow.com/a/21574718
favorite count: 0
has body: I'm having trouble with my java socket programm. I am opening a ServerSocket on host A. On host B, which is in the same private network, I try to bind to the server, but I always get a timeout. Host A | Server | IP: 192.168.56.1 Host B | Client | IP: 192.168.47.1 On the server host A:: welcomeSocket = new ServerSocket(2323); socket = welcomeSocket.accept(); After opening that serverSocket; on host B: socket = new Socket("192.168.56.1", 2323); Then after a few seconds, there is the Exception: java.net.ConnectException: Connection timed out: connect The socket does work well when I start the server on either host A or B and enter "localhost". What's wrong here? Thanks for your help.
answer count: 5
tagged with: sockets

http://stackoverflow.com/comment/32612897
type: QuestionComment
comment on: http://stackoverflow.com/q/21587797
has text: Rolling four 6-sided dice does not have the same distribution as rolling one 24-sided die. You need to roll the dice individually and sum them if you want to get the correct behavior.
score: 1
type: Comment

http://stackoverflow.com/a/21608962
has comment: http://stackoverflow.com/comment/32648589
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/21608328
accepted answer of: http://stackoverflow.com/q/21608328
type: AcceptedAnswer
has body: The problem seems to be you never remove the filter added to the row sorter when the check box is selected. This way the filter will be working regardless the check box status. You should be doing something like this: cEntertainment.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent e){ int state = e.getStateChange(); if (state == ItemEvent.SELECTED) { ... newFilter(cEntertainment.getText()); } else { ... removeFilter(); } } }); ... private void newFilter(String type) { RowFilter&lt;DefaultTableModel,Object&gt; rf = null; try{ rf = RowFilter.regexFilter(type); }catch(java.util.regex.PatternSyntaxException e){ return; } sorter.setRowFilter(rf); } private void removeFilter() { sorter.setRowFilter(null); } As per DefaultRowSorter.setRowFilter(RowFilter filter) javadoc (remarks are mine): Sets the filter that determines which rows, if any, should be hidden from the view. The filter is applied before sorting. A value of null indicates all values from the model should be included.
downvote count: 0

http://stackoverflow.com/comment/32796768
score: 0
type: Comment
has text: java.lang.StringIndexOutOfBoundsException: String index out of range: 4 -- is the error
type: AnswerComment
comment on: http://stackoverflow.com/a/21669242

http://stackoverflow.com/comment/32607193
type: Comment
has text: No error, no exception. Log shows nothing. Just the application shows a dialog saying it stoped and asking if i wanna close app or wait
score: 0
comment on: http://stackoverflow.com/q/21584587
type: QuestionComment

http://stackoverflow.com/comment/32544311
type: QuestionComment
has text: I've managed to solve this problem. The issue was that I didn't specify the correct username. Neither my password nor "Sebastian" (my name) were my real username for my youtube account.
type: Comment
comment on: http://stackoverflow.com/q/21528147
score: 0

http://stackoverflow.com/q/21530338
type: UnansweredQuestion
tagged with: owasp
has comment: http://stackoverflow.com/comment/32510181
score: 2
downvote count: 0
has title: How to check if the guard is working against CSRF attacks on my site?
tagged with: java
tagged with: web-applications
has body: I have this project I build with maven. I want to make sure the Cross-site request forgery guard (this link) is working on every page. After the mvn clean install, the web.xml, the pom.xml, the properties file and the csrfguard.jar is present in the correct way. How can I check if the guard is working and if it's not, what am I doing wrong? Thanks Added to pom.xml: org.owasp csrfguard Added to web.xml: CSRFGuard org.owasp.csrf.CSRFGuard error-page /page/error </filter> CSRFGuard /* Owasp.CsrfGuard.Config WEB-INF/Owasp.CsrfGuard.properties Owasp.CsrfGuard.Config.Print true org.owasp.csrfguard.CsrfGuardServletContextListener org.owasp.csrfguard.CsrfGuardHttpSessionListener -EDIT I checked for tokens in the request. No tokens were sent. What am I missing?
has comment: http://stackoverflow.com/comment/32510092
type: Question
has answer: http://stackoverflow.com/a/21530716
linked to: http://stackoverflow.com/q/6812765
tagged with: csrf
has comment: http://stackoverflow.com/comment/32509840
duplicate of: http://stackoverflow.com/q/6812765
upvote count: 2
answer count: 1
favorite count: 0

http://stackoverflow.com/comment/32630433
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21597955
has text: That's ok. But the final words are that the AWT-Windows thread interacts with the Windows operating system to know what event has occured and on which component it has occured and then pass it to the event dispatch thread? Am i right? Thanks.

http://stackoverflow.com/comment/32717389
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21642615
type: AnswerComment
has text: I can't change the global setting. I'm looking for a solution at the individual response level.

compiler-errors
tags question: http://stackoverflow.com/q/21542234
tag name: compiler-errors
tags question: http://stackoverflow.com/q/21618257
tags question: http://stackoverflow.com/q/21520509
type: Tag
tags question: http://stackoverflow.com/q/21632281
tags question: http://stackoverflow.com/q/21564191
tags question: http://stackoverflow.com/q/21593920
tags question: http://stackoverflow.com/q/21639856
tags question: http://stackoverflow.com/q/21536040
tags question: http://stackoverflow.com/q/21587202
tags question: http://stackoverflow.com/q/21609693
tags question: http://stackoverflow.com/q/21664727

http://stackoverflow.com/comment/32606334
has text: corrected result for tomcat on new jdbc driver
comment on: http://stackoverflow.com/q/21584266
score: 0
type: Comment
type: QuestionComment

authentication
tags question: http://stackoverflow.com/q/21629132
tags question: http://stackoverflow.com/q/21627506
tag name: authentication
tags question: http://stackoverflow.com/q/21637912
type: Tag
tags question: http://stackoverflow.com/q/21603477
tags question: http://stackoverflow.com/q/21646457
tags question: http://stackoverflow.com/q/21629153
tags question: http://stackoverflow.com/q/21536368
tags question: http://stackoverflow.com/q/21677518
tags question: http://stackoverflow.com/q/21607087

spring-mvc
tags question: http://stackoverflow.com/q/21675326
tags question: http://stackoverflow.com/q/21632996
tags question: http://stackoverflow.com/q/21601993
tags question: http://stackoverflow.com/q/21645350
tags question: http://stackoverflow.com/q/21525135
tags question: http://stackoverflow.com/q/21530290
tags question: http://stackoverflow.com/q/21675483
tags question: http://stackoverflow.com/q/21659393
tags question: http://stackoverflow.com/q/21538462
tags question: http://stackoverflow.com/q/21531860
tags question: http://stackoverflow.com/q/21558215
tags question: http://stackoverflow.com/q/21584563
tags question: http://stackoverflow.com/q/21542376
tags question: http://stackoverflow.com/q/21524205
tags question: http://stackoverflow.com/q/21571747
tags question: http://stackoverflow.com/q/21648710
tags question: http://stackoverflow.com/q/21673987
tags question: http://stackoverflow.com/q/21562773
tags question: http://stackoverflow.com/q/21675457
tags question: http://stackoverflow.com/q/21537636
tags question: http://stackoverflow.com/q/21632403
tags question: http://stackoverflow.com/q/21629926
tags question: http://stackoverflow.com/q/21623441
tags question: http://stackoverflow.com/q/21550238
tags question: http://stackoverflow.com/q/21567051
tags question: http://stackoverflow.com/q/21520106
tags question: http://stackoverflow.com/q/21622540
tags question: http://stackoverflow.com/q/21618563
tag name: spring-mvc
tags question: http://stackoverflow.com/q/21628036
tags question: http://stackoverflow.com/q/21655351
tags question: http://stackoverflow.com/q/21604443
tags question: http://stackoverflow.com/q/21591383
tags question: http://stackoverflow.com/q/21520840
tags question: http://stackoverflow.com/q/21611338
tags question: http://stackoverflow.com/q/21536833
tags question: http://stackoverflow.com/q/21593988
tags question: http://stackoverflow.com/q/21523266
tags question: http://stackoverflow.com/q/21621073
tags question: http://stackoverflow.com/q/21626781
tags question: http://stackoverflow.com/q/21598773
tags question: http://stackoverflow.com/q/21577782
type: Tag
tags question: http://stackoverflow.com/q/21547835
tags question: http://stackoverflow.com/q/21612706
tags question: http://stackoverflow.com/q/21552095
tags question: http://stackoverflow.com/q/21619661
tags question: http://stackoverflow.com/q/21625059
tags question: http://stackoverflow.com/q/21637838
tags question: http://stackoverflow.com/q/21540699
tags question: http://stackoverflow.com/q/21666392
tags question: http://stackoverflow.com/q/21635031
tags question: http://stackoverflow.com/q/21535072
tags question: http://stackoverflow.com/q/21538273
tags question: http://stackoverflow.com/q/21554075
tags question: http://stackoverflow.com/q/21614556
tags question: http://stackoverflow.com/q/21630363
tags question: http://stackoverflow.com/q/21627953
tags question: http://stackoverflow.com/q/21614093
tags question: http://stackoverflow.com/q/21554308
tags question: http://stackoverflow.com/q/21557578
tags question: http://stackoverflow.com/q/21565598
tags question: http://stackoverflow.com/q/21564572
tags question: http://stackoverflow.com/q/21587543
tags question: http://stackoverflow.com/q/21547453
tags question: http://stackoverflow.com/q/21579461
tags question: http://stackoverflow.com/q/21614681
tags question: http://stackoverflow.com/q/21660552
tags question: http://stackoverflow.com/q/21556387
tags question: http://stackoverflow.com/q/21592892
tags question: http://stackoverflow.com/q/21599986

http://stackoverflow.com/a/21567517
has body: You can't do that. Length2 IS A Length1, so you can always assign a Length2 object to a Length1 reference (you never have to cast it). You can also assign a Length1 reference that points to a Length2 object to another reference declared as Length2. In this case you need an explicit cast because the compiler doesn't know at compile time that the Length1 reference actually is a Length2. But what you are trying to do is not possible, since Length1 IS NOT A Length2. It's like saying that Car extends Vehicle. You can always point to a Car and say Car. Car c = new Car(); It's always OK. And you can always point to one and say Vehicle: Vehicle v = new Car(); No problem. The only problem you'll have here is if you decide to call, say, the printLicensePlate() method of Car which doesn't exist in Vehicle, which has a melhod called printSpeed(). Since a Car IS A `Vehicle, you can always call: c.printSpeed(); c.printLicensePlate(); and v.printSpeed(); But you can't call: v.printLicensePlate(); even though you know that v is a Car. This is the case where you use a cast, to convert the reference. This is illegal: c = v; // WRONG because the at compile time we don't know what's really in c, since new Car() only happens at runtime. So you tell the compiler "trust me, this is really a Car" by doing: c = (Car) v; But what you did was something like: Car c = new Vehicle(); // WRONG You pointed to a generic Vehicle and said Car. While a Car is always a Vehicle, a Vehicle may not be a car. (Using the c reference, the compiler believes you can legally call c.printLicensePlate(), but at runtime the object you find has no such method. So even if you could pass this by the compiler by casting the reference, it wouldn't work and would produce a ClassCastException at runtime.)
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/21567139
score: 1
downvote count: 0

http://stackoverflow.com/comment/32736331
comment on: http://stackoverflow.com/q/21658669
score: 0
type: Comment
type: QuestionComment
has text: Okay I will try the location fix stuff. Ok thanks a lot guys for your help! im new here, how can i recommend you guys??

http://stackoverflow.com/q/21615049
tagged with: java
accepted answer: http://stackoverflow.com/a/21618903
tagged with: quartz-scheduler
type: Question
has answer: http://stackoverflow.com/a/21618903
has body: I'm trying to get a clustered, Spring-managed Quartz environment going and I'm running into problems with the transaction features: 2014-02-06 13:59:00,015 ERROR org.quartz.core.ErrorLogger - Error executing Job (DEFAULT.idleDeviceJob: couldn't begin execution. org.quartz.SchedulerException: UserTransactionHelper could not lookup/create UserTransaction. [See nested exception: javax.naming.NamingException: Cannot create resource instance] at org.quartz.ee.jta.UserTransactionHelper$UserTransactionWithContext.<init>(UserTransactionHelper.java:148) at org.quartz.ee.jta.UserTransactionHelper.lookupUserTransaction(UserTransactionHelper.java:108) at org.quartz.ee.jta.JTAJobRunShell.begin(JTAJobRunShell.java:101) at org.quartz.core.JobRunShell.run(JobRunShell.java:164) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:560) Caused by: javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.TransactionFactory.getObjectInstance(TransactionFactory.java:116) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321) at org.apache.naming.NamingContext.lookup(NamingContext.java:843) at org.apache.naming.NamingContext.lookup(NamingContext.java:154) at org.apache.naming.NamingContext.lookup(NamingContext.java:831) at org.apache.naming.NamingContext.lookup(NamingContext.java:168) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158) at javax.naming.InitialContext.lookup(InitialContext.java:411) at org.quartz.ee.jta.UserTransactionHelper$UserTransactionWithContext.<init>(UserTransactionHelper.java:145) ... 4 more Obviously as I'm running in Tomcat, there is no JNDI registration for the UserTransaction. That said, I can't figure out how to get Quartz to use the existing transactions I've provided in my application context via AOP (or just ignore the transaction stuff as AOP handles it): <tx:advice id="quartzSchedulerAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="get*…
score: 0
answer count: 1
tagged with: tomcat
has title: Quartz cannot find transaction with Spring
tagged with: spring
type: AnsweredQuestion

http://stackoverflow.com/q/21566847
type: Question
answer count: 3
has answer: http://stackoverflow.com/a/21636976
has body: I have a requirement to check if the given windows service say "XYZService" is running fine. I understand that we can issue a "sc query " command and check the status of it, windows command prompt. but I don't know how to do in java. I am using JDK1.6 in my application. appreciate any help.
possible better answer: http://stackoverflow.com/a/21566951
has answer: http://stackoverflow.com/a/21566951
accepted answer: http://stackoverflow.com/a/21636976
score: 0
has title: how to check particular windows service is running using
tagged with: java
has answer: http://stackoverflow.com/a/75821997
type: AnsweredQuestion

http://stackoverflow.com/comment/32618358
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21578892
score: 1
has text: Erm ... I recall having problems with compilation dependencies due to the Eclipse plugin adding stuff to the build path that was not warranted by the dependencies in the POM. Workaround - do a command-line 'mvn' build regularly. Sigh.

http://stackoverflow.com/comment/32664971
score: 0
type: AnswerComment
type: Comment
has text: Why do I need to use two loops? I can get the same result with just one loop.
comment on: http://stackoverflow.com/a/21617730

http://stackoverflow.com/a/21629418
has comment: http://stackoverflow.com/comment/32684336
upvote count: 5
downvote count: 0
answers question: http://stackoverflow.com/q/21629323
score: 5
type: Answer
has body: You can declare it final and still use a static initialiser: private static final int[] array; static { array = {...}; Arrays.sort(array); }

http://stackoverflow.com/q/21608291
has comment: http://stackoverflow.com/comment/32647644
type: Question
answer count: 2
tagged with: swing
has title: JTree - cannot be cast to javax.swing.tree.MutableTreeNode
has answer: http://stackoverflow.com/a/21608733
score: 0
tagged with: java
tagged with: jtree
has answer: http://stackoverflow.com/a/21608502
type: UnansweredQuestion
tagged with: awt
has body: I'm very new to Java GUI making and am trying to attempt it here. Basically I have another class that reads data from an excel sheet about an automated test pack. What I would like to do is add in those tests into this resource tree. However when I try to use addTest(new testInfo ("TESTING", "TESTING MESSAGE")); It seems to complain. My code: package com.main; import java.awt.Dimension; import java.awt.GridLayout; import java.io.IOException; import java.net.URL; import java.util.ArrayList; import java.util.List; import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTree; import javax.swing.UIManager; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.MutableTreeNode; import javax.swing.tree.TreeSelectionModel; public class ExcelReaderGui extends JPanel implements TreeSelectionListener { /** * */ private static final long serialVersionUID = 1L; private JEditorPane htmlPane; private JTree tree; private URL helpURL; private static boolean DEBUG = false; private static ReadExcel re = new ReadExcel(); private List&lt;testInfo&gt; testsToAdd = new ArrayList&lt;testInfo&gt;();; //Optionally play with line styles. Possible values are //"Angled" (the default), "Horizontal", and "None". private static boolean playWithLineStyle = false; private static String lineStyle = "Horizontal"; //Optionally set the look and feel. private static boolean useSystemLookAndFeel = false; public ExcelReaderGui() { super(new GridLayout(1,0)); //Create the nodes. addTest(new testInfo ("TESTING", "TESTING MESSAGE")); DefaultMutableTreeNode top = new DefaultMutableTreeNode("Automated tests"); createNodes(top); //Create a tree that allows one selection at a time. tree = new JTree(top); tree.getSelectionModel().setSelectionMode (TreeSelectionModel.SINGLE_TREE_SELECTION); //Li…

http://stackoverflow.com/comment/32743867
score: 3
comment on: http://stackoverflow.com/q/21663225
has text: Can We get the stacktrace?
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21641846
score: 0
answers question: http://stackoverflow.com/q/21641800
has body: Here's the basic answer, in pseudocode: recursive_stutter(s:string){ if length of s is 0 return letter = s[0] // save the first character recursive_stutter(s from 1 to length) printf "%c%c%c",letter, letter, letter }
type: Answer

http://stackoverflow.com/a/21548670
answers question: http://stackoverflow.com/q/21548534
downvote count: 0
type: Answer
has body: You can use the positive lookbehinds and lookaheads: String b = a.replaceAll("(?&lt;=[0-9]+)(?=[a-z]+)", "*"); Translation from Regex into English: insert * at any position in the string that is preceded by the digits and followed by the letters.
upvote count: 1
score: 1

http://stackoverflow.com/comment/60920862
type: Comment
comment on: http://stackoverflow.com/a/22091085
score: 0
type: AnswerComment
has text: I still get this issue, exactly same error. My dependencies are: xjc 'com.sun.xml.bind:jaxb-xjc:2.2.7-b41' xjc 'com.sun.xml.bind:jaxb-impl:2.2.7-b41' xjc 'javax.xml.bind:jaxb-api:2.2.7' - The strange thing is that even though I get the error message, the xsd is generated

http://stackoverflow.com/q/21637169
has comment: http://stackoverflow.com/comment/32698590
tagged with: java
upvote count: 1
has title: Getting subclass
downvote count: 1
has body: That's my short Example. SuperClass: public abstract class SuperClass { public SubClass getSubClass() { return null; } } SubClass extending SuperClass: public class SubClass extends SuperClass { public SubClass getSubClass() { return this; } public static void doSomething(SuperClass instance) { if(instance instanceof SubClass) { //Option 1: SubClass example1 = instance.getSubClass(); //Option 2: SubClass example2 = (SubClass)instance; } } } My Question is, what's the best(and without any warnings) way to get SubClass? In option 1, i will get 2 warnings(1. in SuperClass#getSubClass that Class references Subclass, 2. in SubClass#getSubClass that it ignores method in SuperClass). In option 2, i will get 1 warning(Casting to concrete Class) and i believe that option is slower too. Is there any other way to achieve what i want? Which option is the best?
type: Question
has comment: http://stackoverflow.com/comment/32698652
tagged with: casting
has comment: http://stackoverflow.com/comment/32698676
has answer: http://stackoverflow.com/a/21637255
has comment: http://stackoverflow.com/comment/32698674
has comment: http://stackoverflow.com/comment/32699062
score: 0
has comment: http://stackoverflow.com/comment/32698923
answer count: 1
favorite count: 0
tagged with: subclass
type: UnansweredQuestion
tagged with: superclass
has comment: http://stackoverflow.com/comment/32698659
tagged with: oop

http://stackoverflow.com/a/21713344
score: 3
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/33081063
upvote count: 3
answers question: http://stackoverflow.com/q/21534340
has body: DOM Parser through Recursion Using a DOM parser, you can easily get into a mess of nested for loops as you've already pointed out. Nevertheless, DOM structure is represented by Node containing child nodes collection in the form of a NodeList where each element is again a Node - this becomes a perfect candidate for recursion. Sample XML To showcase the ability of DOM parser discounting the size of the XML, I took the example of a hosted sample OpenWeatherMap XML. Searching by city name in XML format This XML contains London's weather forecast for every 3 hour duration. This XML makes a good case of reading through a relatively large data set and extracting specific information through attributes within the child elements. In the snapshot, we are targeting to gather the Elements marked by the arrows. The Code We start of by creating a Custom class to hold temperature and clouds values. We would also override toString() of this custom class to conveniently print our records. ForeCast.java public class ForeCast { /** * Overridden toString() to conveniently print the results */ @Override public String toString() { return "The minimum temperature is: " + getTemperature() + " and the weather overall: " + getClouds(); } public String getTemperature() { return temperature; } public void setTemperature(String temperature) { this.temperature = temperature; } public String getClouds() { return clouds; } public void setClouds(String clouds) { this.clouds = clouds; } private String temperature; private String clouds; } Now to the main class. In the main class where we perform our recursion, we want to create a List of ForeCast objects which store individual temperature and clouds records by traversing the entire XML. // List collection which is would hold all the data parsed through the XML // in the format defined by the custom type 'ForeCast' private static List&lt;ForeCast&gt; forecastList = new ArrayList&lt;&gt;(); In the XML the parent to both temperature and clouds elements…

http://stackoverflow.com/q/21663734
has body: We are trying to configure a websphere cluster of 8 nodes and deploy an app. Is there any way to identify which server the request was processed by without looking at the application logs. In tomcat, if jvmroute in set, based on the value of JSESSIONID from http trace, the server can be identified. Need something similar for websphere application server. Using was8.5 and apache 2.2.3 worker.
tagged with: websphere
has answer: http://stackoverflow.com/a/21666813
has title: websphere in cluster - how to know which node the request was served by?
score: 0
answer count: 1
accepted answer: http://stackoverflow.com/a/21666813
type: AnsweredQuestion
tagged with: java
type: Question

http://stackoverflow.com/q/21625051
has answer: http://stackoverflow.com/a/50787768
has comment: http://stackoverflow.com/comment/32679129
tagged with: image
upvote count: 2
has title: store image into a folder in netbeans
answer count: 2
tagged with: netbeans-7
favorite count: 0
accepted answer: http://stackoverflow.com/a/21627185
possible better answer: http://stackoverflow.com/a/50787768
has body: I am using a FileChooser for selectiong image from the system.Now I want to store the image into db.For this I have created a new folder image in the project,and my idea is load the folder with the opened images renamed like img1,img2...and store this path into the db, at a time one image. I used the code below for getting the image name String name = jFileChooser1.getSelectedFile().getAbsolutePath(); But I dont know how to store the image into the folder.Hope anyone will help to solve this.
has answer: http://stackoverflow.com/a/21627185
type: AnsweredQuestion
score: 2
downvote count: 0
tagged with: java
tagged with: swing
tagged with: oracle10g
type: Question

http://stackoverflow.com/comment/129289325
type: AnswerComment
comment on: http://stackoverflow.com/a/70953671
type: Comment
score: 1
has text: Me, too, but there's a workaround: Instead of @Autowiring , you can dynamically resolve the bean if you Autowired the BeanFactory: ```private AuthenticationManager getAuthenticationManager() { if (this.authenticationManager == null) { this.authenticationManager = beanFactory.getBean(BeanIds.AUTHENTICATION_MANAGER, AuthenticationManager.class); } return this.authenticationManager; } ```

http://stackoverflow.com/q/21649396
tagged with: php
tagged with: java
tagged with: java-bridge-method
tagged with: php-java-bridge
has comment: http://stackoverflow.com/comment/32720277
type: UnansweredQuestion
type: Question
has comment: http://stackoverflow.com/comment/32720336
has comment: http://stackoverflow.com/comment/32736925
has body: I am working on a code which requires java at the back-end and php at the front end to enable users print tickets/receipt from a printer. So far, my PhP JavaBridge code is working perfectly on my xmapp/tomcat intranet server. But when i upload this code to my domain hosted by godaddy, it shows nothing. Is there a special configuration i need to do to run JavaBridge on godaddy or on a remote server?
has title: Running PhP JavaBridge on my website hosted by godaddy
answer count: 0
score: 0

http://stackoverflow.com/comment/32497670
type: Comment
type: QuestionComment
has text: but you won't see the button text change unless you add it to the activity
comment on: http://stackoverflow.com/q/21523192
score: 0

http://stackoverflow.com/a/21541603
answers question: http://stackoverflow.com/q/21541559
has comment: http://stackoverflow.com/comment/32530768
has body: The "expense" is because of it reading from memory every time, instead of possibly using the memory caches. It is not a lot, at least on x86 machines.
has comment: http://stackoverflow.com/comment/32530868
has comment: http://stackoverflow.com/comment/32530982
has comment: http://stackoverflow.com/comment/32530749
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/32530672
has comment: http://stackoverflow.com/comment/32530632
upvote count: 1
type: Answer

http://stackoverflow.com/a/21587129
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/21587066
downvote count: 0
has body: You are calling static method which can be called by the Class so remove the new keyword and update the code as below : CowSingleton cowSingleton = CowSingleton.getInstance();
type: Answer

http://stackoverflow.com/comment/32606538
type: QuestionComment
has text: Why don't you try? What makes you think we can't?
type: Comment
score: 1
comment on: http://stackoverflow.com/q/21584581

http://stackoverflow.com/comment/32507306
type: Comment
type: AnswerComment
has text: The title says `Adding ArrayList into Another ArrayList`, so we are talking about `ArrayLists` here. Now please have a look at the docs: http://developer.android.com/reference/java/util/ArrayList.html#clone()... And please remove your downvote.
comment on: http://stackoverflow.com/a/21528529
score: 0

http://stackoverflow.com/comment/32633770
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21600344
score: 3
has text: Either the key has been modified or your implementation of `equals()/hashcode` is wrong.

http://stackoverflow.com/q/21677743
has comment: http://stackoverflow.com/comment/32769712
has title: Multi-Threading Server with shared Resource
type: AnsweredQuestion
tagged with: java
tagged with: concurrency
type: Question
accepted answer: http://stackoverflow.com/a/21678037
answer count: 1
has comment: http://stackoverflow.com/comment/32769121
score: 0
tagged with: multithreading
has body: I'm trying to make a simple game in Java. I want to code a server that accepts multiple players. Here is the meta of the game: A player connects to the server to play a game, and indicate a number. Each player plays one game only. The game only starts or resolve if 4 players get connected. If the sum of all players number is greater than 21 all lose, else, all win. After the game resolves each player must be warned if it won or lost. The algorithms for the win/lose check, or accept multiple clients I get it. My doubt is what should be a thread (or a runnable object) and/or what is a shared resource. Just a few guide lines and so I can implement this.
has answer: http://stackoverflow.com/a/21678037
has comment: http://stackoverflow.com/comment/32769485

http://stackoverflow.com/q/21618919
accepted answer: http://stackoverflow.com/a/21628298
type: AnsweredQuestion
has body: This is my very first JMH benchmark. I might be doing everything wrong, but.... My benchmark looks like this @State(Scope.Benchmark) public class JmhBranchingBenchmark { private static final int STRING_LENGTH = 100 * 1000; private char[][] allQueries = new char[101][]; @Setup public void up() { for (int i=0; i&lt;allQueries.length; ++i) { ... fill char[i] with STRING_LENGTH chars ... this might take some time, but it's needed only once, or? } } @GenerateMicroBenchmark public void measure5(BlackHole bh) { bh.consume(countBreakingWhitespace(allQueries[5])); } ... some more nearly identical methods as a poor man's replacement for caliper's @Param } I started it... and waited and waited and then killed it. I suspected a problem in the @Setup, so I simplified it, but nothing changed. The run starts pretty optimistically... time -p java -jar target/microbenchmarks.jar ".*JmhBranchingBenchmark.*" -i 5 -f 1 # Run progress: 0.00% complete, ETA 00:02:05 # VM invoker: /usr/lib/jvm/java-7-oracle/jre/bin/java # VM options: &lt;none&gt; # Fork: 1 of 1 # Warmup: 20 iterations, 1 s each # Measurement: 5 iterations, 1 s each # Threads: 1 thread, will synchronize iterations # Benchmark mode: Throughput, ops/time # Benchmark: org.openjdk.jmh.samples.JmhBranchingBenchmark.measure10 # Warmup Iteration 1: and then nothing happens. After a long time, it continues and write 20 lines like # Warmup Iteration 1: 6.415 ops/ms and 5 lines like Iteration 1: 6.506 ops/ms Then it outputs some results Result : 6.510 ±(99.9%) 0.030 ops/ms Statistics: (min, avg, max) = (6.502, 6.510, 6.521), stdev = 0.008 Confidence interval (99.9%): [6.480, 6.540] and corrects its estimated eta: # Run progress: 20.00% complete, ETA 00:26:52 Does my @Setup get invoked much more often than I though or what else can be the reason for the slowness?
score: 1
tagged with: java
has title: What does JMH when it does nothing?
type: Question
tagged with: benchmarking
downvote count: 0
tagged with: jmh
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/21628298
upvote count: 1

http://stackoverflow.com/a/21531630
downvote count: 0
score: 7
has comment: http://stackoverflow.com/comment/32512742
has comment: http://stackoverflow.com/comment/32513110
answers question: http://stackoverflow.com/q/21531531
upvote count: 7
has body: Consider using a list to hold the values: List&lt;String[]&gt; countries = new ArrayList&lt;&gt;(); try { while ((line = br.readLine()) != null) { countries.add(line.split(cvsSplitBy)); } } Later you can iterate over this list: for (String[] country : countries) { System.out.println(Arrays.toString(country); // or whatever }
type: Answer

http://stackoverflow.com/comment/32670544
has text: When I use console.bat connection is successful but I always confuse this damn slashes. But anyway I sure that connection work until it reaches `db.open("admin", "admin");`
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21620622

remote-debugging
tag name: remote-debugging
type: Tag
tags question: http://stackoverflow.com/q/21634490

http://stackoverflow.com/comment/32599180
type: AnswerComment
comment on: http://stackoverflow.com/a/21580052
type: Comment
has text: What is ContextHolder is your example ?
score: 0

gwt
tags question: http://stackoverflow.com/q/21526544
tag name: gwt
tags question: http://stackoverflow.com/q/21608891
tags question: http://stackoverflow.com/q/21556067
tags question: http://stackoverflow.com/q/21609774
tags question: http://stackoverflow.com/q/21601897
type: Tag
tags question: http://stackoverflow.com/q/21591252
tags question: http://stackoverflow.com/q/21595046
tags question: http://stackoverflow.com/q/21617963
tags question: http://stackoverflow.com/q/21517482
tags question: http://stackoverflow.com/q/21534002
tags question: http://stackoverflow.com/q/21537793
tags question: http://stackoverflow.com/q/21581198
tags question: http://stackoverflow.com/q/21519271
tags question: http://stackoverflow.com/q/21558045
tags question: http://stackoverflow.com/q/21599762
tags question: http://stackoverflow.com/q/21535319
tags question: http://stackoverflow.com/q/21641552
tags question: http://stackoverflow.com/q/21601321
tags question: http://stackoverflow.com/q/21641208
tags question: http://stackoverflow.com/q/21610810
tags question: http://stackoverflow.com/q/21514447
tags question: http://stackoverflow.com/q/21626916
tags question: http://stackoverflow.com/q/21677614
tags question: http://stackoverflow.com/q/21577522
tags question: http://stackoverflow.com/q/21597274
tags question: http://stackoverflow.com/q/21545766
tags question: http://stackoverflow.com/q/21673017
tags question: http://stackoverflow.com/q/21576404
tags question: http://stackoverflow.com/q/21589322
tags question: http://stackoverflow.com/q/21649392
tags question: http://stackoverflow.com/q/21577990
tags question: http://stackoverflow.com/q/21628304
tags question: http://stackoverflow.com/q/21532776
tags question: http://stackoverflow.com/q/21545836
tags question: http://stackoverflow.com/q/21655800
tags question: http://stackoverflow.com/q/21613856
tags question: http://stackoverflow.com/q/21607469

http://stackoverflow.com/a/21676577
answers question: http://stackoverflow.com/q/21676518
type: Answer
score: 2
has body: double test = (21757952*100)/63290718; values in 21757952,100, 63290718 should use as double. Currently they are int values. You can try as follows. double test = (21757952.0*100.0)/63290718.0; System.out.println(test);
downvote count: 0
upvote count: 2

http://stackoverflow.com/comment/32746078
comment on: http://stackoverflow.com/q/21664300
type: Comment
type: QuestionComment
has text: Also a third question: http://stackoverflow.com/questions/21380499/is-this-declaration-possible/21380590
score: 0

http://stackoverflow.com/comment/32708694
score: 0
type: Comment
has text: Take a look at [this anonymous class question on SO](http://stackoverflow.com/questions/355167/how-are-anonymous-inner-classes-used-in-java). It helped me a lot.
type: QuestionComment
comment on: http://stackoverflow.com/q/21642956

http://stackoverflow.com/comment/32554041
comment on: http://stackoverflow.com/a/21555602
type: AnswerComment
score: 0
type: Comment
has text: didn't even see that in the code! shouldn't be there at all.

http://stackoverflow.com/a/21534193
has body: You never added any toppings to your pizza, Pizza newPizza = new Pizza(brand, size); // Keep adding toppings, check for empty string to end? while ((topping = getTopping()).length() &gt; 0) { newPizza.addTopping(topping); // &lt;-- add the topping to the pizza. } System.out.println(newPizza.getPizzaInfo()); You also need to fix your method addTopping public void addTopping(String topping) { // toppings.add("topping"); toppings.add(topping); }
score: 0
answers question: http://stackoverflow.com/q/21534091
type: Answer

http://stackoverflow.com/comment/32698609
type: Comment
has text: So how you store CategoryId in this hash map, and why you use hash map?
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21637067

http://stackoverflow.com/comment/32561716
type: QuestionComment
comment on: http://stackoverflow.com/q/21559607
has text: @KevinWorkman While this may be true that premature optimization is evil... Have you seen the posted code? This is better even just for clarity, which is much more important than the optimization
score: 0
type: Comment

http://stackoverflow.com/comment/32635934
score: 0
type: Comment
type: QuestionComment
has text: I assume that because seeing as it was outputted by a webpage it seems lightly, evidently I was wrong. And no text file, I have a script that fetches the linked url and returns it as a string.
comment on: http://stackoverflow.com/q/21601652

http://stackoverflow.com/comment/32751516
type: AnswerComment
score: 0
type: Comment
has text: Why? What do you have against `String`?
comment on: http://stackoverflow.com/a/21667396

http://stackoverflow.com/q/21527016
tagged with: couchdb
favorite count: 0
has body: Having a limited knowledge of Spring, I'm wondering how easy it would be to switch from MongoDB to CouchDB or vice-versa. At present I see benefits in both systems, and was thinking to simply test both. Can someone help explain the steps involved and what aspects would need to be recoded? I know with JPA / Hibernate, switching databases is easy, but I don't know if this is the case with MongoDb and CouchDb. Thanks in advance
tagged with: spring
has comment: http://stackoverflow.com/comment/36072500
has comment: http://stackoverflow.com/comment/32813952
score: 2
upvote count: 2
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32506097
has answer: http://stackoverflow.com/a/63764996
tagged with: java
type: Question
tagged with: mongodb
has title: Spring - Switching from MongoDB to CouchDB and vice-versa
tagged with: database-migration
answer count: 1
downvote count: 0

http://stackoverflow.com/comment/32660772
type: Comment
comment on: http://stackoverflow.com/q/21615307
has text: Added the console output
score: 0
type: QuestionComment

http://stackoverflow.com/comment/32652687
type: Comment
score: 2
has text: @Qiu Still not a good reason to downvote. OP clearly shows effort in the problem.
comment on: http://stackoverflow.com/q/21610834
type: QuestionComment

http://stackoverflow.com/comment/32760807
type: Comment
comment on: http://stackoverflow.com/a/21673087
has text: @Oli: True, I changed it to your wording.
type: AnswerComment
score: 0

http://stackoverflow.com/q/21537148
answer count: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/32522911
favorite count: 0
tagged with: idioms
has comment: http://stackoverflow.com/comment/32522746
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21537270
linked to: http://stackoverflow.com/q/1321745
has body: I've read this and this, but I still don't understand the (idiomatic) equivalent way to do this in Scala enum Status { OK(1, "Ok", "Okay"), NOT_OK(5, "Not Ok", "Not Okay") BAD(10, "Bad", "Run for your life") int code; String name; String description; // custom fields Status(int code, String name, String description) { this.code = code; this.name = name; this.description = description; } } class Main { public static void main(String[] args) { for(Status status : Status.values) { // iterate through them doStuff(status); } } private doStuff(Status status) { System.out.println(status.description); // and more } }
has title: Scala/Java enumerations
tagged with: scala
type: Question
tagged with: enums
linked to: http://stackoverflow.com/q/1898932
has answer: http://stackoverflow.com/a/21538664
linked to: http://stackoverflow.com/q/13671734
has comment: http://stackoverflow.com/comment/32522769
tagged with: java
score: 4
has answer: http://stackoverflow.com/a/21544551
upvote count: 4

http://stackoverflow.com/comment/32622004
score: 0
type: Comment
has text: I mean Point field appearing on main method because of returned link. But I declare it private in order to avoid a possibility to do p.setX(1) in other classes (and the same to other methods). May be it isn't a good solution
comment on: http://stackoverflow.com/a/21586777
type: AnswerComment

http://stackoverflow.com/q/21529874
score: 1
tagged with: java
tagged with: eclipse
type: Question
has answer: http://stackoverflow.com/a/21559324
answer count: 2
tagged with: intellij-idea
has title: How to add java project dependency to play framework 2.2.1 java project
has answer: http://stackoverflow.com/a/21554052
has body: I have a couple of java projects (Abc.Domain, Abc.Framework etc) and I have recently created a new playframework 2.2.1 java project (Abc.Rest.Api). I am using Eclipse as the IDE (also tried this in IntellijIdea). The hierarchy of my code base looks like as below /POC (Empty project) /Abc.Domain (Java project/module) /Abc.Framework (Java project/module) /Abc.Rest.Api (play2 for java project/module) I would like to access the classes and services of Abc.Domain and Abc.Framework in Abc.Rest.Api. I have tried this by adding Abc.Domain and Abc.Framework projects in Abc.Rest.Api Java Build Path in Eclipse. The project builds fine and I can access all the classes of Abc.Domain and Abc.Framework in Abc.Rest.Api, however when I run or Debug the Abc.Rest.Api the sbt of playframwork is not able to find those classes and relevant imports, resulting in runtime exceptions. I googled about this problem and the solutions that I found are Publishing Abc.Domain and Abc.Framework to maven or ivy repositories and adding them in sbt as follows libraryDependencies ++= Seq( "org.apache.derby" % "derby" % "10.4.1.3", "org.hibernate" % "hibernate-entitymanager" % "3.6.9.Final" ) create a lib/ directory in the root of your project and then add jar files to that directory. They will automatically be added to theenter code here application classpath By doing either of the above I no longer will have the capability to do realtime debugging and source code navigation to the classes and services of Abc.Domain and Abc.Framework. I also tried this in IntellijIdea, ironically in IntellijIdea you can not add java modules as dependencies to playframework java module directly. Please can anyone guide me in the right direction to add java projects as dependencies to my playframework java project without loosing debugging and source code navigation of java projects either by using Eclipse of IntellijIdea
upvote count: 1
favorite count: 0
tagged with: playframework-2.2
type: UnansweredQuestion
downvote count: 0

image-processing
tags question: http://stackoverflow.com/q/21555526
tags question: http://stackoverflow.com/q/21618044
tags question: http://stackoverflow.com/q/21552634
tags question: http://stackoverflow.com/q/21575358
tags question: http://stackoverflow.com/q/21528925
type: Tag
tags question: http://stackoverflow.com/q/21666053
tag name: image-processing
tags question: http://stackoverflow.com/q/21561542
tags question: http://stackoverflow.com/q/21620148

http://stackoverflow.com/comment/32626185
type: Comment
has text: You're talking about 3 if statements but in code above I see only 2 if statements. Code which you're showing doesn't have so big cyclomatic complexity. You're doing something wrong. Maybe you're looking at wrong method somehow if changes in code make no diffrence in cyclomatic complexity. Double check everything what is needed.
comment on: http://stackoverflow.com/a/21581540
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32979836
type: Comment
comment on: http://stackoverflow.com/a/21731002
has text: I added an example how you could directly add your Game as a ComponentListener. In your case you should also create an LwjglApplicationConfiguration and use it as an argument when creating the LwjglFrame. Something like this: `LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration(); cfg.useGL20=true; cfg.width=800; cfg.height=600; cfg.title = "Game";`
score: 1
type: AnswerComment

http://stackoverflow.com/a/21671510
upvote count: 3
answers question: http://stackoverflow.com/q/21665270
has body: You should provide an correct target Id. To get the List of target ID's cd to the tools directory in your android sdk. Execute android list target command All the available Id's in your android sdk will be listed down. Use any one of the listed target ID. NOTE: UiAutomator works only on devices supporting API level 16 and above.Therefore, select a target ID which corresponds to "android-16" or above
downvote count: 0
type: Answer
score: 3

http://stackoverflow.com/comment/32707718
comment on: http://stackoverflow.com/q/21642367
has text: Consider refactor this code, nested "if" or "for" statements is a bad practice and is difficult to read
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21634467
has title: Camera takePicture returns java.lang.NullPointerException?
favorite count: 0
type: UnansweredQuestion
tagged with: android
has comment: http://stackoverflow.com/comment/32710591
has comment: http://stackoverflow.com/comment/32695716
score: 2
answer count: 0
downvote count: 0
type: Question
has comment: http://stackoverflow.com/comment/32695635
tagged with: camera
tagged with: java
upvote count: 2
has body: I wrote code to capture image automatically at background. For this, I made a thread and taking picture in that. My code looks like package com.camsharp; import java.io.File; import java.io.FileOutputStream; import java.util.Timer; import java.util.TimerTask; import android.app.Activity; import android.content.Context; import android.hardware.Camera; import android.os.Build; import android.os.Bundle; import android.util.Log; import android.widget.FrameLayout; import android.widget.Toast; public class MainActivity extends Activity { private int cameraId = 0; private Camera mCamera; private CameraPreview mPreview; String fileName = "tempImage.jpeg"; File file; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d("EXEC ", "EXECUTED "); setContentView(R.layout.activity_main); // Create an instance of Camera mCamera = getCameraInstance(cameraId); if (mCamera == null) { Toast.makeText( getApplicationContext(), "The camera service is currently unavailable, please try again!", Toast.LENGTH_LONG).show(); finish(); } else { // Create our Preview view and set it as the content of our // activity. mPreview = new CameraPreview(this, mCamera); FrameLayout frameLayout = (FrameLayout) findViewById(R.id.camera_preview); frameLayout.addView(mPreview); } // start thread for these MyTimerTask myTask = new MyTimerTask(); Timer myTimer = new Timer(); // public void schedule (TimerTask task, long delay, long period) // Schedule a task for repeated fixed-delay execution after a specific // delay. // // Parameters // task the task to schedule. // delay amount of time in milliseconds before first execution. // period amount of time in milliseconds between subsequent executions. myTimer.schedule(myTask, 3000, 1500); } class MyTimerTask extends TimerTask { public void run() { try { Log.e("SUCCESS ", "IT IS OKAY "); //mCamera.takePicture(null, null, null, mPictureCallback); mCamera.takePicture(null, null, mPictureCallback); file = new File(get…

http://stackoverflow.com/a/21613593
upvote count: 2
score: 2
has comment: http://stackoverflow.com/comment/32657768
has body: Casting is solely for the benefit of the compiler. The JVM doesn't know anything about it, and it does not affect what method gets called. The JVM tries to resolve a method by looking for something that matches the given signature, starting with the most specific class and working its way up the hierarchy towards the root (java.lang.Object) until it finds something. The purpose of polymorphism is so code calling some object doesn't have to know exactly what subclass is being used, the object being called takes care of its own specialized functionality. Having a subclass override a method means that objects of that subclass need to handle that method in their own particular way, and the caller doesn't have to care about it. Casting is for odd edge cases where your code can't know what type something is. You shouldn't need to cast if you know the super type (Parent in your example), the subclass should take care of itself.
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/21613540
accepted answer of: http://stackoverflow.com/q/21613540
has comment: http://stackoverflow.com/comment/32657473
type: Answer

http://stackoverflow.com/comment/32658977
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21614474
has text: Do you want every string to *always* be in a different position, or just random? There's a difference.
score: 0

http://stackoverflow.com/comment/32523569
has text: I tried that (target.add(myComponent); ) but still didn't work. Thanks for replying anyway.
type: Comment
comment on: http://stackoverflow.com/a/21530645
type: AnswerComment
score: 0

http://stackoverflow.com/a/21611969
has comment: http://stackoverflow.com/comment/32654358
type: Answer
has body: Map1 is sort of a queue Use a Blocking Queue which is a FIFO data structure.
has comment: http://stackoverflow.com/comment/32654624
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/32657343
accepted answer of: http://stackoverflow.com/q/21611916
has comment: http://stackoverflow.com/comment/32656841
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21611916
downvote count: 0

http://stackoverflow.com/comment/32536064
type: AnswerComment
comment on: http://stackoverflow.com/a/21545263
score: 0
type: Comment
has text: It almost worked..But the problem is i have 9 options(in the question i have shown only 3),and if only 3 are filled,the rest of the 6 show null values when I display.Is there a way I can add the number of options i want?

http://stackoverflow.com/q/21622911
tagged with: hashset
tagged with: data-structures
favorite count: 0
has answer: http://stackoverflow.com/a/21623280
type: Question
accepted answer: http://stackoverflow.com/a/21623280
linked to: http://stackoverflow.com/q/559839
upvote count: 3
answer count: 2
tagged with: performance
tagged with: algorithm
has title: (Java) data structure for fast insertion, deletion, and RANDOM SELECTION
possible better answer: http://stackoverflow.com/a/21623269
tagged with: java
has answer: http://stackoverflow.com/a/21623269
has body: I need a data structure that supports the following operations in O(1): myList.add(Item) myList.remove(Item.ID) ==> It actually requires random access myList.getRandomElement() (with equal probability) --(Please note that getRandomElement() does not mean random access, it just means: "Give me one of the items at random, with equal probability") Note that my items are unique, so I don't care if a List or Set is used. I checked some java data structures, but it seems that none of them is the solution: HashSet supports 1,2 in O(1), but it cannot give me a random element in O(1). I need to call mySet.iterator().next() to select a random element, which takes O(n). ArrayList does 1,3 in O(1), but it needs to do a linear search to find the element I want to delete, though it takes O(n) Any suggestions? Please tell me which functions should I call? If java does not have such data structure, which algorithm should I use for such purpose?
type: AnsweredQuestion
score: 3
downvote count: 0

http://stackoverflow.com/a/21676977
answers question: http://stackoverflow.com/q/21675709
score: 2
downvote count: 0
type: Answer
has body: Try JProfiler, there's at least a free trial. One of the memory views tells you which classes have the most instances created (and how many). You can also use memory recording; start recording, set a "mark", run an operation you think creates garbage, stop recording, see which classes have the most instances created since the "mark" was set. Basically, you need a good profiler, doesn't matter much which one. Typically the commercial ones are better, in my experience. UPDATE: a good profiler will tell you exactly how many instances of a class exist. This sounds like what you are asking for.
upvote count: 2
has comment: http://stackoverflow.com/comment/32768816

http://stackoverflow.com/comment/32725444
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21652601
score: 1
has text: @Jonathan Your code as it is allows `T` to be anything, a File for example. Multiplying a File by a number does not make sense. So you need to place more constraints on what `T` can be.

java-2d
tags question: http://stackoverflow.com/q/21568361
tags question: http://stackoverflow.com/q/21533083
tags question: http://stackoverflow.com/q/21633623
tags question: http://stackoverflow.com/q/21545615
tag name: java-2d
type: Tag

http://stackoverflow.com/q/21662644
tagged with: radio-button
answer count: 1
tagged with: jsp
linked to: http://stackoverflow.com/q/13835913
tagged with: dynamic
type: UnansweredQuestion
tagged with: java
has body: i have a page in jsp where i am dynamically displaying records from the database in a table, with dynamic rows being generated. With every row, there is a radio button so that the user can select one row. The code for page1.jsp is: <% try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:/Users/hp/Documents/Sample1.accdb"; Connection con = DriverManager.getConnection(database, "", ""); Statement stmnt = con.createStatement(); String source=request.getParameter("from"); String dest=request.getParameter("to") ResultSet resultset = stmnt.executeQuery("select * from Trains123 where From='" +source+ "' and To='" +dest+ "' "); while(resultset.next()) { %> <% out.println(resultset.getString("From")); %> <% out.println(resultset.getString("To")); %> <% out.println(resultset.getString("TrainName")); %> <input type="radio" name="TName" value="<%= resultset.getString("TrainName")%>">book and the code on page2.jsp is: <% out.println(request.getParameter("Tname")); %> There is no problem with the record set, the values are getting printed. but the radio button is not being displayed.Also, If there are 2 records in the recordset, only the first one gets printed without the radio button. I debugged the file, the control stops at the radio button line. I have no idea, where the error is and what is the problem with giving dynamic value to the radio button. All i want to do is to find out the row selected by the user.
type: Question
has title: get value of selected dynamic row of table in jsp
has answer: http://stackoverflow.com/a/21663123
score: 0

http://stackoverflow.com/q/21627970
tagged with: layout-manager
score: 0
has comment: http://stackoverflow.com/comment/32681733
answer count: 0
type: UnansweredQuestion
tagged with: swing
has comment: http://stackoverflow.com/comment/32682155
has comment: http://stackoverflow.com/comment/32904092
tagged with: java
has body: I noticed if you try to use LEADING alignment in GroupLayout when one of the components is a button and the other is not a button, the components no longer line up. If both components are buttons, you get results like this: getContainerGap(button, EAST, container) -&gt; 14 getContainerGap(another button, EAST, container) -&gt; 14 getContainerGap(button, WEST, container) -&gt; 14 getContainerGap(another button, WEST, container) -&gt; 14 getContainerGap(button, SOUTH, container) -&gt; 17 getPreferredGap(another button, button, RELATED, SOUTH, container) -&gt; 4 getContainerGap(another button, SOUTH, container) -&gt; 17 If you get out a ruler, you can see that the left margin is exactly 20 pixels, so this result is correct. If one of the components is not a button (usually I'm seeing this when I try to align a button to the left edge of a JScrollPane or similar), you get results like this: getContainerGap(button, EAST, container) -&gt; 14 getContainerGap(reference component, EAST, container) -&gt; 20 getContainerGap(button, WEST, container) -&gt; 14 getContainerGap(reference component, WEST, container) -&gt; 20 getContainerGap(button, SOUTH, container) -&gt; 17 getPreferredGap(reference component, button, RELATED, SOUTH, container) -&gt; 7 getContainerGap(reference component, SOUTH, container) -&gt; 20 Now if you get out a ruler, the left margin of the red border is exactly 20 pixels, but the button juts out an additional 6 pixels. The getVisualMargin method exists to correct this, and you can see that getContainerGap(button, EAST, container) returns 14, which is compensating for the 6 pixels of extra margin outside the button. If you have more types of component to lay out, the results get progressively worse and you end up with a jagged edge all the way down the layout, since only similar components will align with each other. I'm wondering what is going on here. Even though the LayoutStyle is returning the right value for the container gap, it seems like GroupLayout…
has comment: http://stackoverflow.com/comment/32681900
tagged with: grouplayout
has title: I'm trying to correct the layout of Aqua buttons in GroupLayout, but is it even possible?
type: Question
tagged with: layout

http://stackoverflow.com/q/21569238
has answer: http://stackoverflow.com/a/21569298
has comment: http://stackoverflow.com/comment/32580008
downvote count: 0
answer count: 1
favorite count: 0
type: UnansweredQuestion
has title: Using iText for PDF export
tagged with: http://stackoverflow.com/tag/html
tagged with: pdf-generation
score: 3
upvote count: 3
tagged with: java
tagged with: itext
type: Question
has body: In our Spring application, we have export in multiple pages in different sections , the export will include both the data and the graphs. Could you please direct me which is the best option for the export to PDF, we are planning to use iText, so for different pages, can we create templates, whether it will take css styles. whether the HTML template or ftl template work, or do we have any other options which is good in performance and considering that there are many sections where we need export Regards Hari

http://stackoverflow.com/comment/32611012
type: AnswerComment
has text: I don't think that this code does what he's asking for.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21586983

http://stackoverflow.com/a/21559621
type: Answer
score: 3
upvote count: 3
accepted answer of: http://stackoverflow.com/q/21556647
downvote count: 0
has body: You can use Instrumentation to register a retransform-capable ClassFileTransformer and request a re-transformation of the Proxy class. Then, within the transformer’s transform method you have hands on the byte array which makes up the class. After saving the array to a class file you can simply return the array unmodified to let the JVM proceed unaffected. But I’m not sure what you expect from looking into these classes. They are implemented straight-forward and offer no surprises. Here is an example of javap’s output after doing the steps described above on the java.lang.Runnable Proxy as generated with Oracle’s jdk1.7.0_40: public final class com.sun.proxy.$Proxy0 extends java.lang.reflect.Proxy implements java.lang.Runnable { private static java.lang.reflect.Method m1; private static java.lang.reflect.Method m3; private static java.lang.reflect.Method m0; private static java.lang.reflect.Method m2; public com.sun.proxy.$Proxy0(java.lang.reflect.InvocationHandler); Code: 0: aload_0 1: aload_1 2: invokespecial #8 // Method java/lang/reflect/Proxy."&lt;init&gt;":(Ljava/lang/reflect/InvocationHandler;)V 5: return public final int hashCode(); Code: 0: aload_0 1: getfield #16 // Field java/lang/reflect/Proxy.h:Ljava/lang/reflect/InvocationHandler; 4: aload_0 5: getstatic #55 // Field m0:Ljava/lang/reflect/Method; 8: aconst_null 9: invokeinterface #28, 4 // InterfaceMethod java/lang/reflect/InvocationHandler.invoke:(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object; 14: checkcast #57 // class java/lang/Integer 17: invokevirtual #60 // Method java/lang/Integer.intValue:()I 20: ireturn 21: athrow 22: astore_1 23: new #42 // class java/lang/reflect/UndeclaredThrowableException 26: dup 27: aload_1 28: invokespecial #45 // Method java/lang/reflect/UndeclaredThrowableException."&lt;init&gt;":(Ljava/lang/Throwable;)V 31: athrow Exception table: from to target type 0 21 21 Class java/lang/Error 0 21 21 Class java/lang/RuntimeException 0 21 22 Cla…
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21556647

http://stackoverflow.com/comment/32748841
comment on: http://stackoverflow.com/q/21665818
score: 0
has text: what do you want to update exactly? What is in menu?
type: QuestionComment
type: Comment

http://stackoverflow.com/q/21541979
has comment: http://stackoverflow.com/comment/32531823
answer count: 2
has comment: http://stackoverflow.com/comment/32531787
has comment: http://stackoverflow.com/comment/32531831
upvote count: 0
has body: import java.util.Scanner; public class Hw4Part4 { public static void main(String[] args){ Scanner sc = new Scanner(System.in); //Ask for the diners’ satisfaction level using these ratings: 1 = Totally satisfied, 2 = Satisfied, //3 = Dissatisfied. System.out.println("Satisfacion leve: "); int satisfactionNumber= sc.nextInt(); //Ask for the bill subtotal (not including the tip) System.out.println("What is the bill subtotal: "); double subtotal= sc.nextInt(); //Report the satisfaction level and bill total. System.out.println("The satisfaction level is: "+ satisfactionLevel(satisfactionNumber)); System.out.println("The bill total is: " + getBillTotal(tipPercentage, subtotal)); } public static String satisfactionLevel(int satisfactionNumber){ String satisfactionL = ""; if (satisfactionNumber == 1){ satisfactionL ="Totally-satisfied"; } if (satisfactionNumber == 2){ satisfactionL = "Satisfied"; } if (satisfactionNumber == 3){ satisfactionL = "Dissatisfied"; } return satisfactionL; } //This method takes the satisfaction number and returns the percentage of tip to be //calculated based on the number. //This method will return a value of 0.20, 0.15, or 0.10 public static double getPercentage(int satisfactionNumber){ double getPercentage = 0; if (satisfactionNumber ==1){ getPercentage = 0.20; } if (satisfactionNumber ==2){ getPercentage = 0.15; } if (satisfactionNumber ==3){ getPercentage = 0.10; } return getPercentage; } public static double getBillTotal(double tipPercentage, double subtotal){ double totalWithTip= (subtotal + ( getPercentage(satisfactionNumber) * subtotal)); return totalWithTip; } } I am having issues on the last method, the whole code is shown above. It says there is error with the part where I am trying to use the previous method. I need to get the percentage which was computed on the previous method.
has comment: http://stackoverflow.com/comment/32531817
favorite count: 0
accepted answer: http://stackoverflow.com/a/21542298
has comment: http://stackoverflow.com/comment/32531175
has comment: http://stackoverflow.com/comment/32531797
type: AnsweredQuestion
tagged with: java
downvote count: 2
has answer: http://stackoverflow.com/a/21542029
has comment: http://stackoverflow.com/comment/32531341
has comment: http://stackoverflow.com/comment/32531185
type: Question
has comment: http://stackoverflow.com/comment/32531582
has answer: http://stackoverflow.com/a/21542298
has title: Move a method to another method java
score: -2
possible better answer: http://stackoverflow.com/a/21542029

http://stackoverflow.com/a/21519887
has comment: http://stackoverflow.com/comment/32491772
answers question: http://stackoverflow.com/q/21519852
type: AcceptedAnswer
downvote count: 0
has body: I count five separate instances Frame in your code, of which I think only one is visible, which generally isn't the one you are interacting with... // 1... public class Controller { public static Frame myFrame = new Frame(); // 2, 3... public static void main(String[] args) throws Exception { EventQueue.invokeLater(new Runnable() { public void run() { new Frame().setVisible(true); new Frame().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }); // 4... public class Checkout{ Frame testFrame = new Frame(); // 5... public void simulation(){ //... Frame fFrame = new Frame(); Reduce this to one and use it alone. This may mean you will need to pass a reference of the frame to other parts of you application. A better solution would be to build some kind of model, which could trigger notifications, telling interested parties that some part of the model has changed and any one depending on it's data should be updated....
upvote count: 2
has comment: http://stackoverflow.com/comment/32491752
type: Answer
has comment: http://stackoverflow.com/comment/32491813
score: 2
accepted answer of: http://stackoverflow.com/q/21519852

http://stackoverflow.com/comment/32701504
has text: How can you learn the logic if we keep providing all the answers and code for you? Do you really want to learn the logic, or can you just not use a set for your homework assignment?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21637879
score: 1

http://stackoverflow.com/comment/32631505
has text: @Rakesh Thx for your answer! Please explain further. I do not understand what you mean?
score: 0
type: Comment
comment on: http://stackoverflow.com/q/21598937
type: QuestionComment

http://stackoverflow.com/a/21624130
accepted answer of: http://stackoverflow.com/q/21623962
type: AcceptedAnswer
downvote count: 0
has body: As you have correctly stated, they just happen to share a name but are entirely different. Virtualized hardware is perceived by the software as being indistinguishable from the actual hardware. It has exactly the same architecture, down to a quite low level, at which the abstraction layer of the virtualization is crossed. This is not at all the goal of a VM for a managed language, which creates a virtual environment specific to that language, and identical on all hardware platforms.
type: Answer
answers question: http://stackoverflow.com/q/21623962
upvote count: 3
score: 3

http://stackoverflow.com/comment/32622129
comment on: http://stackoverflow.com/a/21593127
score: 0
type: AnswerComment
has text: @peeskillet LOL! In any case, the change of 'tick' has brought me back to 99.9 K. Barbie is off.. :(
type: Comment

memory
tags question: http://stackoverflow.com/q/21554988
tags question: http://stackoverflow.com/q/21550549
tags question: http://stackoverflow.com/q/21601306
tag name: memory
tags question: http://stackoverflow.com/q/21526461
tags question: http://stackoverflow.com/q/21550831
tags question: http://stackoverflow.com/q/21621893
tags question: http://stackoverflow.com/q/21647394
tags question: http://stackoverflow.com/q/21597840
tags question: http://stackoverflow.com/q/21596670
tags question: http://stackoverflow.com/q/21583575
tags question: http://stackoverflow.com/q/21648822
type: Tag
tags question: http://stackoverflow.com/q/21534002
tags question: http://stackoverflow.com/q/21554848
tags question: http://stackoverflow.com/q/21535189
tags question: http://stackoverflow.com/q/21676143
tags question: http://stackoverflow.com/q/21657454

http://stackoverflow.com/comment/32735064
has text: Thank you! This solved my problem. So does this mean that the class accepts generics since its in the class definition? And since every class inherits from type object it will just resolve to whatever class is passed as a cast, otherwise its generic because of the <T> in the class definition.
type: AnswerComment
comment on: http://stackoverflow.com/a/21658200
score: 0
type: Comment

http://stackoverflow.com/comment/32622199
has text: Did your research go so far as reading the dozen exact same questions with answers in the **Related** side bar of this question on this same site?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21593404

http://stackoverflow.com/comment/32514601
has text: But is mediaRouter in separate project which your main project is using as library project?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21532709
score: 0

http://stackoverflow.com/comment/32816001
type: Comment
comment on: http://stackoverflow.com/a/21648385
type: AnswerComment
score: 0
has text: No problem, feel free to mark the answer if it resolves your problem.

http://stackoverflow.com/a/21659335
downvote count: 0
has comment: http://stackoverflow.com/comment/32738496
score: 5
has body: Yes. But also you can use Collections.synchronizedMap utility method to make a hashmap thread safe: Map yourMap = new HashMap(); Map synchronizedMap = java.util.Collections.synchronizedMap(yourMap); Or you can use ConcurrentHashMap or Hashtable which are thread safe by default.
type: AcceptedAnswer
type: Answer
upvote count: 5
accepted answer of: http://stackoverflow.com/q/21659204
answers question: http://stackoverflow.com/q/21659204

http://stackoverflow.com/comment/32728080
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/21622355
type: Comment
has text: Thanks for the answer Michael, I thought I could send the PPS at level 4. What kind of smartcard reader implements such interface for re-activation of the card settings? I am playing with a reader from SpringCard. They provide an interface, but I can't reach 848 kbauds.

http://stackoverflow.com/comment/32712928
comment on: http://stackoverflow.com/a/21645437
type: AnswerComment
score: 0
type: Comment
has text: Yes, instead of Activity, it'l be FragmentActivity and you will be creating Fragments, but i don't think there'l be much of a change in rest of the concept :)

http://stackoverflow.com/q/21523693
type: AnsweredQuestion
score: 3
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/21556858
type: Question
possible better answer: http://stackoverflow.com/a/68511555
has answer: http://stackoverflow.com/a/68511555
tagged with: spring-websocket
has title: Spring websocket example - error - Are you running in a Servlet container that supports J SR-356?
downvote count: 0
tagged with: tomcat
answer count: 3
accepted answer: http://stackoverflow.com/a/21556858
has answer: http://stackoverflow.com/a/31046894
favorite count: 0
has body: I am trying to run the Spring 4 example given @ https://spring.io/guides/gs/messaging-stomp-websocket. When I try to connect to socket, it throws me following exception. As per the example you need tomcat 7.0.50 and I checked the executable jar which has right version of tomcat. Any pointer would be helpful. java.lang.IllegalArgumentException: No 'javax.websocket.server.ServerContainer' ServletContext attribute. Are you running in a Servlet container that supports JSR-356?

http://stackoverflow.com/comment/32497181
score: 0
has text: You can ignore them, because the error is about another war or file presents in the webapps dir and which is not a valid war ( web service ) file.
comment on: http://stackoverflow.com/q/21522518
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32534256
type: Comment
comment on: http://stackoverflow.com/a/21544148
score: 0
type: AnswerComment
has text: I see the green sign next to google play service , is there a way to make test. the same library works fine in another my project

http://stackoverflow.com/a/21554699
type: Answer
score: 0
answers question: http://stackoverflow.com/q/21554309
has body: First of all, correct class definition is public class MyClass&lt;T extends SomeClass&gt; { } or private class MyClass&lt;T extends SomeClass&gt; { } if this class is an inner class. T will be replaced with some type. It means that SomeClass T =new SomeClass(); // this T is not the T from class definition In the line above you are trying to create an instance of abstract class - it's impossible ! Create class which extends SomeClass and implements abstract methods if any and then you can create an instance SomeClass sc = new MyNewClassWhichExtendsSomeClass()

http://stackoverflow.com/comment/32668003
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21619305
has text: libs, I have no lib folder...the error is gone. Feel free to post your comment as an answer and I'll give you the marked answer points

http://stackoverflow.com/a/42130999
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21641083
has body: Scanner#hasNext() is going to return a boolean value indicating whether or not there is more input and as long as the user has not entered end-of-file indicator, hasNext() is going to return true The end-of-file indicator is a system-dependent keystroke combination which the user enters to indicate that there’s no more data to input. on UNIX/Linux/Mac OS X it's ctrl + d,,, On Windows it's ctrl + z look at this simple example to see how to use it // Fig. 5.9: LetterGrades.java // LetterGrades class uses the switch statement to count letter grades. import java.util.Scanner; public class LetterGrades { public static void main(String[] args) { int total = 0; // sum of grades int gradeCounter = 0; // number of grades entered int aCount = 0; // count of A grades int bCount = 0; // count of B grades int cCount = 0; // count of C grades int dCount = 0; // count of D grades int fCount = 0; // count of F grades Scanner input = new Scanner(System.in); System.out.printf("%s%n%s%n %s%n %s%n", "Enter the integer grades in the range 0–100.", "Type the end-of-file indicator to terminate input:", "On UNIX/Linux/Mac OS X type &lt;Ctrl&gt; d then press Enter", "On Windows type &lt;Ctrl&gt; z then press Enter"); // loop until user enters the end-of-file indicator while (input.hasNext()) { int grade = input.nextInt(); // read grade total += grade; // add grade to total ++gradeCounter; // increment number of grades // increment appropriate letter-grade counter switch (grade / 10) { case 9: // grade was between 90 case 10: // and 100, inclusive ++aCount; break; // exits switch case 8: // grade was between 80 and 89 ++bCount; break; // exits switch case 7: // grade was between 70 and 79 ++cCount; break; // exits switch case 6: // grade was between 60 and 69 ++dCount; break; // exits switch default: // grade was less than 60 ++fCount; break; // optional; exits switch anyway } // end switch } // end while // display grade report System.out.printf("%nGrade Report:%n"); // if user entered at l…

http://stackoverflow.com/comment/32732771
has text: Your question is unclear. Do you just want to write boolean method that returns true if all elements of 2D arrays are greater than 0?
score: 0
comment on: http://stackoverflow.com/q/21656880
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32616933
has text: Could you site your sources regarding `"no one really creates inner classes or even static inner classes"`? Sorry, but this statement seems blatantly false.
comment on: http://stackoverflow.com/q/21590153
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21640621
has comment: http://stackoverflow.com/comment/32705140
answers question: http://stackoverflow.com/q/21640541
downvote count: 0
has body: As pL4Gu33 has already stated in his answer, your comparison is faulty. Essentially, each step through the for-loop leaves hand[i] at a constant value (say, 4). That means that your if-statements are checking: if(4 == 4 &amp;&amp; 4 == 5 &amp;&amp; 4 == 6 &amp;&amp; 4 == 7 &amp;&amp; 4 == 8) { ... } This will never evaluate to true. If you knew for certain that you had five elements in the hand and that the hand was already sorted, you could do if (hand[0] == 2 &amp;&amp; hand[1] == 3 &amp;&amp; hand[2] == 4 &amp;&amp; hand[3] == 5 &amp;&amp; hand[4] == 6) { ... } However, I'm going to show you a better answer. The first thing you should do is to sort your hand. Once you do that, it's easy to step through the hand and check to see if the next card in the hand is exactly one greater than the previous card. If you get to the end and this holds true, then it's a straight. /* * You will need to import java.util.Arrays */ public boolean isStraight(int[] hand) { if(hand == null || hand.length != 5) { return false; } else { // Automatically sort the hand Arrays.sort(hand); // Set the "previous" variable to a theoretically impossible value int prev = -1; // Iterate through the hand and see if the next card is exactly one more than // the previous one. for(int i = 0; i &lt; hand.length; i++) { // If prev is -1, then this is the first time through the for-loop // If the card that we're on has a value of the previous card + 1, // we still have the possibility of a straight. if(prev == -1 || (prev + 1) == hand[i]) { prev = hand[i]; } else { return false; } } return true; } }
type: Answer
upvote count: 3
score: 3
has comment: http://stackoverflow.com/comment/32705082

http://stackoverflow.com/comment/32561809
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21559777
has text: What is this code doing instead? Auto-format is ctrl+I, which google would have told you faster than we could.
score: 0

http://stackoverflow.com/comment/35542735
type: QuestionComment
comment on: http://stackoverflow.com/q/21669652
has text: Hey guys just found this on [SO][1] it worked for me! [1]: http://stackoverflow.com/questions/17625345/no-android-facet-found-issues-compiling-with-android-studio-0-2
score: 0
type: Comment

http://stackoverflow.com/q/21570517
tagged with: java
has body: I am getting some data via JSON which I store in a Hashmap map e.g. map.put(KEY_TITLE, parser.getString("title")) and then add the map to an ArrayList> bookList. This is displayed in a list view with bookList as source for the adapter. Additionally I also store all the book info (title, author, published date) of the map in Arraylist arrTitles, arrAuthors, arrDates as I need to pass these values to my next activity. My problem is when I use a comparator to sort the bookList on basis of titles then the bookList gets sorted just fine. I however want to sort my arrTitles, arrAuthors and arrDates as per the new sorting of the bookList so that my arrTitles.getItem(position) sends the correct value to the next activity. Any idea how I can do this? Below are the hashmap, arraylist, onItemClick &amp; comparator code: for (int i = 0; i &lt; json.Length(); i++) { HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); // adding each child node to HashMap key =&gt; value map.put(KEY_ID, json.getString("id")); map.put(KEY_TITLE, json.getString("title")); map.put(KEY_AUTHOR, json.getString("author")); map.put(KEY_DATE, json.getString("date")); arrTitles.add(json.getString("title"); arrAuthors.add(json.getString("author"); arrDates.add(json.getString("date"); //add map to ArrayList booksList.add(map); } list=(ListView)findViewById(R.id.list); Collections.sort(booksList, mapComparator); adapter=new LazyAdapter(this, booksList); list.setAdapter(adapter); // Click event for single list row list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { Intent intent = new Intent(this, editList.class); intent.putExtra("title", arrTitles.getItem(position)); intent.putExtra("date", arrDates.getItem(position)); startActivity(intent); } }); } public Comparator&lt;Map&lt;String, String&gt;&gt; mapComparator = new Comparator&lt;Map&lt;String, String&gt;&gt;() { public int compare(Map…
has answer: http://stackoverflow.com/a/21571075
has comment: http://stackoverflow.com/comment/32582051
has comment: http://stackoverflow.com/comment/32581960
type: Question
tagged with: hashmap
possible better answer: http://stackoverflow.com/a/21571420
tagged with: sorting
has answer: http://stackoverflow.com/a/21571420
tagged with: arraylist
score: 0
has answer: http://stackoverflow.com/a/21570876
has comment: http://stackoverflow.com/comment/32582018
has title: How to sort ArrayList<String> containing elements of ArrayList<HashMap<String, String>> that has been sorted by a comparator?
answer count: 4
has comment: http://stackoverflow.com/comment/32581808
tagged with: android
has answer: http://stackoverflow.com/a/21573049
accepted answer: http://stackoverflow.com/a/21570876
type: AnsweredQuestion

http://stackoverflow.com/q/21569981
upvote count: 1
downvote count: 0
tagged with: eclipse-plugin
favorite count: 0
tagged with: eclipse-rcp
has comment: http://stackoverflow.com/comment/32582511
answer count: 0
type: UnansweredQuestion
score: 1
tagged with: java
tagged with: eclipse
has title: Add Sample Rcp Application (With View ) Menubar(Created By Own) into Eclipse Default Menubar while Porting Application as Plugin to Eclipse
has body: Input: RCP Application(with View): Menubar:: List FileFunction Window Help Output: All these Menu to be Added in Default Menubar of Eclipse when the said RCP application is Ported as Plugin to Eclipse. Note: Menubar in RCP application is created in ApplicationActionBarAdvisor.java class and not in plugin.xml with the help of FillMenuBar method. Problem: After Porting the Above Application as Plugin....View is Opening but Menubar of RCP App is not showing up in Menubar of Eclipse. Kindly help out as to How to proceed to solve this Problem Thanks in Advance
has comment: http://stackoverflow.com/comment/32587301
type: Question
has comment: http://stackoverflow.com/comment/32589726

http://stackoverflow.com/q/21526628
downvote count: 0
score: 1
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/21527041
has title: XPages Java Error: Error getting property 'dbName' from bean
tagged with: xpages
has answer: http://stackoverflow.com/a/21527041
upvote count: 1
answer count: 1
has body: Using the NotesIn9 example from episode 133 I tried to adapt the code to a database maintanance XPage. I replaced all the contact stuff with database information: a database form, a database view, a DatabaseModel.java class, a database_crud XPage. And I defined the DatabaseModel.java class as managed bean. But when I try to open y XPage I get the following error: Error getting property 'dbName' from bean of type com.ibm.domino.xsp.module.nsf.NSFComponentModule$XPagesDatabase Here is the managed bean definition: database view org.openntf.howyabean.model.DatabaseModel And here the dbName field in the XPage: <xp:label for="dbName" value="Database Name" /> <xp:inputText id="dbName" value="#{database.dbName}" /> I'm new to XPages development and don't know where to search for the problem. Any ideas?
favorite count: 0
type: AnsweredQuestion

http://stackoverflow.com/comment/32497257
comment on: http://stackoverflow.com/a/21523274
type: AnswerComment
score: 0
type: Comment
has text: @Bohemian Am I good to assume that writing a loop is the only good way to do this?

http://stackoverflow.com/q/21579016
has answer: http://stackoverflow.com/a/21579411
upvote count: 2
answer count: 1
has body: In my application I use the library log4j to generate logs of the entire system. Is working correctly, use the following settings: Direct log messages to a log file: log4j.appender.file = org.apache.log4j.DailyRollingFileAppender log4j.appender.file.File = log / aplicacao.log log4j.appender.file.DatePattern = '.' yyyy-MM-dd log4j.appender.file.layout = org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern =% d {MM-dd-yyyy, HH: mm: ss: SSS},% t,%-5p,% c {1}:% L-% m% n log4j.appender.file.MaxFileSize = 50KB log4j.appender.file.MaxHistory = 2 I wonder if there is some property that makes clear old files that already have more than a week, because if my system remain running for a long time is not feasible to occupy a lot of memory because the application that I developed is to be used on machines very old. Is there any solution for this? Maxfilesize and MaxHistory added the property and it does not work.
linked to: http://stackoverflow.com/q/3683364
tagged with: log4j
favorite count: 0
type: UnansweredQuestion
tagged with: logging
score: 2
downvote count: 0
tagged with: java
has title: Delete old file using log4j
type: Question

http://stackoverflow.com/a/21659412
has comment: http://stackoverflow.com/comment/32739165
has comment: http://stackoverflow.com/comment/32739117
type: Answer
has comment: http://stackoverflow.com/comment/32739004
has comment: http://stackoverflow.com/comment/32739185
answers question: http://stackoverflow.com/q/21659278
score: 0
has body: You have an empty string for userid and password , and you make a query by using this values , so it will return nothing so you need first to take the userid and password from the user , then make the query by using this values , and if there are a result , so you have valid user String userid = request.getParameter("userid"); String password =request.getParameter("password"); ////and your select statment String sql = "SELECT * FROM login WHERE userid = ? AND password = ?"; PreparedStatement preparedStatement = connection.prepareStatement(sql); preparedStatement.setString(1, userid); preparedStatement.setString(2, password); Statement s = connection.createStatement(); rs =preparedStatement.executeQuery(); ////if there are next ib rs so you have a user by this id and password if(rs.next()) { out.println("The user is valid"); } else { out.println("You are not valid"); }

http://stackoverflow.com/comment/139448025
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21638033
has text: MediaPlayer is a tricky bastard - you deserve 100 likes for this line.

http://stackoverflow.com/comment/32746450
has text: Given the string "anitasugarland", how would the program tell that it should match "anita" but not "an"? How could it know how much of the string is the first name?
type: Comment
score: 5
type: QuestionComment
comment on: http://stackoverflow.com/q/21664585

http://stackoverflow.com/comment/32565758
comment on: http://stackoverflow.com/q/21558069
type: Comment
type: QuestionComment
has text: Possible duplicate of [Code for changing the color of subtasks in Gantt Chart](http://stackoverflow.com/questions/8938690/code-for-changing-the-color-of-subtasks-in-gantt-chart)
score: 1

http://stackoverflow.com/comment/32558449
type: Comment
comment on: http://stackoverflow.com/q/21556492
score: 0
has text: Sorry My bad! I got confused with the version numbers, I thought the second one is '3.1.8'. Thanks for your time, I apologize for the confusion. TY!
type: QuestionComment

http://stackoverflow.com/a/21576914
has body: If implementers of the interface don't need to implement all the methods, they don't need implement this interface, they need only one interface in the hierarchy with needed method set. I would use inheritance like this interface MyFirstInterface { void doSomething(); } interface MySecondInterface extends MyFirstInterface { void doSomethingElse(); }
score: 0
answers question: http://stackoverflow.com/q/21576726
type: Answer

http://stackoverflow.com/q/21529597
tagged with: servlets
type: Question
answer count: 1
downvote count: 0
tagged with: jsp
accepted answer: http://stackoverflow.com/a/21530146
favorite count: 0
tagged with: security
has title: Setting UserPrincipal in form based authentication
score: 1
upvote count: 1
tagged with: model-view-controller
has answer: http://stackoverflow.com/a/21530146
type: AnsweredQuestion
has body: [JEE, MVC-JSP+Servlets, TomEE] Using form based declarative authentication (container managed). Is it possible to explicitly set UserPrincipal? (to log some user in). I know I can check whether there is logged in user or not with request.getUserPrincipal()!=null. Actually I am facing following situation: I have a register.jsp that is being used for new users registration. So data from this jsp are sent to servlet where new user object is created and persisted to database. So, now when user has registered, he/she should be automatically logged in. So, I was thinking how can I implement this automatic login after registration.
tagged with: java

http://stackoverflow.com/q/21656023
tagged with: hashmap
has answer: http://stackoverflow.com/a/21656111
has answer: http://stackoverflow.com/a/21656056
score: 0
upvote count: 1
downvote count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/21656133
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/1066589
answer count: 4
has comment: http://stackoverflow.com/comment/32737101
has comment: http://stackoverflow.com/comment/32731659
has title: Why my hashmap overwrites with last value added?
has body: I'm struck with my project... have to maintain large hashmap of lang arrays.... i try this with sample but its not working.... I cant store keys in arrays.... thanks in advance... class K{ int key; } class V{ int data; } class hashmp{ public static void main(String args[]){ HashMap&lt;K,V&gt; hm=new HashMap&lt;K,V&gt;(); K key1=new K(); for(int i=0;i&lt;5;i++){ V val=new V(); key1.key=i; val.data=i+5; hm.put(key1,val); } System.out.println(); for(int i=0;i&lt;5;i++){ key1.key=i; V pt=hm.get(key1); System.out.println("\n"+hm.containsKey(key1)+key1.key); if(hm.containsKey(key1)) System.out.print(pt.data); } } } for that i'm getting.... true0 9 true1 9 true2 9 true3 9 true4 9 updated code..... class K{ long key; } class V{ long[] v=new long[10]; } public void putHash(V val1){ //some code V s=new V(); K gt=new K(); gt.key=val1.v[0]; if(hm.containsKey(keyArr[(int)gt.key])){ s=hm.get(gt); //get value of key if exists //some code to modify s } gt.key=val1.v[0]; hm.put(gt,s); // put the modified value back to same key } Thank you all to provide me the answers... finally it works well... Thanks for everyone's contribution....
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21656178

http://stackoverflow.com/comment/32610517
has text: r u facing some pblm with such attribute ??
type: AnswerComment
comment on: http://stackoverflow.com/a/21586269
score: 0
type: Comment

yql
tags question: http://stackoverflow.com/q/21631699
type: Tag
tags question: http://stackoverflow.com/q/21658569
tag name: yql

browser
tags question: http://stackoverflow.com/q/21644856
tags question: http://stackoverflow.com/q/21635503
tags question: http://stackoverflow.com/q/21624965
tags question: http://stackoverflow.com/q/21622596
tags question: http://stackoverflow.com/q/21625882
tag name: browser
type: Tag

android-broadcast
tag name: android-broadcast
type: Tag
tags question: http://stackoverflow.com/q/21659190

http://stackoverflow.com/comment/32694046
comment on: http://stackoverflow.com/q/21633997
score: 0
has text: It looks like you forgot to swap the pivot with hi after the while loop.
type: QuestionComment
type: Comment

eclipse-jdt
tags question: http://stackoverflow.com/q/21625214
tag name: eclipse-jdt
tags question: http://stackoverflow.com/q/21624093
tags question: http://stackoverflow.com/q/21634186
tags question: http://stackoverflow.com/q/21568087
tags question: http://stackoverflow.com/q/21669244
type: Tag

http://stackoverflow.com/q/21546787
tagged with: jpa
downvote count: 0
score: 1
favorite count: 0
accepted answer: http://stackoverflow.com/a/21594760
tagged with: many-to-one
has title: In Many to One Relationship how to delete child objects
linked to: http://stackoverflow.com/q/21569970
type: AnsweredQuestion
tagged with: java
has body: Many to One : When removing child object it shoud also remove parent object in Many-to-One relationship. While saving a single object in both parent and child it's working fine. But if I add more than one child object (2 or more) to one parent class, then how can I delete the child object from the list of child objects of one parent class? Child POJO: @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="id") private int id; @Column(name="cName") private String cName; @ManyToOne(cascade=CascadeType.ALL, fetch=FetchType.EAGER) @JoinColumn(name="pId") private Parent parent Parent POJO: @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="id") private int id; @Column(name="pName") private String pName; @Column(name="address") private String address;
upvote count: 1
linked to: http://stackoverflow.com/q/21545682
type: Question
has answer: http://stackoverflow.com/a/21594760
has comment: http://stackoverflow.com/comment/32540128
possible better answer: http://stackoverflow.com/a/21547156
answer count: 2
has answer: http://stackoverflow.com/a/21547156

http://stackoverflow.com/a/21664116
answers question: http://stackoverflow.com/q/21663948
type: Answer
upvote count: 2
has body: You can use an AtomicInteger which is also thread safe. Or you need a model class which may contain the int counter and methods to increment and read the value: public class Model { private int submitCount = 0; public void submit() { ++submitCount; } public void reset() { submitCount = 0; } public int submitted() { return submitCount; } }
score: 2
downvote count: 0

http://stackoverflow.com/comment/32667687
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21619304
has text: What @SotiriosDelimanolis said. More on subject [here](http://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files).
score: 0

http://stackoverflow.com/q/21603541
tagged with: generics
has answer: http://stackoverflow.com/a/21603615
has comment: http://stackoverflow.com/comment/32640071
has comment: http://stackoverflow.com/comment/32639870
linked to: http://stackoverflow.com/q/529085
answer count: 5
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32639134
linked to: http://stackoverflow.com/q/4533636
has answer: http://stackoverflow.com/a/21603740
tagged with: java
has comment: http://stackoverflow.com/comment/32638903
has body: I have a class which always holds four objects: class Foo&lt;E&gt; { Cow&lt;E&gt; a, b, c, d; } I want to be able to iterate over them, so ideally I'd like to use an array: class Foo&lt;E&gt; { Cow&lt;E&gt;[] cows = new Cow&lt;E&gt;[4]; // won't work, can't create generic array } I don't want to use a list or a set since I want there to always be 4 Cow objects. What's the best solution for me?
type: Question
has answer: http://stackoverflow.com/a/21610907
has title: Fixed number of generic objects which can be iterated over
tagged with: arrays
linked to: http://stackoverflow.com/q/2927391
has answer: http://stackoverflow.com/a/21613182
has answer: http://stackoverflow.com/a/21603725
has comment: http://stackoverflow.com/comment/32638868
score: 0
linked to: http://stackoverflow.com/q/716597
linked to: http://stackoverflow.com/q/1290112

http://stackoverflow.com/a/21529720
type: Answer
upvote count: 2
has body: When the statement A = new A() is called; the JVM searches for the class A, if classloader haven't load class A yet, load class A. at that time static{} block in class A is called. Then memory is allocated (Is it refer to your "object creation"?) Then constructor is called. (which constructor is running)
has comment: http://stackoverflow.com/comment/32508836
score: 2
answers question: http://stackoverflow.com/q/21529544
downvote count: 0

http://stackoverflow.com/a/21585394
type: Answer
has comment: http://stackoverflow.com/comment/32608201
score: 1
downvote count: 1
answers question: http://stackoverflow.com/q/21585253
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21585253
has body: When comparing strings, you need to use the .equals method. == will only determine if the two variable point to the exact same string (the smae pointer), not two strings with the same text, for example: string a="hello"; string b=a; string c=getUserInput();//User inputs the string "hello" System.out.println(a==b); System.out.println(a==c); System.out.println(a.equals(c)); will output true false true
upvote count: 2

http://stackoverflow.com/comment/32621998
type: AnswerComment
type: Comment
score: 0
comment on: http://stackoverflow.com/a/21592945
has text: For some reason it works each time but when I send in like {()()[(a==b)]}} it should say that there are too many closed symbols but it sends empty error up at the top. for(int i =0; i<str.length(); i++){ char c=str.charAt(i); if(c=='{' || c=='[' || c=='('){ s.push(c); }else if (c=='}'){ Character temp=s.pop(); if(temp!='{'){ s.push(temp); return MatchRtnCode.UNEXPECTED_SYMBOL; }

http://stackoverflow.com/comment/32522793
type: QuestionComment
has text: From your excepted output , the algorithm required to pick the nth char (n is width in your example it is 3) and form new string . do like this until the complete char visited.. is that the one you want ? then why height has to be passed as argument ?
score: 0
comment on: http://stackoverflow.com/q/21536350
type: Comment

http://stackoverflow.com/q/21527973
score: 0
answer count: 1
has body: I have a SQL query that returns a list of deals which have this structure : deal_id, value_1, value_2, ..., value 50 I put the result of this query in a list like this (using org.hibernate.SQLQuery) : SQLQuery select = session.createSQLQuery(QUERY); List result = select.list(); Then I use this loop to iterate through the results : for (Object o : result) { } When debugging, o looks like this (one String, 50 BigDecimal) : [SSA12325, 0, 1.012, 1.1235, ..., 0] I want to extract the deal_id, how do I do that ? I tried to convert o to a List, but I got a classCastException : [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
type: AnsweredQuestion
tagged with: java
tagged with: hibernate
accepted answer: http://stackoverflow.com/a/21528032
has title: Extract data from an Object
type: Question
has comment: http://stackoverflow.com/comment/32505566
has answer: http://stackoverflow.com/a/21528032

http://stackoverflow.com/q/21580847
has comment: http://stackoverflow.com/comment/32601367
has body: All of my database access methods have been working up until now. I have a string of n usernames separated by ";", and I want to make n separate select statements to check if the user is online or offline. However, when used, this method returns nothing (""). The database connection is working. Any solutions are welcome. EDIT: New method, still does not work: public static String CheckOn(String users) { String toreturn = ""; PreparedStatement stmt2 = null; ResultSet rs2 = null; try { conn = Database.getDBConnection("test"); String sql = "SELECT name FROM sessions WHERE name=?"; stmt2 = conn.prepareStatement(sql); String[] usarr = users.substring(1, users.length()).split(";"); for (int i = 0; i &lt;usarr.length;i++){ if (usarr[i].equals("Empty")){ toreturn = toreturn + "-"; } else{ stmt2.setString(1, usarr[i]); rs2 = stmt2.executeQuery(); if (rs2.next()){ toreturn = toreturn + "y"; } else{ toreturn = toreturn + "n"; } rs2.close(); } } rs2.close(); stmt2.close(); conn.close(); } catch (SQLException se) { se.printStackTrace(); } finally { try { if (stmt2 != null) stmt2.close(); } catch (SQLException se2) { } try { if (conn != null) conn.close(); } catch (SQLException se) { se.printStackTrace(); } } return toreturn; }
has comment: http://stackoverflow.com/comment/32601712
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32599767
has title: Mysql database multiple successive requests fail
answer count: 0
has comment: http://stackoverflow.com/comment/32599893
has comment: http://stackoverflow.com/comment/32600444
has comment: http://stackoverflow.com/comment/32599790
tagged with: mysql
has comment: http://stackoverflow.com/comment/32599861
has comment: http://stackoverflow.com/comment/32599746
has comment: http://stackoverflow.com/comment/32600843
type: Question
has comment: http://stackoverflow.com/comment/32599792
tagged with: java
has comment: http://stackoverflow.com/comment/32599697
has comment: http://stackoverflow.com/comment/32599945
has comment: http://stackoverflow.com/comment/32601285
has comment: http://stackoverflow.com/comment/32600023
score: 0

http://stackoverflow.com/comment/32669716
type: Comment
type: QuestionComment
has text: There's no reason why this should work at all. A resource isn't a file. It's much more likely to be in a JAR file than on the file system.
score: 0
comment on: http://stackoverflow.com/q/21620620

http://stackoverflow.com/comment/32712370
type: Comment
type: QuestionComment
has text: Not even with the back button?
score: 0
comment on: http://stackoverflow.com/q/21645259

http://stackoverflow.com/comment/32578528
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21568612
score: 3
has text: Hint: You're computing a sum but have not used a single `+`. So you'll need to add one somewhere.

http://stackoverflow.com/comment/32677656
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21625534
score: 0
has text: Then read all of http://docs.oracle.com/javaee/7/tutorial/doc/persistence-intro001.htm#BNBQA

http://stackoverflow.com/q/21645960
tagged with: sqlexception
has comment: http://stackoverflow.com/comment/32713755
has comment: http://stackoverflow.com/comment/32713893
has answer: http://stackoverflow.com/a/21646096
accepted answer: http://stackoverflow.com/a/21646096
has comment: http://stackoverflow.com/comment/32713589
has comment: http://stackoverflow.com/comment/32713641
answer count: 2
has comment: http://stackoverflow.com/comment/32713609
tagged with: sql
upvote count: 0
has comment: http://stackoverflow.com/comment/32713553
possible better answer: http://stackoverflow.com/a/21646108
favorite count: 0
tagged with: postgresql
tagged with: resultset
has comment: http://stackoverflow.com/comment/32713670
has comment: http://stackoverflow.com/comment/32713581
has comment: http://stackoverflow.com/comment/32713908
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32713544
has comment: http://stackoverflow.com/comment/32713504
has body: I have a JFrame which contains a form with 3 fields, one which is the name field and one which is the house no and postcode field, this is used to find a customer details. This works fine when the correct information is entered, and displays what I want it to inside a JTable. However if one of the fields in entered incorrectly and the information is not found, is it possible to have a custom error message to display? At the moment the error that appears is: 'ResultSet not positioned properly, perhaps you need to call next.' is it possible to customise the message for this scenario when the information is not found without having to lose the SQL exception altogether for other scenarios where errors occur?
tagged with: java
has comment: http://stackoverflow.com/comment/32713664
downvote count: 2
has comment: http://stackoverflow.com/comment/32713663
has title: Custom SQL Exception Error message in Java
has answer: http://stackoverflow.com/a/21646108
type: Question
has comment: http://stackoverflow.com/comment/32713535
has comment: http://stackoverflow.com/comment/32713959
has comment: http://stackoverflow.com/comment/32713538
has comment: http://stackoverflow.com/comment/32713596
score: -2

http://stackoverflow.com/comment/32780890
comment on: http://stackoverflow.com/a/21676422
has text: @davmac As I said, the "string pool" is just an implementation technique. The JLS only tells us how literals are expected to behave, not how it should be implemented (the JVM spec tells the latter). Have you considered my thought experiment with the pre-processor? Can you write a program that prints "I was preprocessed" when the pre-processor was used on it? - And, of course, the answer to the original question is: Usually, but it need not be so (as my though experiment shows).
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/21659507
has body: I'm busy making an android app in java and xml. It's a sort of puzzle game, a bit similar to sudoku. So i have a scrollview, with a table layout inside it. I have more tablerows than in this code, but showing them too would be unnecessary. &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/wallpaper" &gt; &lt;TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:stretchColumns="*" &gt; &lt;TableRow android:id="@+id/tableRow1" android:layout_width="fill_parent" android:minHeight="50dp" android:background="@drawable/cell_shape" &gt; &lt;TextView android:textColor="@color/black" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/game1" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_gravity="center" /&gt; &lt;TextView android:textColor="@color/black" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/yes" android:layout_gravity="center" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; &lt;/TableRow&gt; &lt;TableRow android:id="@+id/tableRow2" android:layout_width="fill_parent" android:minHeight="50dp" android:background="@drawable/cell_shape" &gt; &lt;TextView android:textColor="@color/black" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/game2" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_gravity="center" /&gt; &lt;TextView android:textColor="@color/black" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/yes" android:layout_gravity="center" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; &lt;/TableRow&gt; &lt;/TableLayout&gt…
type: Question
has answer: http://stackoverflow.com/a/21662313
tagged with: arrays
answer count: 1
has title: OnClick load Array in other JAVA file Android
score: 0
accepted answer: http://stackoverflow.com/a/21662313
tagged with: android
type: AnsweredQuestion
tagged with: onclick
tagged with: java

http://stackoverflow.com/a/21576466
has body: You are getting the error because the setCentre() method expects a Point and not 2 ints: setCentre(new Point(xCoord, yCoord)); Also for: 1.Why don't you just add another constructor for the origin point: public CentredBall(String colour, double radius) { setCentre(0,0); 2.You've written this but you don't know why you've written it? You override them so that they behave the way you want them to for your objects.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21576363

http://stackoverflow.com/comment/32485298
comment on: http://stackoverflow.com/q/21516303
type: Comment
has text: From the javadoc: `Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read.`
score: 0
type: QuestionComment

http://stackoverflow.com/comment/32618939
score: 0
type: AnswerComment
type: Comment
has text: i was trying other attempts by other posts thats why i added that. i am new to SSL and all this.
comment on: http://stackoverflow.com/a/21589208

http://stackoverflow.com/q/21602648
has answer: http://stackoverflow.com/a/24741481
has comment: http://stackoverflow.com/comment/36724643
type: Question
has body: I've got a problem when I try to run a R script from Java Netbeans on Mac OS. I truly look for an answer of this problem on internet but nothing works. I've used Rserve and Runtime.getRuntime().exec("Rscript myScript.R") but neither of them works with my program. When I use Rserve, I run Rserve(args="--no-save") on R console and Rconnection.eval("\myscript.R") on Java program and when I execute it, the program continues running without any response, no errors either and no stops. In fact when I try to execute a more simply R script, like calculate the mean or something like that, it works, but when I try to coerce a data.frame in a xts/zoo time series or just to load xts/zoo library first in my script, the program doesn't stop running and does nothing. On the other hand, when I try to execute "Runtime.getRuntime().exec("Rscript myScript.R")" like appears in other similar post, nothing happens. The program looks to execute the script but it doesn't give me any result although stops running at least. Maybe it is because of Mac OS and that I couldn't indicate to Java what is the Rscript or R.app path, I don't really know. Thank you very much in advance and I wish you could help me. Javi. The file code is: public void Rconnection () { RConnection c=new RConnection(); System.out.println("INFO : Trying to Connect to R"); c.parseAndEval("source(\"/scriptname.R\")"); System.out.println("Greeting from R:" + result.asString()); c.close(); } And the R script is: EU.df &lt;- read.csv("/myinput.csv",header=T) EU.xts &lt;- xts(EU.df[,2:5],seq(as.Date("1970-01-02"),len=nrow(EU.df),by="day")) write.csv(EU.df, file = "/myoutputfile.csv",row.names=FALSE) Maybe it's because of some problems with R libraries or because of MAC OS.
has comment: http://stackoverflow.com/comment/32670711
score: 6
tagged with: http://stackoverflow.com/tag/r
has comment: http://stackoverflow.com/comment/35601767
downvote count: 0
answer count: 1
tagged with: macos
has comment: http://stackoverflow.com/comment/32661606
favorite count: 0
type: UnansweredQuestion
upvote count: 6
has title: Running an R script from Java
tagged with: rscript
has comment: http://stackoverflow.com/comment/32638853
tagged with: java

http://stackoverflow.com/comment/32707089
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/21642013
has text: `for(checkint != (int)checkint)` not a valid for loop.
type: Comment

http://stackoverflow.com/q/21516303
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32485333
upvote count: 1
has answer: http://stackoverflow.com/a/21516336
type: Question
answer count: 2
has body: public String toString() { String info = ""; String courseInfo = this.getCourseInfo(); if("".equals(courseInfo)) { courseInfo = "None"; } info += "--------------------------------------------------\n"; info += "Student Name: " + this.name + "\n"; info += "Student Address: " + this.address + "\n"; info += "Student #: " + this.studentNumber + "\n"; info += "Student Login ID: " + this.loginID + "\n"; info += "Courses taken:" + "\n"; info += courseInfo + "\n"; info += "GPA: " + this.getGPA() + "\n"; info += "--------------------------------------------------\n"; return info; } I was told that this is a bad toString method because it should be to output diagnostic information on one line, or a single literal value if that makes sense. I really don't understand. Should I just print all the instance variables and let the user decide what it is?
accepted answer: http://stackoverflow.com/a/21516336
downvote count: 0
has comment: http://stackoverflow.com/comment/32485362
has comment: http://stackoverflow.com/comment/32485414
favorite count: 0
has comment: http://stackoverflow.com/comment/32485360
has comment: http://stackoverflow.com/comment/32485298
possible better answer: http://stackoverflow.com/a/21516345
has title: what should be included in the toString method and what should not?
tagged with: tostring
has answer: http://stackoverflow.com/a/21516345
type: AnsweredQuestion

http://stackoverflow.com/q/21582128
has comment: http://stackoverflow.com/comment/32602032
type: Question
tagged with: stringbuffer
tagged with: char
answer count: 3
score: 2
tagged with: arrays
downvote count: 0
favorite count: 0
has title: Can't append char to a StringBuffer 2-dimensional array
has answer: http://stackoverflow.com/a/21582176
type: UnansweredQuestion
tagged with: append
upvote count: 2
tagged with: java
has body: Does anybody know why i can't append a char to this StringBuffer array (in my example below) and can somebody please show me how i needs to be done? public class test { public static void main(String args[]){ StringBuffer[][] templates = new StringBuffer[3][3]; templates[0][0].append('h'); } } My output to this code is: output: Exception in thread "main" java.lang.NullPointerException at test.main(test.java:6) It would help me so much so if you know any solution, please respond to this
has answer: http://stackoverflow.com/a/21582394
has answer: http://stackoverflow.com/a/21582169

towers-of-hanoi
tag name: towers-of-hanoi
tags question: http://stackoverflow.com/q/21668424
type: Tag

http://stackoverflow.com/comment/32684742
comment on: http://stackoverflow.com/a/21615110
type: AnswerComment
score: 0
type: Comment
has text: Ah. I see what you're getting at. Yeah, scope error, that's what I get for not testing. I actually want a slightly different solution than yours, again for scoping reasons.

http://stackoverflow.com/comment/32540124
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/21547550
has text: I want output like this but can't get single backslashes

http://stackoverflow.com/comment/32664256
has text: In my case the "useful life" is the longest one. But if I use strong references a out of memory may occur. @kdgregory: Is it a bad thing to have object kept in memory if the gc can delete them whenever it needs to ? @ maaartinus: I can always set the references manually to null and limit the cache size, am I wrong ?
comment on: http://stackoverflow.com/q/21615718
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32511261
type: Comment
score: 0
type: AnswerComment
has text: oh, ok so conversion of char to int automatically replaces it with its ASCII code. Thank you!
comment on: http://stackoverflow.com/a/21530994

http://stackoverflow.com/a/21625847
has body: I've recorded some theoretical results about grow factor which could help you to choose a grow factor for your own data structure here: Magic Factors#Grow Factor. Higher grow factor leads to higher memory footprint and lower "reinsertions per element during construction" metric on average, when the size of the collection is unknown in advance. I agree with André Stannek that 1.5 grow factor doesn't have any special properties and it is just someone's "final decision".
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21624515

communication
tag name: communication
tags question: http://stackoverflow.com/q/21525606
type: Tag

http://stackoverflow.com/q/21666750
tagged with: java
downvote count: 1
type: Question
upvote count: 0
linked to: http://stackoverflow.com/q/898909
score: -1
tagged with: parent-child
has title: Changing parent object to child object
has answer: http://stackoverflow.com/a/21666885
has body: I need a bit of help here. so i have this. I was basically wondering when you create an array of object of a parent class, then change that object to a child class, can I access the methods of that child class and if not why. thanks for any help. public class Racer { private String name; private int position; // Constructor public Racer() {} public Racer(String name) { this.name = name; position = 0; } public String getName() { return name; } public int getPosition() { return position; } public void setPosition(int n) { position = n; } public void setName(String n){ this.name=n; } } the child class public class Spartiates extends Racer{ private int energy; public Spartiates(){ super(); } public Spartiates(String name){ setName(name); setPosition(20); energy=100; } public void setEnergy(int energy){ this.energy=energy; } public int getEnergy(){ return energy; } } main class public class demo{ public static void main(String[] args){ Racer [] player = new player[3]; for(int i=0; i&lt;player.length; i++){ player[i] = new Spartiates(); } System.out.println(player[1].getEnergy()); } so here the problem the getEnergy method doesn't work so I was wondering why. If anybody can help it would be very much appreciated. thanks
has answer: http://stackoverflow.com/a/21666826
favorite count: 0
has answer: http://stackoverflow.com/a/21666823
possible better answer: http://stackoverflow.com/a/21666791
has answer: http://stackoverflow.com/a/21666791
answer count: 4
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21666885

http://stackoverflow.com/a/23786678
answers question: http://stackoverflow.com/q/21658814
type: Answer
has body: you can add your adapter in the asynctask constructor : In your activity : LoadJson lj = new Json(adapter); lj.execute(); You can declare in LoadJson: private ArrayAdapter&lt;String&gt; mAdapter; In the constructor, you get the adapter from activity : public LoadJson(ArrayAdapter&lt;String&gt; adapter){ mAdapter = adapter; } So In your postExecute, you can update the adapter. Hope it helps!
score: 0

http://stackoverflow.com/comment/32759917
comment on: http://stackoverflow.com/q/21672499
type: Comment
has text: Remove the servlet config from your xml and then try to start tomcat again to find out if there is something wrong with other config of your server.
type: QuestionComment
score: 1

http://stackoverflow.com/comment/32653011
comment on: http://stackoverflow.com/q/21611458
type: Comment
type: QuestionComment
score: 2
has text: have you thought about using a database?

http://stackoverflow.com/q/21534316
has comment: http://stackoverflow.com/comment/32517873
possible better answer: http://stackoverflow.com/a/34952873
has comment: http://stackoverflow.com/comment/32517350
upvote count: 23
type: Question
has comment: http://stackoverflow.com/comment/32518146
has answer: http://stackoverflow.com/a/34952873
tagged with: java
tagged with: antlr
has answer: http://stackoverflow.com/a/21552478
has body: Can someone provide a detailed example as to how I can do this using antlr4? Instructions right from installing antlr4 and its dependencies would be highly appreciated.
answer count: 3
score: 21
favorite count: 0
has title: Is there a simple example of using antlr4 to create an AST from java source code and extract methods, variables and comments?
has comment: http://stackoverflow.com/comment/32517822
has answer: http://stackoverflow.com/a/55845986
has comment: http://stackoverflow.com/comment/32517736
accepted answer: http://stackoverflow.com/a/21552478
type: AnsweredQuestion
downvote count: 2

http://stackoverflow.com/q/21530482
downvote count: 1
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21530544
tagged with: java
type: Question
tagged with: user-interface
answer count: 1
tagged with: layout-manager
favorite count: 0
accepted answer: http://stackoverflow.com/a/21530544
score: 0
has body: I've created a frame with inside two JPanel objects. This panel doesn't occupy all the space in a frame but only a part. I need they occupy equally the available space inside frame. container = frame.getContentPane(); matricepc = new JPanel(); matrice = new JPanel(); matrice.setLayout(new GridLayout(griglia.getRow(), griglia.getColumn())); matricepc.setLayout(new GridLayout(griglia.getRow(), griglia.getColumn())); container.add(matricepc,BorderLayout.NORTH); container.add(matrice,BorderLayout.SOUTH);
has title: Component size in JPanel
upvote count: 1
tagged with: swing

http://stackoverflow.com/a/21662201
score: 4
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32744214
has comment: http://stackoverflow.com/comment/32750875
type: Answer
upvote count: 4
downvote count: 0
answers question: http://stackoverflow.com/q/21654855
accepted answer of: http://stackoverflow.com/q/21654855
has body: Yes, the On Demand Router is the native load balancer for a WebSphere cell. Then you simply use the "weight" feature to control the distribution of requests. Setting Weight - In the admin console, go to "Servers > Clusters > [your cluster type] > [your cluster name]" then under the "Additional Properties" heading click "Cluster members". Set their "configured weight" to equal values and then ripplestart the cluster (or cycle individually). Note, "runtime weight" takes effect immediately but is reset to configured weight whenever the server is started. Requests are allocated by a simple formula: (weight of Member X) / (Sum of all member weights) so if server A has a weight of 20 and server B has a weight of 1, then server A should get 20 / (20+1) or 95.3% of all requests. In your case, just set them to the same weight.

http://stackoverflow.com/comment/34171865
type: QuestionComment
comment on: http://stackoverflow.com/q/21561755
type: Comment
has text: possible duplicate of [Eclipse crash on Fedora 20](http://stackoverflow.com/questions/21134508/eclipse-crash-on-fedora-20)
score: 0

http://stackoverflow.com/a/21561395
has comment: http://stackoverflow.com/comment/32564961
downvote count: 0
type: Answer
score: 3
has comment: http://stackoverflow.com/comment/32565301
has comment: http://stackoverflow.com/comment/32565560
has comment: http://stackoverflow.com/comment/32565178
has comment: http://stackoverflow.com/comment/32565900
answers question: http://stackoverflow.com/q/21561344
has comment: http://stackoverflow.com/comment/32565139
has comment: http://stackoverflow.com/comment/32564794
has comment: http://stackoverflow.com/comment/32565679
has comment: http://stackoverflow.com/comment/32565455
has comment: http://stackoverflow.com/comment/32565131
has comment: http://stackoverflow.com/comment/32564717
has body: Static fields can not autowired. You cannot autowire or manually wire static fields in Spring. You'll have to write your own logic to do this . Try to remove static modifier from your variables. check this out UPDATE You could autowire the list of implementation objects as it follows. So inject the implementations to the factory to avoid have N @Autowired annotations
has comment: http://stackoverflow.com/comment/32565807
upvote count: 3

http://stackoverflow.com/q/21592485
possible better answer: http://stackoverflow.com/a/32729650
upvote count: 4
answer count: 2
has title: What causes the ClassCastException: java.util.TreeSet cannot be cast to java.lang.Comparable?
downvote count: 0
accepted answer: http://stackoverflow.com/a/21592621
has comment: http://stackoverflow.com/comment/32620634
has comment: http://stackoverflow.com/comment/32620824
favorite count: 0
has comment: http://stackoverflow.com/comment/32620798
type: AnsweredQuestion
tagged with: java
tagged with: treemap
tagged with: collections
has answer: http://stackoverflow.com/a/21592621
has body: So I'm trying to move all Strings of a certain length from a Collection of Strings (could either be a Set or a List) to a TreeMap and setting a Set of the characters in each String as the key for that String but the line map.put(keyRinger(word), word); throws java.lang.ClassCastException: java.util.TreeSet cannot be cast to java.lang.Comparable Map&lt;Set&lt;Character&gt;, String&gt; map = new TreeMap&lt;Set&lt;Character&gt;, String&gt;(); for (String words : words) { if (word.length() == length) { map.put(keyRinger(word), word); } } This is the keyRing method in case you're curious. private Set&lt;Character&gt; keyRinger(String current) { Set&lt;Character&gt; keyRing = new TreeSet&lt;Character&gt;(); for (int i = 0; i &lt; current.length(); i++) { char key = current.charAt(i); keyRing.add(key); } return keyRing; } So my question is what can I do to avoid this? I've read I need a Comparator or to implement Comparable but I don't know how to do that, and I think there might be a simpler solution (although perhaps not as efficient).
type: Question
has answer: http://stackoverflow.com/a/32729650
score: 4

http://stackoverflow.com/q/21578334
tagged with: struts2
score: 0
has body: I am returning an array list from my struts2 action class. When I an trying to access that Array list in my JavaScript file through JSON, I am getting "Uncaught TypeError: Cannot read property 'length' of undefined". in below line json.EmpListByOffsetAndLength See my code below. I want to display data that is in arraylist into the table in my jsp page. alert(url); $.ajax({ type : "POST", cache : false, url : url, success : function(json) { var table = document.getElementById("tablereload"); var rowCount = document.getElementById("tablereload").rows.length; alert("this is row count" +rowCount); $("#test").html(''); $.each(json.EmpListByOffsetAndLength, function(index, value) { var row = table.insertRow(rowCount); var i = 0; for ( var key in value) { var val = value[key]; alert(val); var cell = row.insertCell(i); var div = document.createElement('div'), // create // DIV // element txt = document.createTextNode(val); // create // text // node div.appendChild(txt); cell.appendChild(div); i++; } }); } })
has answer: http://stackoverflow.com/a/21578441
has answer: http://stackoverflow.com/a/21578562
answer count: 4
has answer: http://stackoverflow.com/a/21594791
has comment: http://stackoverflow.com/comment/32595289
type: UnansweredQuestion
tagged with: java
tagged with: http://stackoverflow.com/tag/json
linked to: http://stackoverflow.com/q/8369467
has comment: http://stackoverflow.com/comment/32594936
type: Question
has title: Uncaught TypeError: Cannot read property 'length' of undefined while accessing arraylist through Json Object
has answer: http://stackoverflow.com/a/21578532
tagged with: javascript
tagged with: jquery

http://stackoverflow.com/comment/120802040
has text: Someone give this person a trophy please ! You saved me from hours of mindless scanning through imports between two different test classes. Thanks !
comment on: http://stackoverflow.com/a/61594494
type: AnswerComment
score: 4
type: Comment

http://stackoverflow.com/comment/32513064
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21528846
has text: Can you please eloborate? Questions seems to be a little confusing. some code will help.
score: 0

http://stackoverflow.com/comment/32587438
type: Comment
type: QuestionComment
has text: check `showLoadingDialog` in `BaseActivity`
score: 0
comment on: http://stackoverflow.com/q/21573863

http://stackoverflow.com/q/21607752
has answer: http://stackoverflow.com/a/21607931
has comment: http://stackoverflow.com/comment/32646486
has body: I know this is silly question,but I am confused,and this is the best site where I find the perfect answers There is toString method in object class,,whereas there is a toString method in each primitive wrapper classes also.one is with Static keyword,other is not.What is done there?overloading or overriding ? In short,I mean to say,can we add static modifier to overridden classes? or tostring method in primitive wrapper classes are different to the toString method in object class
score: -2
tagged with: overriding
has comment: http://stackoverflow.com/comment/32646577
answer count: 3
upvote count: 0
has answer: http://stackoverflow.com/a/48390611
accepted answer: http://stackoverflow.com/a/21607992
has comment: http://stackoverflow.com/comment/32647095
favorite count: 0
possible better answer: http://stackoverflow.com/a/21607931
has comment: http://stackoverflow.com/comment/32646536
has answer: http://stackoverflow.com/a/21607992
has title: confused about toString method in object and Wrapper classes
type: AnsweredQuestion
tagged with: overloading
tagged with: java
downvote count: 2
has comment: http://stackoverflow.com/comment/32646508
type: Question

http://stackoverflow.com/comment/32708763
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21642905
has text: Nope defiantly `import org.eveything` - the name of the library/jar file is irrelevent
score: 0

http://stackoverflow.com/comment/32570348
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21564278
has text: http://stackoverflow.com/questions/316352/why-would-one-mark-local-variables-and-method-parameters-as-final-in-java duplicate This allows compiler optimisation as well as useful warnings if you try to modify the reference. You should certainly do this, and turn on the setting in your IDE that does it for you automatically.
score: 1

http://stackoverflow.com/comment/32638135
score: 0
comment on: http://stackoverflow.com/q/21598881
type: Comment
has text: @Sand just read on the raw socket stream char/byte wise. No need of BufferedReader.
type: QuestionComment

http://stackoverflow.com/q/21576333
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32595891
has comment: http://stackoverflow.com/comment/32591419
answer count: 0
tagged with: java
type: Question
has body: I have a table (let's call it Animal) and I want to create a new backup table (Animal_backup) that has the same attributes of Animal. I want to be sure that if I add an attribute in Animal the same attribute is added in Animal_backup too. I can't extend Animal in Animal_backup because any entry of Animal_backup will also added in Animal I need to keep them separated. The only idea I had so far is to create an interface that must be implemented by Animal and Animal_backup but I'm not sure is the best way to handle it. Also, I have some other tables that extend Animal (Cat,Dog,etc) and I need to backup them too, (Cat_backup,Dog_backup,etc) so I would also have to create other interfaces for them too. Any ideas?
has title: Creating A Backup Table Without Duplicating It
score: 0
tagged with: backup
has comment: http://stackoverflow.com/comment/32591414

http://stackoverflow.com/comment/32629613
type: QuestionComment
has text: I'm not working in a single-client, single-thread environment, so the only actual and reliable way to know if the content has been update is by querying remote source. However, I may assume (a strong assumption) that the operation will be recorded in 2-3 seconds.
comment on: http://stackoverflow.com/q/21597264
score: 0
type: Comment

http://stackoverflow.com/comment/32688354
comment on: http://stackoverflow.com/q/21631760
has text: @Harold_Seiner What is sc?
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/32586784
score: 0
comment on: http://stackoverflow.com/q/21573450
has text: Have you seen this [tutorial](http://docs.oracle.com/javaee/6/tutorial/doc/gmhal.html) or [this one](http://docs.oracle.com/javaee/7/tutorial/doc/servlets011.htm)?
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32705712
comment on: http://stackoverflow.com/q/21638936
score: 0
has text: *"What am I missing?"* Information needed to debug this. What is the source of the HTML in which you see this problem? At what link can we visit the HTML?
type: Comment
type: QuestionComment

http://stackoverflow.com/a/51223682
type: Answer
has body: Slick Util is in Maven but in separate repository - Clojars not Central. See here. What you need is to add this into your pom.xml: clojars http://clojars.org/repo/ slick-util slick-util 1.0.0
answers question: http://stackoverflow.com/q/21541215
score: 0

http://stackoverflow.com/comment/32744708
has text: I do not know how to define `Factorial` or `Fibonacci<Integer>` in Java, for example.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21663627

http://stackoverflow.com/comment/32746214
type: Comment
has text: You can get the default value, but the simplest and correct answer is Kuba's
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21664439

http://stackoverflow.com/a/21519868
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/21519532
answers question: http://stackoverflow.com/q/21519532
type: Answer
has body: You need to add the classpath to the javac command. Something like javac -cp . p1/p2/event/Event.java
score: 0
upvote count: 1
downvote count: 1

http://stackoverflow.com/q/21559779
has comment: http://stackoverflow.com/comment/33167455
has comment: http://stackoverflow.com/comment/33233229
tagged with: grid
tagged with: path-iterator
has body: The premise I am randomly generating a two-dimensional mazelike structure. It boils down to randomly generating a bunch of rooms in the grid, then randomly connecting these rooms with corridors using A*. The rooms have walls that take up an entire square in the grid. The issue I'm having is with the creation of these walls. To decide where to put the randomly generated rooms, I start off dividing the grid in a bunch of rectangular cells of varying sizes, these cells are adjacent to eachother, using cells with size 1 to fill up the remaining gaps between them. After that, I select a random bunch of these cells to end up as rooms. If any of the selected cells are adjacent to eachother, they are combined to form a single room. Up to this point, the algorithm works perfectly. Example The issue The issue I am having is when I want to iterate through every square defining the wall of one of the rooms. What happens now is, I create an Area for each room, and add every cell required to that room's Area. I successfully used the PathIterator to iterate through the Area's outline. The only problem is that the result of that iterator is not the result I want. For example, suppose a rectangle with coördinate (5, 5), and size (4, 6). The resulting points I would want to iterate over are the following: Line 1 from (5, 5) to (8, 5) Line 2 from (8, 5) to (8, 10) Line 3 from (8, 10) to (5, 10) Line 4 from (5, 10) to (5, 5) Instead, I end up with the following: Line 1 from (5, 5) to (9, 5) Line 2 from (9, 5) to (9, 11) Line 3 from (9, 11) to (5, 11) Line 4 from (5, 11) to (5, 5) In other words, every line that can be considered to be above or to the left of the inside of the Area, are inclusive to the Area, and every line considered below or to the right of the Area, are exclusive to the Area (as returned by the Area.contains function). Now fixing this may seem trivial when dealing with simple squares, but once I started trying to fix this for an Area in general, all sorts of annoying…
type: Question
tagged with: algorithm
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32565816
upvote count: 1
favorite count: 0
tagged with: area
has title: Java PathIterator - How do I find the correct perimeter of an area?
type: UnansweredQuestion
answer count: 0
downvote count: 0

http://stackoverflow.com/a/21601919
upvote count: 4
has comment: http://stackoverflow.com/comment/32636318
downvote count: 0
score: 4
type: Answer
has comment: http://stackoverflow.com/comment/32636243
answers question: http://stackoverflow.com/q/21601854
has body: You can't cast a String to a Double; you have to convert the value. Casting means telling the JVM that an object known to be of one supertype is really an object of a subtype, and that's not the case here. Instead, your code that knows the value is a String and wants it to be a Double needs to use `Double.valueOf(stringVariable).

http://stackoverflow.com/comment/32596182
comment on: http://stackoverflow.com/q/21578953
score: 1
has text: Dumping the whole code and asking us to solve it is not a good way to ask questions here. Post only the relevant code.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32527750
type: AnswerComment
comment on: http://stackoverflow.com/a/21535965
type: Comment
has text: At this point you probably want to create a new class since your anonymous inner class is getting a bit on the long side.
score: 1

http://stackoverflow.com/a/21651003
answers question: http://stackoverflow.com/q/21650153
accepted answer of: http://stackoverflow.com/q/21650153
has body: You may be not copying your Mysql connector.jar inside WEB-INF/lib folder
type: AcceptedAnswer
score: 0
type: Answer

http://stackoverflow.com/a/21557598
has body: I will explain it based on the [Java Language Specification] : A return statement is defined as : ReturnStatement: return Expressionopt ; A return statement with an Expression attempts to transfer control to the invoker of the method that contains it; the value of the Expression becomes the value of the method invocation ... execution of such a return statement first evaluates the Expression. What's an expression: An expression is a construct made up of variables, operators, and method invocations, which are constructed according to the syntax of the language, that evaluates to a single value return (subTree(t1.left, t2) || subTree(t1.right, t2)); Let's de-construct it: return Expression; //Statement Expression : (subTree(t1.left, t2) || subTree(t1.right, t2)) As already said - an expression is made up of method invocations , operators, etc - subTree (Result of Method Invocation subtree) Logical Operator (Result of Method Invocation subtree) The resulting would be the value of the evaluation of the Expression.
answers question: http://stackoverflow.com/q/21556993
score: 0
type: Answer

http://stackoverflow.com/comment/32747937
comment on: http://stackoverflow.com/q/21665300
score: 0
type: Comment
type: QuestionComment
has text: If you tried maybe. But usually server only answer to his clients, not wice wersa.

fxml
tags question: http://stackoverflow.com/q/21619271
tag name: fxml
type: Tag

http://stackoverflow.com/a/21652519
has comment: http://stackoverflow.com/comment/32725150
answers question: http://stackoverflow.com/q/21652483
score: 0
has body: You could create an array String[], sort it, and print the middle value: String[] strings = { str1, str2, str3 }; Arrays.sort(strings); System.out.println(strings[1]);
has comment: http://stackoverflow.com/comment/32725653
type: Answer

http://stackoverflow.com/comment/32697953
score: 0
has text: http://s29.postimg.org/dnfm8fgkn/Screen_Shot_2014_02_07_at_3_09_47_PM_2.png No `R.java`
type: AnswerComment
comment on: http://stackoverflow.com/a/21636198
type: Comment

http://stackoverflow.com/comment/32594425
type: QuestionComment
comment on: http://stackoverflow.com/q/21577697
has text: Could you post, how you get now ?
score: 0
type: Comment

http://stackoverflow.com/comment/32549002
type: Comment
type: QuestionComment
has text: Well what did you expect to happen? You are opening a JavaScript dialog that Selenium doesn't expect to be there.
comment on: http://stackoverflow.com/q/21553052
score: 0

http://stackoverflow.com/q/21567139
score: 0
has comment: http://stackoverflow.com/comment/32575826
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32575688
has comment: http://stackoverflow.com/comment/32575716
tagged with: java
has comment: http://stackoverflow.com/comment/32576081
has comment: http://stackoverflow.com/comment/32575746
type: Question
has answer: http://stackoverflow.com/a/21567517
has answer: http://stackoverflow.com/a/21567314
has comment: http://stackoverflow.com/comment/32575781
tagged with: class
has title: Writing Java constructor for child class that takes parent object
answer count: 3
has comment: http://stackoverflow.com/comment/32575913
has answer: http://stackoverflow.com/a/21567214
tagged with: parent
has body: Is it possible to use a parent object to instantiate a child object? The class Length2 extends Length1 with the addition of an instance variable. Common I tried to make a copy constructor that takes the Length1 as a param and sets the extra ivar to 0, but I'm still being told I cannot convert from Legnth1 to Length2. I suppose there may be some implicit casting taking place... have a look. public class Length1 extends Length implements Comparable&lt;Length1&gt;{ protected int miles; protected int yards; public Length1(){ //default constructor miles = 0; yards = 0; } public Length1(int m, int y){ //constructor miles = m; yards = y; } public void setYards(int x){ yards = x; } public void setMiles(int x){ miles = x; } public int getYards(){ return yards; } public int getMiles(){ return miles; } ... public class Length2 extends Length1 { protected int feet; public Length2(){ //default constructor super(0,0); setFeet(0); } public Length2(int m, int y, int f){ // constructor super(m,y); setFeet(f); } public Length2(Length1 x){ super(x.miles,x.yards); setFeet(0); } public void setFeet(int x){ feet = x; } public int getFeet(){ return feet; } ... public class LengthTest{ public static void main(String[] args) { Length1 a,b,c,d,e,f; Length2 g,h,i,j; a = new Length1(78,1610); b = new Length1(77,1694); c = new Length1(); d = new Length1(); g = new Length2(32,1022,1); h = new Length2(31,1700,2); i = new Length2(); j = new Length2(); j = c; //problem occurs here } }
tagged with: constructor

http://stackoverflow.com/a/21591937
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/21591783
has body: If you're using stock API classes (no methods to override or implement), there isn't a huge need to create individual files for each. Typically new class files are only created when you new to define a new class or extend an existing one. It seems the ArrayAdapterClass extends an Activity. An Activity is an individual app screen. You would typically move between Activities by using an Intent. It seems that your MainActivity has no way to start the ArrayAdapterClass.
answers question: http://stackoverflow.com/q/21591783
has comment: http://stackoverflow.com/comment/32638976
score: 0

http://stackoverflow.com/comment/32594998
type: QuestionComment
has text: It's entirely possible that you *don't* have to live with that, which is why I was asking for more information. I still don't see why you can't even tell us the basic information about how the data is stored and how you're reading it. But hey...
comment on: http://stackoverflow.com/q/21557159
score: 0
type: Comment

http://stackoverflow.com/q/21677275
has comment: http://stackoverflow.com/comment/32768241
has answer: http://stackoverflow.com/a/21677496
type: Question
accepted answer: http://stackoverflow.com/a/21677496
score: 3
has comment: http://stackoverflow.com/comment/32767903
has comment: http://stackoverflow.com/comment/32768209
downvote count: 0
answer count: 1
has body: Is anybody know how Spring loads DispatcherServlet and passes WebApplicationContext instance to DispatcherServlet constructor? Where that magic happens specifically?
favorite count: 0
has title: How Spring passes instance of WebApplicationContext to DispatcherServlet constructor?
tagged with: spring
type: AnsweredQuestion
upvote count: 3
tagged with: java

http://stackoverflow.com/q/21553493
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21554811
possible better answer: http://stackoverflow.com/a/21553795
has title: Search list of unique _id as String in mongoDB with find()
score: 0
tagged with: mongodb
answer count: 2
has body: I would like to find a list of different values with unique _id but the problem is that they are saved as String and if I try to search f.e 10 it finds me also 100, 101, 102 etc.. In my case { "_id" : { "$gte" : "10" , "$lte" : "15"}} I would like to find 10, 11, 12, 13, 14, 15. But it finds me also 100, 110, 120 etc.. Thanks for your help
has answer: http://stackoverflow.com/a/21553795
accepted answer: http://stackoverflow.com/a/21554811
type: AnsweredQuestion

http://stackoverflow.com/comment/32597401
type: AnswerComment
type: Comment
has text: Yes, I agree! The point is, that the OPs code doesn't even make sense at all. So, I'm not sure which solution fits the best for the OPs real problem. Just wanted to show up another possibility.
score: 1
comment on: http://stackoverflow.com/a/21578725

surfaceview
tags question: http://stackoverflow.com/q/21647770
tags question: http://stackoverflow.com/q/21597996
type: Tag
tag name: surfaceview
tags question: http://stackoverflow.com/q/21651542

http://stackoverflow.com/comment/32566977
comment on: http://stackoverflow.com/a/21556077
has text: Great ! I will try it. The cluster I am working with is not sharded, so it should not be a problem.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/21521172
upvote count: 1
has body: In your for loop the createRow is trashing the row that you created before. So, before the loop, when you do Cell c2=ws.createRow(1).createCell(1); change this so that the Row object is saved. Row r = Cell c2=ws.createRow(1); r.createCell(1); and use r in your loop too.
type: Answer
answers question: http://stackoverflow.com/q/21521123
downvote count: 0
score: 1

http://stackoverflow.com/q/21522032
has body: I am trying to learn multi-threading in java. I wrote this sample code, to get a random number and exit if the number is positive integer. Here I am using synchronized just to check how it works. Since the method gererateRandom() is synchronized my expectation is that only one thread is allowed to go inside the function. Although there is no shared variable I am just checking how it works. The program is working fine, but what I am expecting is, as the thread gets a positive number it should exit the program and other threads should be blocked. But the result I am getting is completely different. Please check the result section below the code. import java.util.Random; public class CheckNumbnerThread implements Runnable{ Thread t; int n ; CheckNumbnerThread() { t = new Thread(this); System.out.println("Child thread: " + t); t.start(); // Start the thread } @Override public void run() { gererateRandom(); } public synchronized int gererateRandom(){ Random rn = new Random(); n = rn.nextInt() % 100; System.out.println("The random number generated is " + n); if (n &gt; 0){ System.exit(0); } return n; } } public class DemoThread { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int counter = 0; while(true){ new CheckNumbnerThread(); counter++; System.out.println("Thread counter " + counter); } } } Child thread: Thread[Thread-0,5,main] Thread counter 1 Child thread: Thread[Thread-1,5,main] The random number generated is 79 Thread counter 2 Child thread: Thread[Thread-2,5,main] The random number generated is 27 Thread counter 3 Child thread: Thread[Thread-3,5,main] The random number generated is -7 Thread counter 4 Child thread: Thread[Thread-4,5,main] The random number generated is -68 Thread counter 5 Child thread: Thread[Thread-5,5,main] The random number generated is 20 Thread counter 6 Child thread: Thread[Thread-6,5,main] The random number generated is 67 Thread counter 7 Child thread: Thread[Thread-7,5,main] The random …
tagged with: java
has comment: http://stackoverflow.com/comment/32496052
has answer: http://stackoverflow.com/a/21522159
type: Question
has title: Explainanton needed for multithreded java program execution
answer count: 2
score: -2
tagged with: synchronized
favorite count: 0
has answer: http://stackoverflow.com/a/21522110
downvote count: 2
upvote count: 0
has comment: http://stackoverflow.com/comment/32495285
tagged with: multithreading
accepted answer: http://stackoverflow.com/a/21522159
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21522110

http://stackoverflow.com/a/21632431
type: Answer
has body: Your understanding is wrong, but not by much. The names of the errors pretty much indicate their nature. A compile time error occurs when you compile code. Compiling means converting text into bytecode. This means that your java code can not be converted into bytecode. Compile time errors generally check for syntax, although the Java compiler does some very rudimentary logic checks as well. For example, it does not allow you to compile code with unreachable statements. A runtime error occurs when you run the program. This is when the JVM is actually trying to execute your compiled bytecode and runs into a problem. There is no step in which the bytecode gets converted directly into machine code. Bytecode is interpreted directly by the JVM. As you indicated, these problems can be things like division by zero and other undefined operations, running out of memory, or sometimes trying to cast objects into illegal types. These are just examples. Anything that prevents bytecode from executing is considered a runtime error.
has comment: http://stackoverflow.com/comment/32690925
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/32690408
has comment: http://stackoverflow.com/comment/32691240
downvote count: 0
answers question: http://stackoverflow.com/q/21632281
has comment: http://stackoverflow.com/comment/32691883

http://stackoverflow.com/a/21613922
answers question: http://stackoverflow.com/q/21612287
score: 1
has comment: http://stackoverflow.com/comment/32665337
upvote count: 1
has comment: http://stackoverflow.com/comment/32665119
type: Answer
downvote count: 0
has body: Just for fun: from itertools import combinations_with_replacement from operator import mul my_integer = 20 factorizations = {t for t in {list(t).remove(1) if 1 in t and len(t)&gt;2 else t if len(t)&gt;1 else None for combo in [combinations_with_replacement(factors(my_integer), n) for n in xrange(len(factors(my_integer)))] for t in combo if reduce(mul, t, 1) == my_integer} if t} print factorizations set([(4, 5), (2, 2, 5), (1, 20), (2, 10)])

http://stackoverflow.com/q/21606800
accepted answer: http://stackoverflow.com/a/21607369
has comment: http://stackoverflow.com/comment/32644880
tagged with: substring
has title: String equality using replace and substring methods
has answer: http://stackoverflow.com/a/21606873
tagged with: replace
linked to: http://stackoverflow.com/q/513832
has body: I have some questions about string comparison.I couln't find any answers concerning replace and substring methods in particular.So here is the code public static void main(String args[]) { if ("hello".substring(0) == "hello") System.out.println("statement 1 is true"); if ("hello".substring(1) == "ello") System.out.println("statement 2 is true"); if ("hello".replace('l', 'l') == "hello") System.out.println("statement 3 is true"); if ("hello".replace('h', 'H') == "Hello") System.out.println("statement 4 is true"); if ("hello".replace('h', 'H') == "hello".replace('h', 'H')) System.out.println("statement 5 is true"); } The output is: statement 1 is true statement 3 is true Does the substring method create a new String().If so why is statement one true,yet 2 is not?Same question goes about statement 3 and 4.Thank you.
type: AnsweredQuestion
tagged with: compare
tagged with: string
has answer: http://stackoverflow.com/a/48603657
type: Question
has answer: http://stackoverflow.com/a/21607369
has comment: http://stackoverflow.com/comment/32645087
tagged with: java
has comment: http://stackoverflow.com/comment/32644867
score: 0
possible better answer: http://stackoverflow.com/a/21606869
has answer: http://stackoverflow.com/a/21606869
answer count: 4

http://stackoverflow.com/a/21651381
answers question: http://stackoverflow.com/q/21650634
has body: One occasion where this delete/renameTo easily goes awry, is when the files are in use. A solution seen consists of using an additional lock file. Too complicated for such a simple thing. Using an embedded database, like java's own Derby, which is not that difficult. The database needs no extra provision. There are good tutorials with simple example code.
score: 1
upvote count: 1
downvote count: 0
type: Answer

http://stackoverflow.com/comment/32728838
comment on: http://stackoverflow.com/q/21654479
type: Comment
type: QuestionComment
has text: No, definitely don't use null. If this code is *in* the JFrame derived class, then either use `this`, or if the JOptionPane is displayed within an *inner* class, then use `OuterClassName.this`. And again, get rid of the static modifier.
score: 0

drupal
type: Tag
tags question: http://stackoverflow.com/q/21615850
tag name: drupal

http://stackoverflow.com/comment/32546576
type: QuestionComment
score: 1
has text: Indeed the advice in that link is the least bad; reverse engineer the entities new from the database schema and then manually go through them to fix all the annotations to what you need them to be. Its boring work, but nobody ever said that programming was all fun and games.
comment on: http://stackoverflow.com/q/21548945
type: Comment

http://stackoverflow.com/comment/32762589
type: Comment
score: 0
has text: No i didn't, there is just the listview background
type: AnswerComment
comment on: http://stackoverflow.com/a/21674161

http://stackoverflow.com/comment/32732850
type: Comment
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/21656912
has text: ... or a declared method name for your painting method. And you're trying to read in a file inside of a paint method -something you should never do. Please if you have code that won't compile, do post your compilation errors. Don't make us guess.

http://stackoverflow.com/comment/32701329
comment on: http://stackoverflow.com/q/21638529
score: 0
type: Comment
type: QuestionComment
has text: If anyone can send mail, you may create a class `Human` with method `sendMail()` and make `Doctor` and `Postman` herit from it...

http://stackoverflow.com/a/21546390
has body: If you want to try the DIY way, you can place a startup script in your /etc/init.d directory as said here. http://www.ghacks.net/2009/04/04/get-to-know-linux-the-etcinitd-directory/ However, to implement a clean yourScript stop command, I would recommend that you split your functionality into a launcher and a daemon, and make your launcher able to start or communicate with your existing daemon in order to send orders to it. Then your startup script would only invoke your launcher, which in its turn would start a new daemon, or send orders to the existing one.
answers question: http://stackoverflow.com/q/21546278
score: 3
has comment: http://stackoverflow.com/comment/32540252
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/58484793
has comment: http://stackoverflow.com/comment/32540174
upvote count: 3

http://stackoverflow.com/comment/32598187
type: Comment
has text: Maybe it's before the space I added, since it's a zero-width character.
comment on: http://stackoverflow.com/a/21580087
type: AnswerComment
score: 0

http://stackoverflow.com/a/21571694
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/21571503
upvote count: 1
type: Answer
has body: ListNodes is indeed the name of the class, and also of it's instantiated objects. "Next" simply refers to the next ListNodes in the chain, and is thus of the type ListNodes. I do NOT like how the class name is in plural, by the way. ptr is kept as a reference to the ListNodes (again, aaaaaaargh with the plural!) we are currently pointing at, as we are swooping through the list. So the first thing we do in this method is to set ptr to ptr_start, as ptr_start is the first ListNodes in the list, and we want to start counting from the very beginning. Then what happens is we keep moving ptr onward one step at a time, for as long as there are new nodes to visit.

http://stackoverflow.com/a/21576300
downvote count: 0
has comment: http://stackoverflow.com/comment/32644299
accepted answer of: http://stackoverflow.com/q/21573636
has body: It seems that your schema is invalid because it uses regular expressions that are not permitted by the XSD specification. There are some (so-called) XSD processors that allow non-standard regular expressions; I believe one such is the Microsoft schema processor. You have only two options: modify the schema to be conforming, or use a schema processor that implements the proprietary extensions used in the schema. If the schema is indeed an "official European Union XSD" then: (a) I'm surprised you are not allowed to disclose it (b) you have every reason to complain that the EU is doing something that doesn't comply with open standards.
answers question: http://stackoverflow.com/q/21573636
upvote count: 2
has comment: http://stackoverflow.com/comment/32602349
has comment: http://stackoverflow.com/comment/32591897
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32646691
type: Answer
score: 2

http://stackoverflow.com/q/21523853
has comment: http://stackoverflow.com/comment/32498545
has comment: http://stackoverflow.com/comment/32498392
has comment: http://stackoverflow.com/comment/32498230
has comment: http://stackoverflow.com/comment/32498638
favorite count: 0
score: 0
tagged with: exception
has comment: http://stackoverflow.com/comment/32498370
has title: Java Index Out Of Bounds Exception ArrayList
has comment: http://stackoverflow.com/comment/32498494
has comment: http://stackoverflow.com/comment/32498154
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32498193
has comment: http://stackoverflow.com/comment/32498973
has comment: http://stackoverflow.com/comment/32498156
upvote count: 1
has answer: http://stackoverflow.com/a/27264535
downvote count: 1
has comment: http://stackoverflow.com/comment/32498423
type: Question
has answer: http://stackoverflow.com/a/21524084
tagged with: java
has comment: http://stackoverflow.com/comment/32498408
has answer: http://stackoverflow.com/a/21524162
has body: I made a class with an ArrayList that holds "Student" Objects and I have a toString method that prints the Students test scores,name,etc. But I keep getting "java.lang.IndexOutOfBoundsException: Index: 0, Size: 0" here is my code, if you need to see any more code just comment public class School2 { ArrayList &lt;Student2&gt; studentArray;// array of Student's /** * Constructor for School, creates an array of for ten Student's. */ public School2() { final int NUMSTUDENTS = 10; studentArray = new ArrayList &lt;Student2&gt; (NUMSTUDENTS); }// end constructor /** * Method adds a student 'newStudent' to the array of Student's. * @param newStudent - Student to be added */ public void add(Student2 newStudent) { studentArray.add(newStudent); }// end method /** * Method adds a Student whose name and test scores are passed in parameter. * @param name - name of newly added Student * @param tests - array of test scores belonging to newly added Student */ public void add(String name, ArrayList &lt;Integer&gt; testScores) { Student2 studentAdded = new Student2(name, testScores); studentArray.add(studentAdded); }// end method /** * Method adds a Student whose name is passed in parameter. * @param name - name of newly added Student */ public void add(String name) { Student2 studentAdded = new Student2(name); studentArray.add(studentAdded); }// end method /** * Method adds a Student whose name is an empty String and test scores are 0. */ public void add() { Student2 studentAdded = new Student2(); studentArray.add(studentAdded); }// end method /** * Method removes all Student object 's' from array of Student's * @param s - Student to be removed from array of Student's */ public void remove(Student2 s) { for (int i = 0; i &lt; studentArray.size(); i++) { if (studentArray.get(i) == s) { studentArray.remove(i); }// end if statement }// end for loop }// end method /** * Method removes the Student whose index is passed in the parameter * @param index - index at which the Student is locate…
answer count: 3
has comment: http://stackoverflow.com/comment/32498941

http://stackoverflow.com/comment/32609523
comment on: http://stackoverflow.com/q/21585925
has text: You might want to close the file to make sure everything's flushed.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32528158
type: QuestionComment
has text: I meant the what looks like trying to make a singleton bit that can somehow change types. How do you suppose calling `getInstance(Integer.class)` is going to work if you've already created and are trying to return a `Store<Float>` ?
comment on: http://stackoverflow.com/q/21539844
score: 0
type: Comment

http://stackoverflow.com/comment/32564683
type: AnswerComment
score: 0
has text: Im running it on a Nexus 7 at the minute which I think is ARM. But if I'm wanting this to run on a load of Android devices then surely it won't work. How else could I display text?
type: Comment
comment on: http://stackoverflow.com/a/21561248

http://stackoverflow.com/comment/32509151
has text: Run the code from my **UPDATE**. It works fine for me. No ClassCastException
type: Comment
comment on: http://stackoverflow.com/a/21525188
score: 0
type: AnswerComment

http://stackoverflow.com/q/21636647
type: Question
has answer: http://stackoverflow.com/a/21636756
accepted answer: http://stackoverflow.com/a/21636756
tagged with: for-loop
has comment: http://stackoverflow.com/comment/32697639
has comment: http://stackoverflow.com/comment/32697717
upvote count: 3
downvote count: 1
answer count: 1
favorite count: 0
has title: Statements outside for loop are not being executed
has comment: http://stackoverflow.com/comment/32697581
has body: I'm new to Java. I found a website called project eulder and was practicing on a problem. I don't understand why the following program does not display anything but when I put System.out.println(max); into the for loop it works but displaying all the prime numbers including the biggest. Who do I only the display the biggest prime number? public class LargestPrimeFactor { public static void main(String[] args) { long x = 600851475143L; int max = 0; for (int i = 1; i &lt;= x; i++) { if (x % i == 0) if (isPrime(i)) max = i; } System.out.println(max); } public static boolean isPrime(int n) { for (int i = 2; i &lt; n; i++) { if (n % i == 0) return false; } return true; } }
score: 2
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32697627
tagged with: java
tagged with: loops
tagged with: unreachable-code
has comment: http://stackoverflow.com/comment/32697501
has comment: http://stackoverflow.com/comment/32697686

http://stackoverflow.com/comment/32720172
comment on: http://stackoverflow.com/q/21647062
has text: I thought Online Judges do it all the time. Accept code in C. Then there must be a easy solution to the problem.
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/32752361
comment on: http://stackoverflow.com/q/21667750
has text: Yes, ` ` works fine, I'm going to use that. Please put that in an answer so I can accept it.
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/a/21558792
upvote count: 1
answers question: http://stackoverflow.com/q/21558677
has body: if (postcode.length() == 6) postcode = postcode.substring(0,5);
downvote count: 0
type: Answer
score: 1

http://stackoverflow.com/q/21580299
has comment: http://stackoverflow.com/comment/32598792
has comment: http://stackoverflow.com/comment/32599074
answer count: 1
has comment: http://stackoverflow.com/comment/32599886
favorite count: 0
tagged with: android
accepted answer: http://stackoverflow.com/a/21583568
has comment: http://stackoverflow.com/comment/32600443
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/32600511
has answer: http://stackoverflow.com/a/21583568
has comment: http://stackoverflow.com/comment/32598944
has body: Is it possible to create holes in an Android layout.I have two backgrounds, one normal, one blurred, and what I want to create cells that can display the blurred background. My XML would be constructed like this: Background_blurred > Background_normal > Cells. -I already know how to blur a background. -Cells are everywhere, like a GridView, and not just on the borders.
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/32598964
has comment: http://stackoverflow.com/comment/32598935
has comment: http://stackoverflow.com/comment/32599793
has comment: http://stackoverflow.com/comment/32599712
has comment: http://stackoverflow.com/comment/32598597
type: Question
upvote count: 2
has title: Dig holes in Android layouts

http://stackoverflow.com/q/21665366
has answer: http://stackoverflow.com/a/21665652
has title: Stack sorting between 3 stacks of Integers
answer count: 1
tagged with: sorting
score: 0
type: UnansweredQuestion
type: Question
tagged with: stack
tagged with: java
has body: What am I missing to complete the problem? the homework problem says: Suppose you have 3 stacks of integers, s1 (which has values in it), s2 (which is empty) and s3 (also empty). Write code to sort the entries in s1, using the algorithm given here (the sorted values will be in s2 at the end): At any point in time, s2 will hold entries in sorted order, with the smallest value at the top. Move the top entry of s1 to s2. Remove and consider the top entry t of s1. Remove entries of stack s2 and put them onto stack s3 until you reach the correct place to put t. Then put t onto s2. Next move all the entries from s3 to s2. my code so far: public class practice2 { public static void main(String[] args) { Stack&lt;Integer&gt; s1 = new Stack&lt;Integer&gt;(); Stack&lt;Integer&gt; s2 = new Stack&lt;Integer&gt;(); Stack&lt;Integer&gt; s3 = new Stack&lt;Integer&gt;(); s1.push(1); s1.push(61); s1.push(21); s1.push(31); s1.push(51); s1.push(111); s2.push(s1.pop()); while(!s1.isEmpty()) { if(s1.peek() &lt; s2.peek()) { s2.push(s1.pop()); } else { s3.push(s1.pop()); } } if(s2.peek() &lt; s3.peek()) { while(!s2.isEmpty()) { s1.push(s2.pop()); } } while(!s1.isEmpty()) { if(s1.peek() &gt; s3.peek()) { s2.push(s1.pop()); } else s2.push(s3.pop()); } } }

http://stackoverflow.com/a/21663098
type: AcceptedAnswer
score: 0
accepted answer of: http://stackoverflow.com/q/21662995
type: Answer
has body: You have to read the InputStream in the same order and same format which you write in the stream otherwise you would get OptionalDataException You have written the data in OutputStream in the order :- ImageIO.write(map, "png", out); out.writeInt(2 * mapWidth + 1); out.writeObject(encoded); And you are reading the stream in the order :- map = ImageIO.read(in); encoded = (byte[][]) in.readObject(); Just read the int after u read map.The correct code would be :- public void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException{ boxHeight = in.readInt(); boxWidth = in.readInt(); mapHeight = in.readInt(); mapWidth = in.readInt(); map = ImageIO.read(in); in.readInt();// you read this int and assign it to the object as you wish encoded = (byte[][]) in.readObject(); int tileSetSize = in.readInt(); for(int i = 0; i &lt; tileSetSize; i++){ tileSet.add(ImageIO.read(in)); } }
answers question: http://stackoverflow.com/q/21662995

http://stackoverflow.com/a/21574030
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/21573986
upvote count: 2
has body: Maybe because you need to use invokeLater() to start any Swing application. and e.getSource() will return the reference of the button on which the action happened. If you want so stick to that, then it should be == btn1 Plus, the rules of making an SSCCE state that you strip your code down to the required minimum. Why do you have the extra code when all you have implemented is listener for.one button ?
type: Answer

http://stackoverflow.com/comment/32500253
score: 0
type: AnswerComment
has text: Thank you soo much, it seems my ent file is corrupt it works with the one you provided
type: Comment
comment on: http://stackoverflow.com/a/21524851

http://stackoverflow.com/q/21578330
has comment: http://stackoverflow.com/comment/32595185
possible better answer: http://stackoverflow.com/a/21579305
answer count: 4
has comment: http://stackoverflow.com/comment/32594962
has answer: http://stackoverflow.com/a/21579305
has title: Simple math-to-english calculator
accepted answer: http://stackoverflow.com/a/21578624
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/21578428
type: Question
has answer: http://stackoverflow.com/a/21578624
has body: I'm currently taking a basic programming course. The teacher refuses to look at my code and attempts to guess the question I'm asking, and then answer that (incorrect) question. The basics of this is, it's supposed to take an equation, like 5 * 6, and output "Five times six equals 30," with the answer just being a number. The code I have right now is as such: package mainPackage; import java.util.*; public class Main { public static void main(String[]args) { Scanner scan = new Scanner(System.in); System.out.println("Please enter the equation"); String input = scan.nextLine(); String space = " "; int firstSpace = 0; int secondSpace = 0; int numInt1 = 0; int numInt2 = 0; String a = "0"; char b = 'a'; String c = "0"; firstSpace = input.indexOf(space); String sub = input.substring((firstSpace + 1), input.length()); secondSpace = sub.indexOf(space); a = input.substring(firstSpace--); b = input.charAt(firstSpace++); c = input.substring(secondSpace++); numInt1 = Integer.parseInt(a); numInt2 = Integer.parseInt(c); String num1 = ""; String op = ""; String num2 = ""; switch (numInt1) { case 0: { num1 = "Zero"; } case 1: { num1 = "One"; } case 2: { num1 = "Two"; } case 3: { num1 = "Three"; } case 4: { num1 = "Four"; } case 5: { num1 = "Five"; } case 6: { num1 = "Six"; } case 7: { num1 = "Seven"; } case 8: { num1 = "Eight"; } case 9: { num1 = "Nine"; } } System.out.println(a); System.out.println(b); System.out.println(c); } } She has told us that between each number and operand, she WILL put a space. So rather than 5/6, it would be 5 / 6, and that we only have to do it for 0 to 9, but still have to detect if she puts a two digit number, and print invalid number. This part I know how to do. The problem arises when I try to run this. No errors are showing up in the lines, but when I run it, I get this: Exception in thread "main" java.lang.NumberFormatException: For input string: " * 6" at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt…
score: 0
tagged with: exception
has answer: http://stackoverflow.com/a/21578748

http://stackoverflow.com/q/21633387
tagged with: selectionchanging
has title: Changing a specific line in a file from another one
has answer: http://stackoverflow.com/a/21634132
accepted answer: http://stackoverflow.com/a/21634132
score: 2
type: AnsweredQuestion
tagged with: java
type: Question
downvote count: 0
answer count: 1
tagged with: class
tagged with: text-files
favorite count: 0
has body: So, I have looked through just about every suggestion on this forum so far and none of them can really help me towards the answer that I need. Here is the my main code: I've left out the implements as this works fine. public class Management { private static int Price1 = 0; private static int Price2 = 0; public static void main(String[] args) { try { Scanner file = new Scanner(new File("friendsfile")); String s; while(file.hasNext()) { s = file.nextLine(); if(s.contains("House 1")) { Price1 = getPrice(s); } if(s.contains("House 2")) { Price2 = getPrice(s); } } Filewriter fw = new Filewriter(); fw.fileWriter(Price1,Price2); } catch(FileNotFoundException fnfe) { System.out.println("File not found"); } catch(Exception e) { System.out.println("HERE IS AN ERROR MATE!"); } } private static int getPrice(String s) { StringTokenizer st = new StringTokenizer(s,";"); st.nextToken(); int price1 = Integer.parseInt(st.nextToken().replace(" ","")); return price1; } } Now the Filewriter looks like this: public class Filewriter { public static void fileWriter(int price1, int price2) { System.out.println("Ye"); final String FILE_PATH = "housesfile"; final String MARKER_LINE1 = "price1"; final String TEXT_TO_ADD1 = "price1: "+price1; final String MARKER_LINE2 = "price2"; final String TEXT_TO_ADD2 = "price2: "+price2; List&lt;String&gt; fileLines = new ArrayList&lt;String&gt;(); Scanner scanner = null; try { scanner = new Scanner(new File(FILE_PATH)); while (scanner.hasNextLine()) { String line = scanner.nextLine(); fileLines.add(line); if (line.trim().equalsIgnoreCase(MARKER_LINE1)) { fileLines.add(TEXT_TO_ADD1); } if (line.trim().equalsIgnoreCase(MARKER_LINE2)) { fileLines.add(TEXT_TO_ADD2); } } } catch (FileNotFoundException e) { e.printStackTrace(); } finally { if (scanner != null) { scanner.close(); } } PrintWriter pw = null; try { pw = new PrintWriter(new File(FILE_PATH)); for (String line : fileLines) { pw.println(line); } } catch (FileNotFoundException e) { e.printStackTrace();…
upvote count: 2

http://stackoverflow.com/q/21653000
has comment: http://stackoverflow.com/comment/32726170
has title: Reading row of listview in android
type: UnansweredQuestion
tagged with: android
tagged with: java
has comment: http://stackoverflow.com/comment/35369348
has answer: http://stackoverflow.com/a/23133891
type: Question
has comment: http://stackoverflow.com/comment/32732095
score: 0
tagged with: android-listview
answer count: 1
has body: I am using custom adapter for listview. In row layout contains, two EditText view &amp; one image view. I want read value of EditText view on button action(which will be clicked at ending). When I manually write entries in edittext box, I am unable to call 'notifyDataSetChanged'. So only old values are set to adapter. Now at end, how to read current data directly from edittext view. Event editText.getText() also not working. It shows previous data, not modified data. Thank you in advance.
has comment: http://stackoverflow.com/comment/32726060

http://stackoverflow.com/comment/32682348
score: 0
comment on: http://stackoverflow.com/a/21627617
type: Comment
has text: but i only need to find them. if there is no words like "ora_pmon_sas", it should pass it.
type: AnswerComment

http://stackoverflow.com/comment/32582594
comment on: http://stackoverflow.com/a/21569669
type: AnswerComment
score: 0
type: Comment
has text: I just tried replacing the code in my openTEV() method with the two lines above to create a new activity with an intent. It's causing my app to close. I'm getting "FATAL EXCEPTION: main" in the LogCat. I've just realised I'll probably have to make a layout file to go with the new activity. Now I have no idea what sort of view to put in the XML file. Do I need a view at all in the second layout file?

batch-file
tags question: http://stackoverflow.com/q/21569352
tags question: http://stackoverflow.com/q/21546356
tags question: http://stackoverflow.com/q/21546388
tags question: http://stackoverflow.com/q/21539307
tag name: batch-file
type: Tag
tags question: http://stackoverflow.com/q/21634273
tags question: http://stackoverflow.com/q/21554671
tags question: http://stackoverflow.com/q/21538993
tags question: http://stackoverflow.com/q/21624741
tags question: http://stackoverflow.com/q/21576670
tags question: http://stackoverflow.com/q/21582724
tags question: http://stackoverflow.com/q/21609031

http://stackoverflow.com/comment/32765245
has text: What is your typical environment? The answer really depends on that..
score: 2
comment on: http://stackoverflow.com/q/21674683
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21535029
tagged with: java
has body: According to a comment from this post, hascode of null objects can throw NPE or a value of zero. This is implementation specific. but within the same implementation, why does Objects.hashcode and hascode(instance) return different values. for ex: public class EqualsTesting { public static void main(String[] args){ String p1 =null; String p2 = null; System.out.println(Objects.hashCode(p1)); System.out.println(p2.hashCode()); } } Output: 0 Exception in thread "main" java.lang.NullPointerException at BinaryTrees.EqualsTesting.main(EqualsTesting.java:14) If this is the case, will this not affect the key look-up in HashMap where null Key-value pairs are allowed. (It might either hash to bucket 0 or throw a NPE)
has answer: http://stackoverflow.com/a/72224003
has comment: http://stackoverflow.com/comment/32518657
answer count: 6
has answer: http://stackoverflow.com/a/21535194
possible better answer: http://stackoverflow.com/a/21535077
linked to: http://stackoverflow.com/q/11184041
has answer: http://stackoverflow.com/a/21535077
downvote count: 0
linked to: http://stackoverflow.com/q/17268212
accepted answer: http://stackoverflow.com/a/21535089
favorite count: 0
has comment: http://stackoverflow.com/comment/32518592
has comment: http://stackoverflow.com/comment/32518565
has comment: http://stackoverflow.com/comment/32526426
score: 14
type: AnsweredQuestion
upvote count: 14
has comment: http://stackoverflow.com/comment/32518585
has answer: http://stackoverflow.com/a/21535135
has title: what must be hashcode of null objects in Java?
has answer: http://stackoverflow.com/a/21535089
type: Question
tagged with: object
tagged with: hashmap
has answer: http://stackoverflow.com/a/67608658
tagged with: hashcode

http://stackoverflow.com/comment/32667733
score: 0
type: Comment
type: QuestionComment
has text: I copied and pasted the android-support-v4.jar into the libs folder where robotium is, but it's still has the same error about it not being found. Do I need to do something else?
comment on: http://stackoverflow.com/q/21619305

http://stackoverflow.com/a/21647543
downvote count: 0
answers question: http://stackoverflow.com/q/21647254
type: Answer
upvote count: 1
has body: Here's the split regex you want: String[] split = str.split(" +(?=[^&lt;]*(&lt;[^/]|$)");
score: 1

http://stackoverflow.com/comment/32760836
type: AnswerComment
has text: @BrunoLowagie The OP circumvented the bug from the referred-to [question](http://stackoverflow.com/questions/21018428/creating-pdf-a-3-embedded-file-shall-contain-valid-params-key) by making use of a byte[] instead of a file. His issue is triggered in a slightly different conformance test.
type: Comment
comment on: http://stackoverflow.com/a/21671620
score: 0

http://stackoverflow.com/q/21603105
answer count: 0
score: 1
upvote count: 1
has title: jme3 - Exported blender model throws "Num components must be between 1 and 4"
type: Question
has body: I created a model of a robot which has an armature and two animation actions in it, “walk” and “stand”. I exported this model with the latest blender2ogre exporter plugin (my Blender version is 2.69, plugin version is 0.6.0) like this: 1: Select the armature of my model: 2: Export it with the ogre plugin with these settings: 3: Result are the files “Robobob.mesh.xml” and “Robobob.skeleton.xml” (no errors). I added both to my assets, now when loading my model with the Asset-Manager, I get this exception: SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main] java.lang.IllegalArgumentException: Num components must be between 1 and 4 at com.jme3.scene.VertexBuffer.createBuffer(VertexBuffer.java:907) at com.jme3.scene.Mesh.extractVertexData(Mesh.java:1176) at com.jme3.scene.plugins.ogre.MeshLoader.compileModel(MeshLoader.java:776) at com.jme3.scene.plugins.ogre.MeshLoader.load(MeshLoader.java:892) at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:288) at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:374) at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:378) at de.my.game.MyGame.makePlayer(MyGame.java:59) at de.my.game.MyGame.simpleInitApp(MyGame.java:43) at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226) at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130) at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207) at java.lang.Thread.run(Unknown Source) Is this the right way of exporting and does anyone have an idea whats wrong with my model? Thanks in advance! :)
tagged with: blender
tagged with: java
tagged with: 3d
downvote count: 0
tagged with: jmonkeyengine
favorite count: 0
tagged with: model
type: UnansweredQuestion

http://stackoverflow.com/comment/34360175
type: Comment
has text: Yes, improved support for reading existing MIDI files is something I've been working hard towards in writing JFugue 5. Glad you found your answer!
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/21535794

http://stackoverflow.com/comment/32701248
score: 0
type: Comment
has text: And about how to show them? Do I have to add _final int state_enclosure_ and in _public vois chatacter()_ method add this: _case state_enclosure: item.setEnclosure(strCharacters); break;_ ; case state_title: feed.setTitle(strCharacters); break;
comment on: http://stackoverflow.com/a/21638468
type: AnswerComment

http://stackoverflow.com/q/21574076
downvote count: 0
has answer: http://stackoverflow.com/a/21620456
favorite count: 0
has title: How can we do our own Certificate Verification Step in HTTPS
possible better answer: http://stackoverflow.com/a/21620456
tagged with: https
type: Question
score: 2
type: AnsweredQuestion
has body: I need to put my own certificate verification step in SSL Handshake when making an HTTPS connection with HttpsURLConnection. I have written my own certificate verification code to verify some property in the host certificates say Certificate Revocation Status using Online Certificate Status Protocol. What is the proper way to include this step in Java. I can add it as a part of the default HostNameVerifier as follows but is there a proper way to do this? HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { HostnameVerifier verifier = HttpsURLConnection.getDefaultHostnameVerifier(); public boolean verify(String s, SSLSession sslSession) { return verifier.verify(s, sslSession) &amp;&amp; MyVerifier.doMyVerification(sslSession); } });
tagged with: java
tagged with: ssl
has answer: http://stackoverflow.com/a/21620024
accepted answer: http://stackoverflow.com/a/21620024
upvote count: 2
answer count: 2
tagged with: certificate-revocation
tagged with: ocsp

http://stackoverflow.com/comment/32562663
has text: thanks guys for the answers , the original of this code was : jObj = new JSONObject(json); } catch (JSONException e) { Log.e("JSON Parser", "Error parsing data " + e.toString()); I I took it from the forum for the substring...
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21560164

http://stackoverflow.com/comment/32575746
score: 0
type: QuestionComment
has text: Is there a work-around where I could write a method to cast the object? I only need the two ivars contained in the L1 object to be copied to the L2 object. Yes I know that it doesn't make much sense practically :/
type: Comment
comment on: http://stackoverflow.com/q/21567139

http://stackoverflow.com/q/21571367
answer count: 1
downvote count: 1
has title: Convert JsonObject into String using Java
tagged with: java
tagged with: http://stackoverflow.com/tag/json
type: UnansweredQuestion
has body: I am getting some values from mongodb via Java Spring API. For sofTagList as in image below, I am getting List&lt;JsonObject&gt; for that. I am trying to access the value field inside tagName. When I itereate the list, I am getting null values each and every time. I tried googling and convert that JsonObject to String. But that doesn't help me to solve my issue. I am using com.google.gson.JsonObject package. Here is the screen shot of my mongodb which I am trying to access. Edit 1: Added code Snippet. if(null!=person.getSofTagList()){ List&lt;JsonObject&gt; jsonObj = person.getSofTagList(); System.out.println("Size is ========&gt;&gt; "+ jsonObj.size()); for (JsonObject jsonObject : jsonObj) { System.out.println("GetTag Name "+jsonObject.getAsJsonObject("tagName")); } } When printing size I am getting 30 as shown in image. It loops for 30 times in for loop but all time null is the output. Hope my question is clear. Thanks in advance.
tagged with: mongodb
score: 2
favorite count: 0
has comment: http://stackoverflow.com/comment/32583053
type: Question
has comment: http://stackoverflow.com/comment/32582970
has comment: http://stackoverflow.com/comment/32583145
has answer: http://stackoverflow.com/a/21571478
upvote count: 3
tagged with: gson

http://stackoverflow.com/comment/32765006
type: Comment
has text: @AlexeiKaigorodov: No, they'll be taken from the cache anyway. Just the CPU will have to ensure that the cache is in sync with main memory, but this is cheap when not contended. The times will still differ.
comment on: http://stackoverflow.com/a/21672251
type: AnswerComment
score: 0

http://stackoverflow.com/q/21523357
score: 8
linked to: http://stackoverflow.com/q/20988152
has title: Java TimeUnit.MILLISECONDS.toDays() gives wrong result
tagged with: java
answer count: 5
tagged with: date
has comment: http://stackoverflow.com/comment/32497428
has answer: http://stackoverflow.com/a/21523724
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21523567
downvote count: 0
linked to: http://stackoverflow.com/q/9235845
favorite count: 0
has comment: http://stackoverflow.com/comment/32497247
upvote count: 8
type: Question
has answer: http://stackoverflow.com/a/79078822
accepted answer: http://stackoverflow.com/a/21523724
has answer: http://stackoverflow.com/a/21523725
has body: I'm trying to calculate the difference between two days in amount of days. For some reason comparing 01-03-2013 and 01-04-2013 gives the result 30, as does comparing 01-03-2013 and 31-03-2013 Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(2013, Calendar.MARCH, 1); Date start = cal.getTime(); cal.set(2013, Calendar.APRIL, 1); Date end = cal.getTime(); long days = TimeUnit.MILLISECONDS.toDays(end.getTime() - start.getTime()); System.out.println("!!! Amount of days : " + String.valueOf(days)); &gt;&gt; 30 cal.set(2013, Calendar.MARCH, 1); start = cal.getTime(); cal.set(2013, Calendar.MARCH, 31); end = cal.getTime(); days = TimeUnit.MILLISECONDS.toDays(end.getTime() - start.getTime()); System.out.println("!!! Amount of days : " + String.valueOf(days)); &gt;&gt; 30 Why is this?
has comment: http://stackoverflow.com/comment/32497530
has comment: http://stackoverflow.com/comment/32497235
possible better answer: http://stackoverflow.com/a/21524213
tagged with: timeunit
has answer: http://stackoverflow.com/a/21524213
tagged with: calendar

http://stackoverflow.com/comment/32752610
score: 0
has text: Once minutes exceeds 60 then 1 is added to hours. once hours exceeds 24 then 1 is added to days. once days exceeds 24 then one is added to weeks. etc.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21667884

http://stackoverflow.com/comment/32621772
has text: Also equals when doing a comparison should be `==` not `=` in general. The reason you don't use it with a string is because you `==` compares the address in memory instead of if the charters of the string are equal.
type: AnswerComment
comment on: http://stackoverflow.com/a/21593189
type: Comment
score: 0

http://stackoverflow.com/a/21614403
score: 2
type: AcceptedAnswer
downvote count: 0
has body: In Java, the inherent concept of a Class accomplishes this for you, as long as you decide on a key member of the class. class Student extends Person { private int student_id; //if unique, good candidate for a key .... private int age,weight...; } And you can store a collection of students (or students and faculty if they extend a base class) in any sort of data structure, such as ArrayList etc. List&lt;Person&gt; mylist = new ArrayList&lt;Person&gt;(); mylist.add(new Student(1234)); You can add methods to Student, such as overriding toString() to print out any important information. If you wanted an O(1) access time to fetch a student based on their key, you could implement something like Map&lt;Integer,Person&gt; mymap = new HashMap&lt;Integer,Person&gt;(); mymap.put(student1.getStudentID(),student1);
type: Answer
answers question: http://stackoverflow.com/q/21614258
has comment: http://stackoverflow.com/comment/32659255
has comment: http://stackoverflow.com/comment/32658908
accepted answer of: http://stackoverflow.com/q/21614258
upvote count: 2
has comment: http://stackoverflow.com/comment/32658742
has comment: http://stackoverflow.com/comment/32658969

http://stackoverflow.com/q/21610545
has comment: http://stackoverflow.com/comment/32651388
type: UnansweredQuestion
downvote count: 0
score: 1
tagged with: java
tagged with: itext
type: Question
has title: how to extract PDF watermark content using iText apis
has answer: http://stackoverflow.com/a/21615559
has body: I was going through the itext api docs &amp; I was able create a pdf with a watermark image or text but did not find a method to get/extract watermark content from pdf. So I have a pdf document containing watermarked text/image &amp; I want to extract that text or img and validate which I am not able to do. How to extract watermark content using iText apis? Or is there any other way to validate watermark content? By validate I mean if I have an existing pdf/image with some watermarked text [as done in 2nd link in above ref], I want to check whether it has expected text/image. References: http://itextpdf.com/themes/keyword.php?id=226 http://www.java-connect.com/itext/add-watermark-in-PDF-document-using-java-iText-library.html
upvote count: 1
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/32651668
has comment: http://stackoverflow.com/comment/32651485

http://stackoverflow.com/comment/32720697
comment on: http://stackoverflow.com/a/21649971
score: 0
type: Comment
has text: Yes, see item 2) above.
type: AnswerComment

http://stackoverflow.com/q/21564890
has comment: http://stackoverflow.com/comment/32571575
score: 0
answer count: 1
type: AnsweredQuestion
tagged with: object
has answer: http://stackoverflow.com/a/21564933
has comment: http://stackoverflow.com/comment/32571474
tagged with: java
accepted answer: http://stackoverflow.com/a/21564933
has title: Delete Method without Array List
type: Question
has body: I need to implement a delete method WITHOUT USING AN ARRAY LIST. I need to use a set of loops to do it. Here is my delete method and add method as well as any other important variables used. Any advice on what is wrong with my code would be great. EDITED: Changed the comparing of references to values. Seems to work repeatedly. final int MAX_DEVICES = 5; // Array of devices private Device list[] = new Device[MAX_DEVICES]; // Number of Devices currently in the list // "Valid" Devices are stored in cells 0 - (numDevices - 1) private int numDevices = 0; Scanner stdin; // read from stdin private void Add() { String thisName; int numThisRead; float thisInitVal; thisName = stdin.next(); numThisRead = stdin.nextInt(); thisInitVal = stdin.nextFloat(); if(numDevices &gt; MAX_DEVICES) System.out.println("The List was full. " + thisName + " was not added to the list."); else { Device myDevice = new Device(thisName, numThisRead, thisInitVal); list[numDevices] = myDevice; numDevices ++; System.out.println(thisName + " device has been added to the list."); } } private void Delete() //ASK QUESTION { String thisDelete; thisDelete = stdin.next(); for(int i = 0; i &lt; MAX_DEVICES; ++i) { if(list[i].getName().equals(thisDelete)) //if you find the name { System.out.println(list[i].getName() + " was deleted from the " + "list."); for(int j = i; j &lt; numDevices - 1; j++) list[j] = list[j + 1]; numDevices--; return; } } System.out.println(thisDelete + " not deleted. It is not in the list."); }
has comment: http://stackoverflow.com/comment/32571510

http://stackoverflow.com/comment/32488340
comment on: http://stackoverflow.com/a/21517965
type: Comment
has text: Oh right, I have to specify the type of data returned by the method.I feel kind of silly for forgetting to call the method using dot notation. Thanks for the help!
score: 1
type: AnswerComment

http://stackoverflow.com/q/21541324
type: AnsweredQuestion
has title: Can the package "org.opencv.core.Mat" be used for a simple Java program?
downvote count: 0
score: 7
favorite count: 0
type: Question
accepted answer: http://stackoverflow.com/a/21541554
upvote count: 7
answer count: 1
tagged with: opencv
has body: I'm trying to do some operations with a Matrix in Java using opencv. I'm using Eclipse Kepler IDE. The problem happens when I try to declare a new matrix with the constructor, then I get the following error in the console: Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat(III)J at org.opencv.core.Mat.n_Mat(Native Method) at org.opencv.core.Mat.&lt;init&gt;(Mat.java:477) I'm using OpenCV 2.4.8 for OSX, OSX 10.9.1 and Eclipse Kepler. Here is my Code: import java.util.ArrayList; import java.util.List; import org.opencv.core.CvType; import org.opencv.core.Mat; import org.opencv.core.Size; public class FisherFaces { public static void main(String[] args) { Size s = new Size(new double[] {3,3}); Mat g= new Mat(3,3,CvType.CV_8UC1); } Is there anything I am doing wrong to cause this error?
tagged with: java
has answer: http://stackoverflow.com/a/21541554
has comment: http://stackoverflow.com/comment/32530386
tagged with: eclipse

http://stackoverflow.com/a/21534255
upvote count: 1
answers question: http://stackoverflow.com/q/21534188
downvote count: 0
has body: You are iterating over all elements in the array, but checking element seq[i + 1] for i == seq.lenth - 1 will always cause the exception. The last number is fully constrained by your conditions, so no need to check it. Make your loop run as follows: for (int i=0; i &lt;seq.length - 1; i++)
type: Answer
score: 1

http://stackoverflow.com/q/21620484
has answer: http://stackoverflow.com/a/21637225
possible better answer: http://stackoverflow.com/a/21622347
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21622791
score: 1
tagged with: java
has title: Testing output of void main with Console.readline() involved
upvote count: 1
has body: I need to junit test an existing code by the output ( in system.out ) public static void main(String args[]) { Console console = System.console(); String str = console.readLine(); System.out.println("halo"+str); } Since the console.readline is waiting for user input, I found it will halt in the console.readline(),thus block me from getting the output. Is there a way to do this? Is it posible to do it using Mockito or something?
type: Question
tagged with: mockito
accepted answer: http://stackoverflow.com/a/21622791
answer count: 3
tagged with: junit
downvote count: 0
has answer: http://stackoverflow.com/a/21622347
favorite count: 0
tagged with: console

http://stackoverflow.com/comment/32760580
type: AnswerComment
comment on: http://stackoverflow.com/a/21658411
type: Comment
score: 1
has text: @aLearner The short version: if you're synchronizing with a ConcurrentHashMap, **You're Doing It Wrong**. The whole point of that class is that you _don't need to_ synchronize to use it; you use a different set of operations that let you avoid that sort of cost.

http://stackoverflow.com/comment/42367980
has text: Eclipse does the same, it's a very beneficial feature.
score: 4
type: AnswerComment
comment on: http://stackoverflow.com/a/21632640
type: Comment

http://stackoverflow.com/comment/32551800
type: Comment
has text: the protected configure method is isolated to only the WebSecurityConfigurerAdapter (that is why the method scope is protected). This means the authentication will not be found by the global method security support. Instead global authentication should be configured as demonstrated in my example. Also note that the expression handler you have here is for the web and not method level security.
type: AnswerComment
comment on: http://stackoverflow.com/a/21554408
score: 0

http://stackoverflow.com/q/21630732
score: 0
has answer: http://stackoverflow.com/a/21630822
tagged with: arrays
answer count: 7
has answer: http://stackoverflow.com/a/21631201
has body: My code is supposed to separate a given String and covert the chosen letters into # and separate and concatenate the words with the chosen letter. My problem is with one of the methods (allWordsWith) in my code, it won't allow me to return a String array. (p.s, the codes that run this one are irrelevant, I'm not supposed to edit those). import java.util.Arrays; import java.util.Scanner; public class LipogramAnalyzer { private String line; public LipogramAnalyzer(String text){ line = text; } public String mark (char letter){ String replaceletters = line.replace(letter, '#'); return replaceletters; } public String[] allWordsWith (char letter){ String[] arr = line.split(" "); for ( String ss : arr) { String ary[] = {ss}; for(int i = 0; i &lt; ary.length; i++){ int numindex = ss.indexOf(letter); if (numindex != -1){ String result = ary[i]; return result; } } } } }
tagged with: string
has answer: http://stackoverflow.com/a/21630815
has answer: http://stackoverflow.com/a/21630873
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21630864
has answer: http://stackoverflow.com/a/21631318
has comment: http://stackoverflow.com/comment/32686896
has comment: http://stackoverflow.com/comment/32686750
has answer: http://stackoverflow.com/a/21630926
tagged with: java
has title: How to return a String Array
type: Question

http://stackoverflow.com/comment/32491687
comment on: http://stackoverflow.com/a/21519735
score: 0
type: Comment
has text: I agree with @wqrahd.
type: AnswerComment

http://stackoverflow.com/comment/32620867
score: 0
type: AnswerComment
type: Comment
has text: How would I call addView()?
comment on: http://stackoverflow.com/a/21592105

http://stackoverflow.com/comment/32707390
comment on: http://stackoverflow.com/a/21642174
has text: Apparently, we like [MCVE](http://stackoverflow.com/help/mcve) 's now. Being official SO docs and things.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/21621803
has title: Why Map.putIfAbsent() is returning null?
favorite count: 0
answer count: 9
has answer: http://stackoverflow.com/a/21621882
possible better answer: http://stackoverflow.com/a/48080179
has answer: http://stackoverflow.com/a/21621874
has answer: http://stackoverflow.com/a/21621856
has answer: http://stackoverflow.com/a/67604508
has comment: http://stackoverflow.com/comment/32671313
has answer: http://stackoverflow.com/a/67790438
type: AnsweredQuestion
upvote count: 36
downvote count: 0
accepted answer: http://stackoverflow.com/a/21621848
tagged with: java
type: Question
tagged with: hashmap
has answer: http://stackoverflow.com/a/21621848
has answer: http://stackoverflow.com/a/31146735
has answer: http://stackoverflow.com/a/48080179
has body: The following program is printing null. I am not able to understand why. public class ConcurrentHashMapTest { public static final Map<String, String> map = new ConcurrentHashMap<>(5, 0.9f, 2); public static void main(String[] args) { map.putIfAbsent("key 1", "value 1"); map.putIfAbsent("key 2", "value 2"); String value = get("key 3"); System.out.println("value for key 3 --> " + value); } private static String get(final String key) { return map.putIfAbsent(key, "value 3"); } } Could someone help me understand the behavior?
score: 36
has answer: http://stackoverflow.com/a/21621859

http://stackoverflow.com/q/21534168
has comment: http://stackoverflow.com/comment/32516988
favorite count: 0
has comment: http://stackoverflow.com/comment/32517329
has title: Logback configuration file is ignored
has comment: http://stackoverflow.com/comment/32517033
score: 2
has comment: http://stackoverflow.com/comment/32517807
upvote count: 2
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32518440
has body: The logback's configuration file is ignored into my WS module (I'm using glassfish). The location .../src/main/resources/logback.xml This is its content: <?xml version="1.0" encoding="UTF-8"?> %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n <appender-ref ref="STDOUT" /> I start the WS service with the command mvn embedded-glassfish:run Any suggestions?
type: Question
has answer: http://stackoverflow.com/a/52860897
tagged with: java
tagged with: logback
has comment: http://stackoverflow.com/comment/32517140
has comment: http://stackoverflow.com/comment/32517968
answer count: 1
downvote count: 0

http://stackoverflow.com/q/21564549
type: Question
score: 0
tagged with: java
answer count: 1
has body: It's been a couple years since I've done any java. I'm thinking there's a nicer way to write this, not sure how to google the question really. boardSpots[0][1] = new Pawn(); boardSpots[1][1] = new Pawn(); boardSpots[2][1] = new Pawn(); boardSpots[3][1] = new Pawn(); boardSpots[4][1] = new Pawn(); boardSpots[5][1] = new Pawn(); boardSpots[6][1] = new Pawn(); boardSpots[7][1] = new Pawn();
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32570796
has comment: http://stackoverflow.com/comment/32570829
has answer: http://stackoverflow.com/a/21564636
has comment: http://stackoverflow.com/comment/32570730
has title: more elegant way to initialize range of array elements

http://stackoverflow.com/comment/32506078
comment on: http://stackoverflow.com/q/21528174
score: 0
type: Comment
type: QuestionComment
has text: http://stackoverflow.com/questions/1935178/correct-usage-of-stateful-beans-with-servlets/1935476#1935476 post says that an SLSB is synchronized by the app server.

http://stackoverflow.com/q/21667586
score: 0
has comment: http://stackoverflow.com/comment/32751863
answer count: 1
tagged with: parameters
tagged with: java
accepted answer: http://stackoverflow.com/a/21668309
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32752743
has body: "Employee identification number (a string) in the format XXX-L, where each X is a digit within the range 0-9 and the L is a letter within the range ‘A’-‘M’ (both lowercase and uppercase letters are acceptable)" The above is a field which will be an argument for the constructor. Right now, I'm planning on making sure the the first 3 letters of the string is a number between 0-9, and then make sure there is a dash in the index of 4, and then make sure there is a letter between A-M in the 5th index, all using if else statements. Is there a better way of doing this, like if the entering of the parameter didn't have to be so exact, and the programs able to fix it by itself? Thank you. I coded it and tried regex expression tools: import java.util.regex.*; public class Employee { private String eName; private String IDNumber; public Employee(String name, String number) { String regex = "[0-9][0-9][0-9][\\-][a-mA-M]"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(number); this.eName = name; if(matcher.matches()) { this.IDNumber = number; } else{ this.IDNumber = "999-M"; } } public String getNumber() { System.out.println(IDNumber); return IDNumber; } public static void main(String[] args) { Employee e = new Employee("John", "123-f"); e.getNumber(); Employee c = new Employee("Jane","25z"); c.getNumber(); } } I haven't thoroughly tested it, but it works, but looking at other people's regex expression, mine seems to be very newbish. I was wondering if someone can help me construct a shorter or better regex expression.
has comment: http://stackoverflow.com/comment/32754472
has comment: http://stackoverflow.com/comment/32752772
has comment: http://stackoverflow.com/comment/32751905
type: Question
has comment: http://stackoverflow.com/comment/32751853
has comment: http://stackoverflow.com/comment/32753548
has title: Java better way to code this simple parameter intake?
tagged with: constructor
has answer: http://stackoverflow.com/a/21668309

http://stackoverflow.com/comment/32726187
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21652980
type: Comment
has text: I can see the appeal, but then you have to synchronize access to the shared location data.

http://stackoverflow.com/comment/33515906
type: QuestionComment
comment on: http://stackoverflow.com/q/21635307
score: 0
has text: Could you please add the error trace to your question?
type: Comment

http://stackoverflow.com/comment/32635571
comment on: http://stackoverflow.com/a/21599996
type: AnswerComment
score: 0
type: Comment
has text: @kocko hmmm bare with me please , say I have a class called Part , how employ the createInstanceFrom(); now ?

http://stackoverflow.com/a/21521331
score: 3
answers question: http://stackoverflow.com/q/21521213
downvote count: 0
upvote count: 3
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32494125
has comment: http://stackoverflow.com/comment/32494865
has body: Why would you call doubleValue()? Just avoid doing that. There are two problems with it: A double has no notion of trailing zeroes, unlike BigDecimal Converting between double and BigDecimal (in either direction) is almost always a bad idea. They're generally used for different kinds of values - e.g. physical dimensions like height and weight are best for double; artificial values such as currency are best for BigDecimal Without the call to doubleValue() you're fine: import java.math.*; public class Test { public static void main(String[] args) { String input = "0.4595"; int places = 3; BigDecimal dec = new BigDecimal(input) .setScale(places, BigDecimal.ROUND_HALF_EVEN); System.out.println(dec); // Prints 0.460 } }
type: Answer
accepted answer of: http://stackoverflow.com/q/21521213

http://stackoverflow.com/q/21673058
has answer: http://stackoverflow.com/a/21673222
favorite count: 0
answer count: 5
possible better answer: http://stackoverflow.com/a/21673222
score: 2
type: AnsweredQuestion
downvote count: 0
has body: Why I get trailing so many numbers when I run below code? BigDecimal lat = new BigDecimal(0.0077); System.out.println(lat); output >> 0.00770000000000000024702462297909733024425804615020751953125 I want to print exactly what I entered. How can I do this?
accepted answer: http://stackoverflow.com/a/21673087
tagged with: java
type: Question
upvote count: 2
has title: Remove trailing numbers
has answer: http://stackoverflow.com/a/21673087
tagged with: bigdecimal
has answer: http://stackoverflow.com/a/21673664
has answer: http://stackoverflow.com/a/21673097
has answer: http://stackoverflow.com/a/21673254

http://stackoverflow.com/comment/41168400
type: QuestionComment
comment on: http://stackoverflow.com/q/21638080
has text: There's also the point that the higher-order hash bits are "suspect" in many cases.
score: 0
type: Comment

http://stackoverflow.com/q/21662774
has body: So, I'm still learning Java and I am curious about extracting information from Strings and and assigning the information to a variable. Let's for example say, I have the following String: {"my_books_are_all_organized","yes_sir_yes_they_are"} Then I wish to make a new String that that only contains this part: my_books For example a String variable called whatIsOgranized, which only held the text "my_books", would have to gather all the information from the symbols: {" To the symbols: _are Everything in between those sets of symbols are to be stored in the whatIsOrganized String. So when I run: System.out.println(whatIsOrganized); It gives me: my_books Is this possible in Java? Could anyone show me how my above example would be coded?
answer count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/32743067
tagged with: string
favorite count: 0
has comment: http://stackoverflow.com/comment/32742955
has answer: http://stackoverflow.com/a/21662852
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21662864
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/21662852
upvote count: 1
possible better answer: http://stackoverflow.com/a/21662864
type: Question
has comment: http://stackoverflow.com/comment/32742956
has title: Save part of a String from a word to a different word

http://stackoverflow.com/q/21520519
has comment: http://stackoverflow.com/comment/32513618
tagged with: xjc
has comment: http://stackoverflow.com/comment/32508445
type: Question
has body: I tried googling without any help. Apologies if there are any duplicates. I have the following schema header for the file common.xsd &lt;xs:schema xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:meta="http://www.vmware.com/vcloud/meta" jaxb:version="2.0" jaxb:extensionBindingPrefixes="meta" elementFormDefault="qualified" targetNamespace="http://www.vmware.com/vcloud/v1.5" version="1.0"&gt; I am trying to generate class files using xjc command. xjc -version xjc version "JAXB 2.1.10 in JDK 6" JavaTM Architecture for XML Binding(JAXB) Reference Implementation, (build JAXB 2.1.10 in JDK 6) I am getting this error. [info] [ERROR] Unsupported binding namespace "http://www.vmware.com/vcloud/meta". Perhaps you meant "http://java.sun.com/xml/ns/jaxb/xjc"? [info] line 21 of file:/Users/kcherivirala/vmware/dev/corp/zephyr/services/networkservice/app/vcd-schema/src/main/xsd/vcloud/common.xsd Any leads on this would be of great help.
tagged with: xsd
tagged with: http://stackoverflow.com/tag/xml
upvote count: 1
answer count: 1
has comment: http://stackoverflow.com/comment/32492728
has comment: http://stackoverflow.com/comment/32492570
tagged with: java
type: UnansweredQuestion
tagged with: jaxb
has comment: http://stackoverflow.com/comment/32506828
has answer: http://stackoverflow.com/a/26422067
downvote count: 0
score: 1
has title: Unsupported binding namespace while generating class files using xjc
favorite count: 0

http://stackoverflow.com/a/21611002
downvote count: 0
type: Answer
has body: You could put the initialization code in a trait constructor and have your tests extend from that trait. Another approach is to have that configuration as the default, and if no configuration is set then it gets used the first time your library code is called. That would cover both testing and non-testing scenarios. A hybrid approach would be to have your sbt testing configuration set a system property. If that system property is set and no configuration is has been set then the testing config will be used the first time the library code gets called.
score: 1
answers question: http://stackoverflow.com/q/21609048
upvote count: 1

http://stackoverflow.com/comment/32601118
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21517017
has text: Did you really set the background to 0, 0, 0, 0 and it still looks like that? Cuz it doesnt for me

http://stackoverflow.com/comment/32523764
score: 0
type: AnswerComment
has text: I've tried it, but it didn't help. The error message is the same. I've also put xsd file into the same directory, where PrivatePersonService.wsdl is.
type: Comment
comment on: http://stackoverflow.com/a/21523278

http://stackoverflow.com/comment/32595252
type: Comment
score: 0
comment on: http://stackoverflow.com/q/21577782
type: QuestionComment
has text: Passing JSON into the query parameter doesn't make sense. You need to at least URL-encode it.

http://stackoverflow.com/comment/32681005
comment on: http://stackoverflow.com/a/21619476
type: Comment
type: AnswerComment
has text: Putty is very much a windowed application. There has been requests for a no-terminal mode but hasnt materialized (see [here](http://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/no-terminal-window.html))
score: 0

http://stackoverflow.com/comment/32687581
type: Comment
has text: @JBNizet: The method `V set(int rowIndex, int columnIndex, V value)` proves that the row and column keys are not needed to set a value for `ArrayTable`.
comment on: http://stackoverflow.com/q/21628045
score: 0
type: QuestionComment

http://stackoverflow.com/q/21590908
has comment: http://stackoverflow.com/comment/32618236
has answer: http://stackoverflow.com/a/42145752
has answer: http://stackoverflow.com/a/65057707
has answer: http://stackoverflow.com/a/56797002
has answer: http://stackoverflow.com/a/66187024
has comment: http://stackoverflow.com/comment/32618194
upvote count: 5
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21591030
has answer: http://stackoverflow.com/a/65721352
has comment: http://stackoverflow.com/comment/32618213
has body: I am trying to find all the elements which occur an odd number of times in an array. I worked out a little bit, but my code is only returning the correct answer if there is only one number which occurs odd number of times. If there are two or more odd occurring numbers than I am not able to process it. What I understand is that if we do bit-wise XOR of elements than we get one odd occurring element. How can I improve it for multiple numbers? Below is my code: public class OddOccur { public int oddoccurence(int[] arr, int size) { int res = 0; int[] fin = new int[size]; for (int i = 0; i &lt; size; i++) { res = res ^ arr[i]; } return res; } public static void main(String args[]) { int[] arr = { 2, 5, 5, 2, 2, 3, 3, 3 }; int n = arr.length; OddOccur obj = new OddOccur(); System.out.println("odd occuring element is:" + obj.oddoccurence(arr, n)); } } Need help to solve this issue!
score: 5
linked to: http://stackoverflow.com/q/15469795
has title: How to find all odd occurring elements in an array in Java
has answer: http://stackoverflow.com/a/70174252
has answer: http://stackoverflow.com/a/68610248
tagged with: arrays
downvote count: 0
has answer: http://stackoverflow.com/a/63973217
has comment: http://stackoverflow.com/comment/32618364
has comment: http://stackoverflow.com/comment/32618369
has comment: http://stackoverflow.com/comment/32618276
has answer: http://stackoverflow.com/a/72999694
has comment: http://stackoverflow.com/comment/32618142
answer count: 15
favorite count: 0
has answer: http://stackoverflow.com/a/45457018
has answer: http://stackoverflow.com/a/54513398
has comment: http://stackoverflow.com/comment/32618181
has answer: http://stackoverflow.com/a/54155287
has answer: http://stackoverflow.com/a/54156091
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/37423875
has comment: http://stackoverflow.com/comment/32618344

http://stackoverflow.com/comment/32584513
score: 0
type: AnswerComment
type: Comment
has text: the code if (recbtn.getText().equals(getString(R.string.recBtn))) doesnt work but when ireplace the else it work
comment on: http://stackoverflow.com/a/21571969

http://stackoverflow.com/a/21613592
type: Answer
has body: The actual type is Child, therefore when you call a method, the Child's method will be called. It doesn't matter whether the reference type is of Parent, it's the actual type of the object that matters. You can't "cast to superclass" in order to call the Parent's method either.
answers question: http://stackoverflow.com/q/21613540
score: 0

http://stackoverflow.com/q/21617326
tagged with: jaxb2
score: 0
tagged with: binding
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32668664
has comment: http://stackoverflow.com/comment/32667593
tagged with: http://stackoverflow.com/tag/xml
answer count: 0
has comment: http://stackoverflow.com/comment/32666241
has comment: http://stackoverflow.com/comment/32668113
has title: Binding attributes in arbitrary class with sun's JAXB-Impl
type: Question
has body: I have this xml sample: <author id="1" /> <author id="2" /> I need to map this to un annotated class. These classes are JPA annotated but not JAXB. I understand that this would work by default if the attributes are elements. But in this case, some work needs to be done. So my question is, Is this possible with JAXB-Impl (not MOXy) ? And if yes, where do I start and what do I need to customize. I looked into extending XmlAdapter, but couldn't find examples, about to do this. I appreciate any hint.
tagged with: java
tagged with: jaxb

http://stackoverflow.com/comment/32629742
has text: @pskink because depending on the launch trigger i sometimes want to make the root view visible
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21597531

http://stackoverflow.com/comment/32562094
has text: Consider using a `Map`.
comment on: http://stackoverflow.com/q/21559952
type: QuestionComment
type: Comment
score: 3

http://stackoverflow.com/comment/104520230
comment on: http://stackoverflow.com/q/21530112
type: Comment
type: QuestionComment
has text: Only way is to issue direct queries to the underlying driver. Or switch to C# where you can do native bulk inserts with Entity Framework.
score: 1

http://stackoverflow.com/comment/32595950
score: 0
comment on: http://stackoverflow.com/q/21578764
type: QuestionComment
type: Comment
has text: it just saving the file name. i just don't know the directory where it is putting the file. @MustafaGenç

http://stackoverflow.com/a/21609459
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/32651451
answers question: http://stackoverflow.com/q/21601306
score: 1
has comment: http://stackoverflow.com/comment/32650108
upvote count: 1
has body: The PermGen memory space is not part of the heap (sometimes this causes confusion). It's where some kind of objects are allocated, like Class objects, Method objects, and the pool of strings objects. Unlike the name would indicate, this memory space is also collected (during the FullGC), but often bring major headaches, as known OutOfMemoryError. Problems with bursting PermGen are difficult to diagnose precisely because it is not the application objects . Most of the cases, the problem is connected to an exaggerated amount of classes that are loaded into memory. A well known issue, was the use of Eclipse with many plugins ( WTP ) with default JVM settings . Many classes were loaded in memory and ends with a burst of the permGEN. Another problem of PermGen are the hot deploys in application servers. For several reasons, the server cannot release the context classes at the destroy time . A new version of the application is then loaded, but old the classes remains, increasing the PermGen. That's why sometimes we need to restart the whole container because of the PermGen.

http://stackoverflow.com/comment/32676072
comment on: http://stackoverflow.com/q/21624403
score: 0
type: Comment
type: QuestionComment
has text: I don't see any array in your code except `String[] args` in main.

http://stackoverflow.com/q/21646960
has comment: http://stackoverflow.com/comment/32715284
has comment: http://stackoverflow.com/comment/32715282
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21647157
upvote count: 1
has comment: http://stackoverflow.com/comment/32715242
has title: ordering indexes by array values
score: 1
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32715298
answer count: 2
has answer: http://stackoverflow.com/a/21647108
has comment: http://stackoverflow.com/comment/32715327
tagged with: arrays
downvote count: 0
has body: I have an array of integers and I want some code to produce an array for me with these specifications: first item is the index of the maximum of integer values second item is the index of highest value which is less than max the last item is the index of the minimum of integer values. Assume int totalvalue[] = {100, 120, 90, 110} and I want this {1, 3, 0, 2}
favorite count: 0
has comment: http://stackoverflow.com/comment/32715323

http://stackoverflow.com/q/21642771
has title: Find maximum element in binary tree
has comment: http://stackoverflow.com/comment/32708491
type: Question
accepted answer: http://stackoverflow.com/a/21643109
tagged with: recursion
score: 4
has body: I am really confused about finding an element in a binary tree. Question: When we say, search an element in a binary tree, maximum, in this case, do we assume that the tree is sorted??? If not, take a look at the below code, I got it from a book and almost every online URL suggests a similar pattern int FindMaxNmb(BinaryTreeNode root) { int root_val, left, right, max; if(root != null) { root_val = root.getData(); //recursion - this is what I don't understand /* * This code would have made sense if the binary tree contained * Sorted elements, like The left subtree of a node contained * Only nodes with keys less than the node's key The right subtree * of a node contained only nodes with keys greater * than the node's key. * */ left = FindMaxNmb(root.getLeft()); right = FindMaxNmb(root.getRight()); //Find max number if(left &gt; right) { max = left; } else { max = right; } if(root_val &gt; max) { max = root_val; } } return max; } What i don't understand : take this recursion for instance left = FindMaxNmb(root.getLeft()); this will go on calling unless it reaches the leftmost bottom leaf and then assigns the value, same is with getRight()....but this thing only works for the leftmost node having 2 children...how does it check the value of remaining nodes (I am assuming that binary tree is not sorted) I know I am missing something very obvious here...please help!!
tagged with: search
has answer: http://stackoverflow.com/a/21643109
answer count: 1
favorite count: 0
tagged with: binary-tree
upvote count: 4
tagged with: tree
type: AnsweredQuestion
downvote count: 0
has comment: http://stackoverflow.com/comment/32708487
tagged with: java

http://stackoverflow.com/q/21563067
has comment: http://stackoverflow.com/comment/32568392
has comment: http://stackoverflow.com/comment/32568700
has comment: http://stackoverflow.com/comment/32593453
answer count: 3
has comment: http://stackoverflow.com/comment/32568100
has answer: http://stackoverflow.com/a/21563364
has body: Given a year and a month; I want to get two Date Objects. one for startDate of the month and one for the end Date of the month. I have it implemented here and it works. but this looks too verbose, and I am wondering if there is a neat solution to this; Eg given March 2014, start Date will be March 01 and end Date will be March 31 ( as Date objects with millisecond precision) public setDates(int month,int year) { Calendar calendar = Calendar.getInstance(); // Use the calendar to get the startDate and endDate of this Invoice. calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH,month); //set start date calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH)); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMinimum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMinimum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMinimum(Calendar.SECOND)); calendar.set(Calendar.MILLISECOND, calendar.getActualMinimum(Calendar.MILLISECOND)); this.startDate = calendar.getTime(); //endDate start date calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMaximum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMaximum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMaximum(Calendar.SECOND)); calendar.set(Calendar.MILLISECOND, calendar.getActualMaximum(Calendar.MILLISECOND)); this.endDate = calendar.getTime(); }
accepted answer: http://stackoverflow.com/a/21563364
upvote count: 1
has answer: http://stackoverflow.com/a/21563121
has comment: http://stackoverflow.com/comment/32568217
linked to: http://stackoverflow.com/q/3083781
favorite count: 0
linked to: http://stackoverflow.com/q/8997228
has comment: http://stackoverflow.com/comment/32568122
has title: get startday of month and endday of month using calendar class in Java
linked to: http://stackoverflow.com/q/14241836
tagged with: calendar
has comment: http://stackoverflow.com/comment/32567924
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
linked to: http://stackoverflow.com/q/14475489
tagged with: date
linked to: http://stackoverflow.com/q/2261480
has answer: http://stackoverflow.com/a/21566360
type: Question
linked to: http://stackoverflow.com/q/10828398
has comment: http://stackoverflow.com/comment/32568428
possible better answer: http://stackoverflow.com/a/21563121
has comment: http://stackoverflow.com/comment/32568058

http://stackoverflow.com/comment/32746569
comment on: http://stackoverflow.com/a/21664637
type: AnswerComment
has text: @rick Through the MinGW project, yes.
score: 0
type: Comment

http://stackoverflow.com/q/21579826
downvote count: 0
has comment: http://stackoverflow.com/comment/32597686
favorite count: 0
type: UnansweredQuestion
tagged with: android
has answer: http://stackoverflow.com/a/21580052
tagged with: universal-image-loader
upvote count: 2
has answer: http://stackoverflow.com/a/24478392
has title: Fix a warning of ImageLoader : "Try to initialize ImageLoader which had already been initialized before"
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/21580941
has body: In my app, i have a listview with some items. Each item has a img which is downloaded from distant url. I use ImageLoader library to load each image into my app. My listview is well built, i have all images, but i have a warning in LogCat : 02-05 15:16:17.938: W/ImageLoader(17363): Try to initialize ImageLoader which had already been initialized before. To re-init ImageLoader with new configuration call ImageLoader.destroy() at first. I don't know how to fix this issue ? Here the code of my adapter : public class ArticleListAdapterHome extends ArrayAdapter&lt;ArticleHome&gt; { Typeface faceLight = Typeface.createFromAsset(getContext().getAssets(), "fonts/Roboto-Light.ttf"); Typeface faceBold = Typeface.createFromAsset(getContext().getAssets(), "fonts/Roboto-Bold.ttf"); public ArticleListAdapterHome(Activity activity, List&lt;ArticleHome&gt; articles) { super(activity, 0, articles); } @Override public View getView(int position, View convertView, ViewGroup parent) { Activity activity = (Activity) getContext(); LayoutInflater inflater = activity.getLayoutInflater(); View rowView; ArticleHome article = getItem(position); if (position == 0) { rowView = inflater.inflate(R.layout.item_ligne_home_premier, null); //////////////////////////////////////////////////////// ///// IMAGE /////////////////////////////////////////////////////// ImageView imgfirst = (ImageView) rowView.findViewById(R.id.imgimg) ; DisplayImageOptions options = new DisplayImageOptions.Builder() .cacheInMemory(true) .cacheOnDisc(true) .build(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getContext()) .defaultDisplayImageOptions(options) .threadPriority(Thread.MAX_PRIORITY) .denyCacheImageMultipleSizesInMemory() .memoryCacheSize(2 * 1024 * 1024) .build(); ImageLoader imageLoader = ImageLoader.getInstance(); imageLoader.init(config); imageLoader.displayImage(article.getImage(), imgfirst); ListView listV = (ListView)parent; boolean pauseOnScroll = false; // or true boolean pauseO…
answer count: 3
score: 2

http://stackoverflow.com/a/21677385
score: 0
type: Answer
has body: Actually you are using List FWD = new ArrayList&lt;Coords&gt;(); which means the JVM would create List as follows List&lt;Object&gt; FWD = new ArrayList&lt;Coords&gt;(); and when you use get(), it will return object of Object class and when you call method getIndexX(), this method does not exists in the Object class hence it will give an exception or error at the compiletime. Hence, you should use List&lt;Coords&gt; FWD = new ArrayList&lt;Coords&gt;();
answers question: http://stackoverflow.com/q/21677212

http://stackoverflow.com/comment/32610442
has text: I would prefer to it in a method in java, as the program which gives the original file is written in Java. Sorry for not specifying earlier. @Bugs it is the last character in every line, which is also the 6th caret on every line.
score: 0
comment on: http://stackoverflow.com/q/21586612
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32603470
type: AnswerComment
has text: @Puce Why rewrite? The array length is indeed stored together with the array, so what's the problem? If you would like to suggest a better wording for this, please feel free to edit - I always appreciate good edits!
type: Comment
comment on: http://stackoverflow.com/a/21582008
score: 0

http://stackoverflow.com/a/21664437
accepted answer of: http://stackoverflow.com/q/21664387
upvote count: 5
answers question: http://stackoverflow.com/q/21664387
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/32746362
has comment: http://stackoverflow.com/comment/32746443
has body: In order to access private field you have to set it as accessible: field.setAccessible(true);
score: 5
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32746470
has comment: http://stackoverflow.com/comment/32746471
has comment: http://stackoverflow.com/comment/32746319

http://stackoverflow.com/a/21730466
type: AcceptedAnswer
has body: Yes that is correct. see https://github.com/neo4j/neo4j/blob/master/community/kernel/src/main/java/org/neo4j/graphdb/factory/GraphDatabaseSettings.java#L190 for the full details.
type: Answer
downvote count: 0
score: 1
accepted answer of: http://stackoverflow.com/q/21613746
upvote count: 1
answers question: http://stackoverflow.com/q/21613746

http://stackoverflow.com/q/21591381
tagged with: java
tagged with: hibernate
type: Question
tagged with: hibernate-envers
upvote count: 5
has answer: http://stackoverflow.com/a/40847882
has title: Querying all Hibernate Envers revisions between two dates
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/21592070
has comment: http://stackoverflow.com/comment/32619669
favorite count: 0
type: UnansweredQuestion
score: 5
has comment: http://stackoverflow.com/comment/32619584
has comment: http://stackoverflow.com/comment/32619767
has body: I have just started using Hibernate Envers for audit, and i will like to know if there is a way to get all the revisions of a class between two dates. up until now i was using: AuditQuery query = reader.createQuery().forRevisionsOfEntity(MYCLASS.class, false, true); query.add(AuditEntity.revisionNumber().le(reader.getRevisionNumberForDate(MYDATE))); to get the revisions of a particular date, but is there a way to recover all the revisions between for example: MYDATE1 and MYDATE2?

http://stackoverflow.com/comment/32721853
has text: @Obicere I'm not, there is a pic on my desktop I'm trying to load.
comment on: http://stackoverflow.com/q/21650420
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/32682400
type: AnswerComment
type: Comment
has text: I'm unable to find any such SQL that is supported by both. MYDATE1 - MYDATE2 gives the number of days between two dates in Oracle but gives number of seconds as output in case of HSQLDB
comment on: http://stackoverflow.com/a/21590508
score: 0

http://stackoverflow.com/comment/32499868
type: AnswerComment
score: 0
type: Comment
has text: @user3155839: Declare the HTML entities in your code. See my edited answer.
comment on: http://stackoverflow.com/a/21523662

http://stackoverflow.com/comment/32553284
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21555281
has text: AFAIK, an immutable collection will _always_ be sized appropriatelly to the number of elements inserted, no matter what method you use to instantiate it. And a default HashSet will have a size of 16 (to allow for a trick of using binary `AND` instead of a `mod` operation when calculating the right bucket from the `hashCode`). Or has anything changed recently?

http://stackoverflow.com/comment/32717612
comment on: http://stackoverflow.com/a/21647060
score: 0
type: AnswerComment
type: Comment
has text: Yeah, it makes no sense to build upon own encryption. Quite sad that there is no common -free- solution. Else, I guess, I would already found it here or while googleing. :)

http://stackoverflow.com/comment/32553960
has text: @SotiriosDelimanolis Sorry for uncleared question. `UserInsertReqDto` is just example. This will only exist when user of the framework create it. I have to prepare in the framework to get annotation of whatever `ReqDto` class which implement `IReqDto`. Thank you for your time sir.
type: QuestionComment
comment on: http://stackoverflow.com/q/21555556
score: 0
type: Comment

http://stackoverflow.com/comment/74869819
comment on: http://stackoverflow.com/q/21557545
has text: This is pretty much why command line arguments were invented.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21542293
has body: You can use if task available from ant-contrib to do file existance check at path you are looking &amp; run a delete like below: &lt;if&gt; &lt;available file="${bigPathToFolder}"/&gt; &lt;then&gt; &lt;delete dir="${bigPathToFolder}" quiet="false"/&gt; &lt;echo message="Delete success" /&gt; &lt;/then&gt; &lt;else&gt; &lt;echo message="File Not found at path : ${bigPathToFolder}" /&gt; &lt;/else&gt; &lt;/if&gt;
downvote count: 0
type: Answer
score: 1
answers question: http://stackoverflow.com/q/21527082
upvote count: 1

replaceall
tags question: http://stackoverflow.com/q/21606246
type: Tag
tag name: replaceall

http://stackoverflow.com/a/21601905
downvote count: 0
score: 5
has comment: http://stackoverflow.com/comment/32636378
has body: The thing is, a cast cannot actually change the type of an object. It can refer to the object by any of the types that it already belongs to - but it cannot change the actual type. A String is not a Double, so you cannot cast String to Double. You need to call Double.valueOf().
upvote count: 5
type: Answer
answers question: http://stackoverflow.com/q/21601854

http://stackoverflow.com/comment/32517401
has text: Are you sure the Player supports multiple instruments? Not all do.
comment on: http://stackoverflow.com/q/21523067
score: 1
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21598261
has comment: http://stackoverflow.com/comment/32630590
has answer: http://stackoverflow.com/a/21598695
tagged with: aop
has comment: http://stackoverflow.com/comment/32630639
tagged with: aspectj
score: 0
has title: How to invoke methods of hooked class within aspect?
has comment: http://stackoverflow.com/comment/32632309
answer count: 1
accepted answer: http://stackoverflow.com/a/21598695
has body: Maybe name of theme is bad. I try to explain clarity. I have class: public class A(){ Field1 field1; Field2 field2; public void method1(){...} public void method2(){...} public void sourceMethod(ParameterClass parameter1){ //some code method1(); //some code method2(); //some cdoe } } I will hook source method: ... @Around(value = "execution(* A.sourceMethod(ParameterClass))") public void aroundSourceMethod(JoinPoint joinPoint){ //I need to write my realization sourceMethod here // I want to invoke method1 and method2 here } Here I want to rewrite all code. But I need to invoke method1() and method2() Is it possibly using AspectJ ?
has comment: http://stackoverflow.com/comment/32632130
has comment: http://stackoverflow.com/comment/32631594
type: AnsweredQuestion
tagged with: hook
has comment: http://stackoverflow.com/comment/32631855
tagged with: java
type: Question

http://stackoverflow.com/comment/32700033
comment on: http://stackoverflow.com/a/21637818
has text: Actually, I think you're off in that hex literal. My calculator claims it should be 0x40000000, and going backwards says the same (1<<32 starts with 0x10, 1<<31 starts with 0x8, 1<<30 starts with 0x4).
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32504102
type: Comment
type: QuestionComment
has text: *Deleting needed folder* only
score: 0
comment on: http://stackoverflow.com/q/21527082

http://stackoverflow.com/comment/32696621
has text: readObject() and writeObject() methods do the actual reading data and writing data to-form the socket.
type: Comment
comment on: http://stackoverflow.com/a/21635486
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32644340
score: 1
type: AnswerComment
has text: @DerrickBowen If you are programming to interfaces as Spring recommends, you could then use the first alternative of splitting your context files.
type: Comment
comment on: http://stackoverflow.com/a/21585958

http://stackoverflow.com/a/59025209
has comment: http://stackoverflow.com/comment/121690129
downvote count: 0
score: 1
has body: Jon skeet said: The documentation seems pretty clear to me: "Base implementation of HttpClient that also implements Closeable" - HttpClient is an interface; CloseableHttpClient is an abstract class, but because it implements AutoCloseable you can use it in a try-with-resources statement. But then Jules asked: @JonSkeet That much is clear, but how important is it to close HttpClient instances? If it's important, why is the close() method not part of the basic interface? Answer for Jules close need not be part of basic interface since underlying connection is released back to the connection manager automatically after every execute To accommodate the try-with-resources statement. It is mandatory to implement Closeable. Hence included it in CloseableHttpClient. Note: close method in AbstractHttpClient which is extending CloseableHttpClient is deprecated, I was not able to find the source code for that.
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/106917067
answers question: http://stackoverflow.com/q/21574478

http://stackoverflow.com/a/21521971
has comment: http://stackoverflow.com/comment/32495469
score: 4
has body: Per &sect;15.17.3 "Remainder Operator %" of The Java Language Specification, Java SE 7 Edition, (a/b)*b+(a%b) is always equal to a. Turning this around, we have a%b == a - (a/b)*b. So, you should be able to write: power *= 2; power -= (power/M) * M; Or, since you're only multiplying by two each time, you know that power cannot exceed M before this operation, so you can rewrite the above as: power *= 2; if (power &gt; M) { power -= M; }
accepted answer of: http://stackoverflow.com/q/21521807
answers question: http://stackoverflow.com/q/21521807
upvote count: 4
type: AcceptedAnswer
downvote count: 0
type: Answer

http://stackoverflow.com/q/21651444
has comment: http://stackoverflow.com/comment/32723118
tagged with: java
has comment: http://stackoverflow.com/comment/32723337
linked to: http://stackoverflow.com/q/5888204
type: Question
has answer: http://stackoverflow.com/a/21653327
answer count: 1
score: 0
tagged with: memory-mapped-files
tagged with: cryptography
tagged with: http://stackoverflow.com/tag/xml
type: UnansweredQuestion
tagged with: encryption
has title: Write a decrypted file to memory
has body: I have an XML file for storing session records in my Java project. The session records will be encrypted, but at times i will have to decrypt it. I have seen codes regarding encrypting and decrypting files, where the decrypted files are written as plain text file, which can be access or seen by the users. I don't want this to happen, I wish to fetch the encoded data from the encrypted file, decode it and store it in the memory for the later use like parsing the XML file. Is there any provision in Java to get the data from a byte[] array or a string and to save it into memory and to read it later from the memory? I know this is a dirty way to store data, but is there any other suggestion to encrypt and use the user sessions in an XML or plain text file, like how Google Chrome or Mozilla or other software save their encrypted cache in our computer and fetch it securely? I need something like that! I have no idea how they do that. Kindly assist me regarding this thing. Note that I do not wish to integrate MySQL with this Java project.

http://stackoverflow.com/q/21593321
tagged with: swing
answer count: 1
tagged with: jbutton
has answer: http://stackoverflow.com/a/21593377
tagged with: java
tagged with: border
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/21592492
accepted answer: http://stackoverflow.com/a/21593377
tagged with: imageicon
type: Question
has body: JPanel droppan = new JPanel (); droppan.setLayout (new FlowLayout ()); bi1 = new ImageIcon (""); b1 = new JButton (bi1); //b1.setBorderPainted (false); b1.setBorder (BorderFactory.createEmptyBorder (2,3,2,3)); b1.setContentAreaFilled (false); b1.setSize (100,38); //b1.setBounds(3,3,100,38); droppan.add(b1); b1.addMouseListener (this); add(droppan); This is actually a row of buttons but the code above is just a snippet of the first button. Initially, the first button has a border unless I click on another button and then that button now has the border, as if it "transfers" if you get what I mean. What am I doing wrong? the setborderpainted is a comment because even if it's not in a comment the border is still there This is a panel inside a frame
has title: setBorderPainted(boolean) not working
has comment: http://stackoverflow.com/comment/32622032
score: 0

http://stackoverflow.com/q/21556073
has answer: http://stackoverflow.com/a/22138767
possible better answer: http://stackoverflow.com/a/40313010
tagged with: rest
has answer: http://stackoverflow.com/a/40313010
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/3508338
score: 0
tagged with: java
accepted answer: http://stackoverflow.com/a/22138767
has body: I can not figure out, how to write the Rest Test. Please help me out. I have a RestService: @POST @Path("/insertDataInDB") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response insertDataInDB(@FormDataParam("inputfile") MultipartFormDataInput inputfile) { do Stuff } The Service works, i tested it with Chromes Rest Console. Request URI: http://localhost:8080/persDB/rest/r/insertDataInDB Content Type: multipart/form-data Attachements Files: Test.xlsx Parameter Key: inputfile How does the Rest Test look? I tried this But i can't quite figure it out, where to put the parameter key etc. @HttpTest(method = Method.POST, path = "persDB/rest/r/insertDataInDB", content = "{}", type = MediaType.MULTIPART_FORM_DATA, file = "inputfile.xlsx") public void insertDataInDB() { do Stuff } and i'm getting a java.io.IOException: 2014-02-04 16:01:30,825 [http-/0.0.0.0:8080-2] SEVERE org.jboss.resteasy.core.SynchronousDispatcher - Failed executing POST r/insertDataInDB: org.jboss.resteasy.spi.ReaderException: java.io.IOException: Unable to get boundary for multipart
type: Question
answer count: 2
has title: How to write Restfuse HttpTest with MULTIPART_FORM_DATA?
has comment: http://stackoverflow.com/comment/36971389
tagged with: junit
linked to: http://stackoverflow.com/q/5723429

http://stackoverflow.com/q/21660514
has answer: http://stackoverflow.com/a/21660730
linked to: http://stackoverflow.com/q/34413
tagged with: java
has body: when i run my java application with eclipse i don't get any problem but when i run it with the command prompt i get NoClassDefFoundError. C:\Windows\System32&gt;cd C:\Users\Caco\workspace\Bisquit_server\bin\bisquit_server C:\Users\Caco\workspace\Bisquit_server\bin\bisquit_server&gt;java ReceiveMsg Exception in thread "main" java.lang.NoClassDefFoundError: ReceiveMsg (wrong nam e: bisquit_server/ReceiveMsg) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:791) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482) C:\Users\Caco\workspace\Bisquit_server\bin\bisquit_server&gt; this is my java code: package bisquit_server; import java.io.*; import java.net.*; public class ReceiveMsg { private ServerSocket server_socket; private Socket socket; ObjectInputStream input_stream; private static String msg; public ReceiveMsg() throws IOException, ClassNotFoundException{ try { server_socket=new ServerSocket(50000,1); while(true){ listen(); System.out.print("Server is ready to connect to a client"); createStreams(); initProcessing(); } } finally {close();} } private void listen() throws IOException{ socket= server_socket.accept(); ReceiveMsgTh rmth = new ReceiveMsgTh(); Thread t = new Thread(rmth); } private void createStreams() throws IOException{ input_stream= new ObjectInputStream(socket.getIn…
has comment: http://stackoverflow.com/comment/32739171
tagged with: noclassdeffounderror
duplicate of: http://stackoverflow.com/q/34413
type: Question
answer count: 2
upvote count: 0
has answer: http://stackoverflow.com/a/21660594
has comment: http://stackoverflow.com/comment/34438210
favorite count: 0
has comment: http://stackoverflow.com/comment/32738816
score: -1
type: UnansweredQuestion
has title: I get NoClassDefFoundError, how can i fix it?
downvote count: 1

http://stackoverflow.com/a/21516715
has comment: http://stackoverflow.com/comment/32486472
answers question: http://stackoverflow.com/q/21516591
has comment: http://stackoverflow.com/comment/32486273
score: 0
has body: From Java 1.5 covariant return types are supported so basically the method getChildren() will be able to return any list of the subclasses of MusicComponent if the base class method is overriden. What you need to do is before you iterate check using instanceof to make sure that the list variable that you want to iterate is of the correct type.
type: Answer

http://stackoverflow.com/comment/32843820
type: AnswerComment
score: 0
type: Comment
has text: I cant run them as threads. They will be different processes only.
comment on: http://stackoverflow.com/a/21604560

http://stackoverflow.com/q/21525784
upvote count: 1
type: Question
tagged with: java
tagged with: graph
has title: Is there any way to dump both HTML data and Graph data into a pdf?
answer count: 1
downvote count: 0
tagged with: javascript
favorite count: 0
has body: On googling,I have found some graph creation software's like amcharts,fusion charts, etc. and PDF creation software's like iText etc which only creates graphs and writes to pdf respectively. Amcharts has an option of exporting to PDF as it exports only graph data but not html data. But my web application has both HTML data(tables,text in tags) and graphs. I have to write both html content and graph data to a single PDF file using javascript or Java .Is there any way to do this.I need to generate a graph from the data in the table and write both table and the created graph to PDF. Please help me.
tagged with: http://stackoverflow.com/tag/html
tagged with: pdf-generation
has answer: http://stackoverflow.com/a/21526128
accepted answer: http://stackoverflow.com/a/21526128
type: AnsweredQuestion
score: 1

http://stackoverflow.com/a/21560280
type: AcceptedAnswer
downvote count: 0
score: 4
type: Answer
has body: You can do this using login command. Lets get help for login command via help login: [/] &gt; help login description: Login to the current working Repository usage:login &lt;user&gt; &lt;password&gt; -workspace &lt;name&gt; &lt;arguments&gt; name argument required description ---------- ---------- ---------- ---------------------------------------- user user false registered user name [default=anonymous] password password false password [default = anonymous] &lt;options&gt; name argument required description ---------- ---------- ---------- ---------------------------------------- workspace name false workspace So you need to login like so: login admin admin -workspace anotherWorkspace
accepted answer of: http://stackoverflow.com/q/21560279
upvote count: 4
answers question: http://stackoverflow.com/q/21560279

http://stackoverflow.com/q/21557521
tagged with: fontmetrics
favorite count: 0
type: UnansweredQuestion
score: 1
upvote count: 1
tagged with: bufferedimage
has body: I want to create a PNG Image with Java. In this image I want to show some random Text. Normaly I would create a picture like this: BufferedImage bi = new BufferedImage(300,300,BufferedImage.TYPE_INT_ARGB); bi.getGraphics().drawString("Hello world", 0, 0); ImageIO.write(bi, "png", File.createTempFile("out", ".png")); I know that I can calculate the String length with the following code: bi.getGraphics().getFontMetrics().stringWidth("Hello world"); But to execute this, I need a Graphics Object (which I grab from the BufferedImage). So I must declare BufferedImage before I can use stringWidth. The result is, that the image is much bigger than needed. The only way I see is to create a "dummy BufferedImage". So I can calculate the needed width &amp; height and after that I can create a BufferedImage that fit. I can't find a better solution, but maybe someone can help me. Thanks a lot.
type: Question
tagged with: 2d
tagged with: java
has answer: http://stackoverflow.com/a/21558181
has title: Java 2D PNG: Calculate Dimension
answer count: 1
downvote count: 0

http://stackoverflow.com/comment/32656271
type: QuestionComment
comment on: http://stackoverflow.com/q/21613098
score: 0
has text: @MattBall with that I really meant if there was any difference in the number of instructions that would need to be executed to get the value of either `head` or `dummy` (not JVM instructions since those will obvoiusly differ [`aload` and something])
type: Comment

http://stackoverflow.com/comment/32526536
has text: @MadProgrammer, yes, the ID is relevant because I may require the items be in a certain order.
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21536113

http://stackoverflow.com/a/53306801
answers question: http://stackoverflow.com/q/21564757
score: 0
has body: File I/O - Checking a File or Directory Path path = ...; if (Files.exists(path)) /* the path exists */; if (Files.isDirectory(path)) /* the path exists and is a directory */; if (Files.isWritable(path)) /* the path is writable */;
type: Answer

http://stackoverflow.com/q/21579782
tagged with: custom-component
tagged with: java
tagged with: jtable
score: 0
has title: JTable not refreshed after mixing Row Header and combine/split code.
answer count: 2
tagged with: rowheader
has answer: http://stackoverflow.com/a/21581228
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21629565
tagged with: swing
has body: I am working in a project in which I have to show Row Numbers along with the functionality to Combine/Split cells in a JTable. To implement this functionality I followed the code from the url:- 1.) RowNumberHeader -> http://tips4java.wordpress.com/2008/11/18/row-number-table/ Then I followed the code to Combine/Split cells:- http://www.java3z.com/cwbwebhome/article/article5/swing_example/JTableExamples4.html After integration of the above code It looks like:- package com.test.jtable; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; import javax.swing.border.*; /** * @version 1.0 11/22/98 */ public class MixedExample extends JFrame { public MixedExample() { super( "Mixed Example" ); AttributiveCellTableModel ml = new AttributiveCellTableModel(100,5) { public Object getValueAt(int row, int col) { return "" + row + ","+ col; } }; CellAttribute cellAtt = ml.getCellAttribute(); MultiSpanCellTable table = new MultiSpanCellTable( ml ); table.setCellSelectionEnabled(true); table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); table.setDefaultRenderer(Object.class ,new AttributiveCellRenderer()); JTable jRowTable = new RowNumberTable(table); JScrollPane scroll = new JScrollPane(table); scroll.setRowHeaderView(jRowTable); scroll.setCorner(scroll.UPPER_LEFT_CORNER,jRowTable.getTableHeader()); scroll.setSize(300,300); ColorPanel colorPanel = new ColorPanel(table,(ColoredCell)cellAtt); FontPanel fontPanel = new FontPanel(table, (CellFont)cellAtt); SpanPanel spanPanel = new SpanPanel(table, (CellSpan)cellAtt); Box boxAtt = new Box(BoxLayout.Y_AXIS); boxAtt.add(colorPanel); boxAtt.add(fontPanel); boxAtt.add(spanPanel); Box box = new Box(BoxLayout.X_AXIS); box.add(scroll); box.add(new JSeparator(SwingConstants.HORIZONTAL)); box.add(boxAtt); getContentPane().add( box ); setSize( 400, 300 ); setVisible(true); } class ColorPanel extends JPanel { JTable table; ColoredCell cellAtt; ColorPanel(final JTable table, final ColoredC…
type: Question

http://stackoverflow.com/q/21640356
answer count: 1
has answer: http://stackoverflow.com/a/21640465
accepted answer: http://stackoverflow.com/a/21640465
has body: The resource class is defined like this: @Path("v1") @Produces({MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public class RestApi { And I have a method defined like this: @GET @Path("patients") public String patients( When I run the maven command to run the enunciate doc goal, the generated wadl looks like this: &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;wadl:application xmlns:wadl="http://wadl.dev.java.net/2009/02" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;wadl:doc xmlns:enunciate="http://enunciate.codehaus.org/" enunciate:generatedBy="Enunciate-1.27"/&gt; &lt;wadl:grammars&gt; &lt;wadl:include href="ns0.xsd"/&gt; &lt;/wadl:grammars&gt; &lt;wadl:resources base="http://localhost:8888/app/api"&gt; ... &lt;wadl:resource path="/rest/v1/patients"&gt; &lt;wadl:method name="GET"&gt; Where is this "/rest/" coming from in the resource path? I've searched everywhere in my project and there's no reference to it. Here's my enunciate.xml config file: &lt;enunciate label="Rest API" xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt; &lt;deployment host="localhost:8888" context="/app/api"/&gt; &lt;/enunciate&gt;
tagged with: rest
tagged with: jersey-1.0
tagged with: maven
type: AnsweredQuestion
tagged with: java
type: Question
has title: Enunciate: In my wadl, why do all my resources path attributes get prefixed with "/rest"?
score: 0
tagged with: enunciate

http://stackoverflow.com/comment/32638024
type: Comment
type: QuestionComment
has text: Yes, IntelliJ and all IDEs should have nothing to do with your deployment. You need to package it properly as an executable JAR. IntelliJ can be told to add that to the JAR manifest. Figure out how to tell it so.
comment on: http://stackoverflow.com/q/21602764
score: 0

http://stackoverflow.com/q/21654170
has answer: http://stackoverflow.com/a/21654288
has title: Attaining the correct number of 'a' characters in the String
has answer: http://stackoverflow.com/a/21654211
favorite count: 0
upvote count: 1
accepted answer: http://stackoverflow.com/a/21654211
linked to: http://stackoverflow.com/q/5223815
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21654218
has comment: http://stackoverflow.com/comment/32728064
has answer: http://stackoverflow.com/a/21654208
tagged with: java
has answer: http://stackoverflow.com/a/21654218
has answer: http://stackoverflow.com/a/21654231
type: Question
has body: I am trying to write a small program that takes a String sentence (given in main method), and calculates the number of upper case characters and number of a's. I am having a bit of trouble with the second part. While there are no doubt multiple ways to write the program, I have written for loops that trace through the String, and do my work. It works fine for calculating the uppercase values, but for the a's, it is counting every letter as one. I may be going crazy. public class CountCharacters { public static void main(String[] args) { charCount("How many UPPER CASE letters, a's, and 0-9 digits are there in this String?"); } public static void charCount(String b) { int upper = 0; int a = 0; for (int i = 0; i &lt; b.length(); i++) { char v = b.charAt(i); if (Character.isUpperCase(v)) { upper++; } } for (int i = 0; i &lt; b.length(); i++) { char t = b.charAt(i); if (Character.isLetter('a')) { a++; } } System.out.println("There are " + upper + " upper case letters, and " + a + " lower case a's in the String"); } }
has answer: http://stackoverflow.com/a/21654200
downvote count: 0
has comment: http://stackoverflow.com/comment/32728065
score: 1
answer count: 6

http://stackoverflow.com/comment/33080992
score: 1
comment on: http://stackoverflow.com/a/21849741
has text: I figured as much. On one hand I understand why (doesn't feel safe to be able to save someone's private key and stuff), but on the other hand... I don't know how to solve this. Whatever we need is private in that class.
type: AnswerComment
type: Comment

http://stackoverflow.com/q/21527625
has answer: http://stackoverflow.com/a/21527981
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21529063
tagged with: spring
tagged with: java
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/32505348
score: 0
has comment: http://stackoverflow.com/comment/32505311
has body: When a bean is declared inner bean then it should be destroyed with the destruction of Outer bean.But this is not happening in below case where destroy method of bean is not called. innerbeans-spring.xml &lt;bean id="car" name="carBean" class="com.semanticbits.shoaib.innerbeans.Car" destroy-method="destroy" init-method="init"&gt; &lt;property name="engine"&gt; &lt;bean class="com.semanticbits.shoaib.innerbeans.Engine" destroy-method="destroy" init-method="init"&gt; &lt;/bean&gt; &lt;/property&gt; &lt;/bean&gt; Car.java: Just required code written here public void init(){ System.out.println("Car init method"); } public void destroy(){ System.out.println("Car destroy method"); } public static void main(String[] args){ ConfigurableApplicationContext context=(ConfigurableApplicationContext)ApplicationContextFactory.getApplicationContext("innerbeans-spring.xml"); Car car=context.getBean("car",Car.class); context.getBeanFactory().destroyBean("car",car); } Engine.java : Just required code written here public void init(){ System.out.println("Engine init method"); } public void destroy(){ System.out.println("Engine destroy method"); } Output: Engine init method Car init method Car destroy method My question is: 1) getBeanFactory().destroyBean(String beanName,Object beanReference) What does beanName means here? 2)Why destroy method of Engine class is not called as Engine is inner bean to Car class?? Extending the question: public static void main(String[] args){ ConfigurableApplicationContext context=(ConfigurableApplicationContext)ApplicationContextFactory.getApplicationContext("innerbeans-spring.xml"); Car car=context.getBean("car",Car.class); context.getBeanFactory().destroyBean("car",car); //now here Car bean is destroy. //when I call then check the output section. context.getBeanFactory().destroySingletons(); } Extended Output: Engine init method Car init method Car destroy method Car destroy method Engine destroyed. 3)When Car instance was already destroyed then why Car…
tagged with: inversion-of-control
has title: How Inner bean is destroyed in Spring?
has comment: http://stackoverflow.com/comment/32504972

http://stackoverflow.com/a/22226880
has body: or this public static double LogNormal(double mean, double stddev) { Random randGen = new Random(); double varx = Math.pow(stddev, 2); double ess = Math.log(1.0 + (varx/Math.pow(mean,2))); double mu = Math.log(mean) - (0.5*Math.pow(ess, 2)); return Math.pow(2.71828, (mu+(ess*randGen.nextGaussian() ) ) ); }
score: 0
answers question: http://stackoverflow.com/q/21674599
type: Answer

http://stackoverflow.com/q/21568271
has answer: http://stackoverflow.com/a/21568394
tagged with: recursion
has title: Program flow on recursion with strings and ints
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21568611
has comment: http://stackoverflow.com/comment/32578006
score: 0
answer count: 3
has body: I don't understand how this works. I know basic factoral recursion, but this is of a mixed type. Could someone explain step by step on what's going on with the output based on this exact code snippet? Even just a few of the first values (commented at the end of the code)? Thanks :) public class recursion1st { public static String recFun(int x) { if (x &lt;= 0) return "/"; return recFun(x-3) + x + recFun(x-2) + x; } public static void main(String[] args) { System.out.println(recFun(8)); } } //Produces '/2/25/3/1/1358/3/1/136/1/14/2/2468 '(?)
tagged with: string
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21568372

http://stackoverflow.com/q/21564354
tagged with: security
answer count: 2
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/21747278
has title: is it possible to make sure the client used is from a particular host?
possible better answer: http://stackoverflow.com/a/21744755
has answer: http://stackoverflow.com/a/21744755
has body: I have a server application and a client application created with java that will communicate with the server application. But, since i haven't put emphasis on security in the server side it is really easy to hack the server application if a hacker creates his own client to connect with my server. I want to make sure the client application that is communicating with my server is the authentic client that i created. I upload client to a specific host like www.abcd.com. Now, can i make sure when a client that connects to my server came from that host. I am knowledgeable about signing it with trusted signer but i am looking for a cheap option.
type: AnsweredQuestion
score: 1
tagged with: java
tagged with: certificate
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/21747278

http://stackoverflow.com/comment/32540911
score: 0
type: AnswerComment
type: Comment
has text: check my answer to http://stackoverflow.com/questions/21545682/many-to-one-relationship-while-removing-child-object-its-throwing-exception
comment on: http://stackoverflow.com/a/21547156

http://stackoverflow.com/comment/32490968
has text: Probably not an exact duplicate, but this is a generic error message and you need to follow the steps in my answer to the linked question to provide useful information.
comment on: http://stackoverflow.com/q/21519424
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/51586043
has body: Another way result = (totalResults + pageSize - 1) / pageSize; // // eg: totalResults=10,pageSize=3 =&gt; result = 4 = (10 + 3 - 1) / 3 // eg: totalResults=12,pageSize=3 =&gt; result = 4 = (12 + 3 - 1) / 3 or result = totalResults / pageSize + totalResults % pageSize &gt; 0 ? 1 : 0 or result = (int) Math.ceil((float)totalResults/pageSize);
answers question: http://stackoverflow.com/q/21660987
downvote count: 0
type: Answer
upvote count: 6
score: 6

http://stackoverflow.com/comment/32738769
type: Comment
comment on: http://stackoverflow.com/q/21660471
type: QuestionComment
has text: It should work if you have algs4.jar in your references libraries.
score: 0

http://stackoverflow.com/comment/32511267
type: QuestionComment
type: Comment
has text: It appears that the device object is actually not null or "". The debugger whilst break-pointed was showing a pop-up window of "device = null" because that's how it's instantiated giving me the impression that it's null. My bad! Silly Pop-up window :(
comment on: http://stackoverflow.com/q/21530750
score: 0

http://stackoverflow.com/q/21631720
answer count: 1
accepted answer: http://stackoverflow.com/a/21632068
favorite count: 0
has comment: http://stackoverflow.com/comment/32688623
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32688651
tagged with: java
tagged with: http://stackoverflow.com/tag/json
score: -1
downvote count: 1
has comment: http://stackoverflow.com/comment/32688331
has title: Parsing Json in Android and set it in a ListView
type: Question
has answer: http://stackoverflow.com/a/21632068
has comment: http://stackoverflow.com/comment/32688314
has comment: http://stackoverflow.com/comment/32688756
upvote count: 0
has comment: http://stackoverflow.com/comment/32688703
has body: In my android project, I have the string text which got the following data: [ { "admin": true, "created_at": "2012-10-16T07:26:49Z", "email": "asdf@gmail.com", "id": 28, "language": "fr", "name": "Marc", "profile_pic_content_type": null, "profile_pic_file_name": null, "profile_pic_file_size": null, "profile_pic_updated_at": null, "provider": null }, { "admin": false, "created_at": "2013-04-02T18:47:36Z", "email": "asdf2@gmail.com", "id": 263, "language": "en", "name": "Marcus", "profile_pic_content_type": null, "profile_pic_file_name": null, "profile_pic_file_size": null, "profile_pic_updated_at": null, "provider": null } ] I converted it into a json object thanks to this: JSONObject jsonObj = new JSONObject(text); I want to parse that Json object, and setting it inside a ListView, but even with the official documentation I can't succeed in doing so. After parsing, I want to keep only the first part of the array, and delete every field excepting the email, language and name, to get this in the end: [ { "email": "asdf@gmail.com", "language": "fr", "name": "Marc" } ]
has comment: http://stackoverflow.com/comment/32688586
tagged with: android

http://stackoverflow.com/a/21656166
accepted answer of: http://stackoverflow.com/q/21656146
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/32731941
answers question: http://stackoverflow.com/q/21656146
has comment: http://stackoverflow.com/comment/32732441
has comment: http://stackoverflow.com/comment/32764243
has body: Try adding this dependency to your pom.xml javax.validation validation-api 1.0.0.GA If not consider using hibernate-validator4.2.0.Final I have that one in my config and it is working fine.
type: Answer
has comment: http://stackoverflow.com/comment/32731650
upvote count: 20
has comment: http://stackoverflow.com/comment/58075573
has comment: http://stackoverflow.com/comment/32732227
score: 20

http://stackoverflow.com/comment/32587872
type: AnswerComment
type: Comment
has text: add "e_mail" instead of "cnt"
score: 0
comment on: http://stackoverflow.com/a/21572144

http://stackoverflow.com/comment/32757174
comment on: http://stackoverflow.com/q/21670915
score: 0
has text: Shouldn't that be `My` and `Name` instead of `MyN` and `ame` in your expected output?
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32523266
comment on: http://stackoverflow.com/q/21537357
type: Comment
score: 0
has text: Are you using an IDE like Eclipse? If so, the IDE should highlight which line has the problems.
type: QuestionComment

http://stackoverflow.com/comment/32505849
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21528002
has text: If you are using Apache CXF for your web-services then trying to use the Spring Web Service infrastructure to secure the clients isn't going to work. You will have to use the Apache CXF infrastructure for this (or refactor your code to use Spring Web Services).
type: Comment

http://stackoverflow.com/comment/32628901
type: QuestionComment
has text: On which line do you get the NPE? Also, if you recently edited your layouts, clean and rebuild the project.
comment on: http://stackoverflow.com/q/21597477
score: 4
type: Comment

http://stackoverflow.com/comment/32558643
has text: Your build should create a .zip file of your application. The .zip file contains the .jar files. To install the app, you must unzip the .zip file. In this case, the .jar files will be available as `java.io.Files`.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21557412
type: AnswerComment

http://stackoverflow.com/comment/32713430
score: 0
comment on: http://stackoverflow.com/a/21645699
has text: Do it exactly like your post. make sure `adv` is in the `src`
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/32714816
type: AnswerComment
score: 0
type: Comment
has text: >> Does the user need to see the data placed on the model for the /first or /second page? Yes, I need to save a model.
comment on: http://stackoverflow.com/a/21641076

http://stackoverflow.com/comment/32759922
score: 0
comment on: http://stackoverflow.com/q/21670264
type: Comment
type: QuestionComment
has text: @user1781290 It's different from my problem.But I found that pipe can be used。

http://stackoverflow.com/a/21671012
has body: You might have forgot to create sequence "TICKET_SEQ". Try queries in the below format, CREATE TABLE "TICKET_TABLE" ( "TKT_NUMBER" NUMBER NOT NULL ENABLE, "TKT_STATUS" VARCHAR2(10), "TKT_CLIENT" VARCHAR2(10), "TKT_ASSIGN" VARCHAR2(15), "TKT_PROJ" VARCHAR2(15), "TKT_SUB" VARCHAR2(100), "TKT_BODY" VARCHAR2(200), "USER_NAME" VARCHAR2(15) NOT NULL ENABLE, CONSTRAINT "TICKET_TABLE_PK" PRIMARY KEY ("TKT_NUMBER") ENABLE ); CREATE sequence "TICKET_SEQ" minvalue 1 maxvalue 100 increment BY 1 start with 10; SET define OFF; CREATE OR REPLACE TRIGGER "BI_TICKET_TABLE" before INSERT ON "TICKET_TABLE" FOR EACH row BEGIN SELECT TICKET_SEQ.nextval INTO :NEW.TKT_NUMBER FROM dual; END; ALTER TRIGGER "BI_TICKET_TABLE" ENABLE;
score: 0
has comment: http://stackoverflow.com/comment/32811700
type: Answer
answers question: http://stackoverflow.com/q/21670627
has comment: http://stackoverflow.com/comment/32757290

http://stackoverflow.com/q/21665009
has comment: http://stackoverflow.com/comment/32747312
has comment: http://stackoverflow.com/comment/32747440
has answer: http://stackoverflow.com/a/21665074
tagged with: ajax
answer count: 2
has answer: http://stackoverflow.com/a/21665168
possible better answer: http://stackoverflow.com/a/21665074
downvote count: 0
has title: Converting XML to an HTML-String using XSLT in Java
favorite count: 0
tagged with: http://stackoverflow.com/tag/xml
has body: I can now generate an HTML file using the code: FileInputStream xml = new FileInputStream("original.xml"); FileInputStream xsl = new FileInputStream("converter.xsl"); FileOutputStream out = new FileOutputStream("result.html"); Source xmlDoc = new StreamSource(xml); Source xslDoc = new StreamSource(xsl); Result result = new StreamResult(out); TransformerFactory factory = TransformerFactory.newInstance(); Transformer trans = factory.newTransformer(xslDoc); trans.transform(xmlDoc, result); However, I want to generate a Java String instead of an external HTML file, so that I can pass the result back to my JSP page by Ajax callback. How can I modify this code to do that?
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21665168
has comment: http://stackoverflow.com/comment/32747463
score: 1
tagged with: java
upvote count: 1
type: Question
tagged with: xslt

http://stackoverflow.com/a/21540639
has body: because it wont get to "Tata" more than once, it only gets there when i=0, continue immediately begins the next iteration of the loop
answers question: http://stackoverflow.com/q/21540603
type: Answer
score: 0

http://stackoverflow.com/q/21623694
type: Question
tagged with: apache-camel
has comment: http://stackoverflow.com/comment/32674621
downvote count: 0
answer count: 1
has answer: http://stackoverflow.com/a/21643818
tagged with: jms
favorite count: 0
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/2828653
tagged with: activemq-classic
has title: Apache Camel sync multiple consumer
score: 1
tagged with: java
has body: I have a two instance of tomcat server running same web application due to durability. These web applications consume some queue/topic form ActiveMQ using Apache-camel lib. My issue is how to sync these two consumer so that only one consumer can get a particular message.I mean ActiveMQ send different message on each node.
upvote count: 1

http://stackoverflow.com/q/21632767
has comment: http://stackoverflow.com/comment/32691058
has answer: http://stackoverflow.com/a/21633139
accepted answer: http://stackoverflow.com/a/21633139
tagged with: jboss
has comment: http://stackoverflow.com/comment/32693851
has body: I'm trying to open the connection to WildFly for all the local network. When I set the hostname to localhost it works normally but just on this computer. But when I change the hostname to 0.0.0.0, it never finishes the starting process and it makes the IDE useless and makes other IDE tasks wait with following message: Waiting another process to finish
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/32693526
favorite count: 0
has comment: http://stackoverflow.com/comment/32690638
has title: WildFly, never start in 0.0.0.0
has comment: http://stackoverflow.com/comment/32690699
type: AnsweredQuestion
score: 2
upvote count: 2
tagged with: java
tagged with: wildfly
type: Question

http://stackoverflow.com/q/21555556
has answer: http://stackoverflow.com/a/21555827
type: AnsweredQuestion
downvote count: 0
tagged with: reflection
score: 1
tagged with: annotations
accepted answer: http://stackoverflow.com/a/21555797
type: Question
has title: Read annotation value from interface?
tagged with: java
has answer: http://stackoverflow.com/a/21555797
has comment: http://stackoverflow.com/comment/32553715
answer count: 2
upvote count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/32553960
has body: I am developing a framework which allows developers to do database operations through service layer. Service classes will send the database request dto object which will be annotated with sql ID to use as ID in MyBatis. Later I will read the annotation value by reflection. First of all, I created a custom annotation interface. @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface MyBatisMapper { String namespace() default ""; String sqlId() default ""; } And interface for database request dto object. public interface IReqDto { public String getDaoType(); } And database request dto object which will implement the above IReqDto interface. @MyBatisMapper(namespace="User", sqlId="userInsert") public class UserInsertReqDto implements IReqDto{ //beans and getters/setters } The above bean may vary as requirement of the developer. This is not part of the framework. Developer must implement IReqDto interface in any kind of database request object he use. What I am trying is to read the annotated values (namespace and sqlId) from database invoker class by using reflection. I understand that I can get the annotated value by doing this. Class&lt;UserInsertReqDto&gt; ReqDto = UserInsertReqDto.class; for(Annotation annotation : ReqDto.getAnnotations()) { System.out.println(annotation.toString()); } But my problem is, as the UserInsertReqDto will vary, I tried to use reflection to IReqDto interface. Class&lt;IReqDto&gt; ReqDto = IReqDto.class; Well, surely it doesn't work. The question is - how can I read the annotated value from database request object in this situation? Thanks.
possible better answer: http://stackoverflow.com/a/21555827

http://stackoverflow.com/a/21587978
has comment: http://stackoverflow.com/comment/32613118
answers question: http://stackoverflow.com/q/21587878
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/32613099
has comment: http://stackoverflow.com/comment/32613037
has body: List#subList is exactly suited for this purpose. int chunkSize = al.size() % 2 == 0 ? al.size() / 2 : (al.size() / 2) + 1; List&lt;Integer&gt; firstHalf = al.subList(0, chunkSize); There are two cases to consider: Even: If the size is even, then n / 2 is the correct size to chunk by. Odd: If the size is odd, then you need to add 1 to the result for the odd-length list to have the middle value.
has comment: http://stackoverflow.com/comment/32613154
score: 10
has comment: http://stackoverflow.com/comment/32613022
has comment: http://stackoverflow.com/comment/32612860
upvote count: 10

http://stackoverflow.com/comment/32495469
type: Comment
comment on: http://stackoverflow.com/a/21521971
score: 1
has text: This is one of the best answers in a while. A +1 well earned for the above explanation.
type: AnswerComment

http://stackoverflow.com/q/21661055
has body: I have a JTable with the column names " Names " , " Quantity " and " Unit " . I'm coding a program where you get the ingredients names. So i need to get the whole row of one column and String it all up together, because i need to store it in mySql and i have already set it all as String. Any idea how i can do this ? My code are as follows : JTable Code: DefaultTableModel model = (DefaultTableModel)table.getModel(); if(!txtQty.getText().trim().equals("")){ model.addRow(new Object[]{ingCB.getSelectedItem().toString(),txtQty.getText(),unitCB.getSelectedItem().toString()}); }else{ JOptionPane.showMessageDialog(null,"*Quantity field left blank"); } Getting the values and for storing : for(int i = 1; i&lt;= i ; i++){ ingredients = table.getName(); } This is for loop is wrong and it does not work because i have a constructor to take in Ingredients but because it is inside the loop, it cannot take it in. Any suggestions please ? Thank you. Constructor : Food e2 = new Food(Name, Description, priceDbl, Image, Category, Ingredients, promotion ); e2.createFood();
answer count: 1
tagged with: string
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21673030
tagged with: java
type: Question
has title: Getting a row of names from the first column of JTable
tagged with: jtable
score: 0

http://stackoverflow.com/a/77357219
has body: If we are using spring boot and lombok dependency on editor like sts/ eclipse/ intelliJ we need to make sure that lombok is configured means we need to install lombok in sts and eclipse and in intelliJ we need to enable annotation processing then only getters and setters will ge generated dynamically. I faced the same problem in sts and this works perfectly fine for me... Try to install lombok Lombok not working with STS
type: Answer
answers question: http://stackoverflow.com/q/21613703
has comment: http://stackoverflow.com/comment/136375964
score: 0

http://stackoverflow.com/comment/32659864
score: 0
type: AnswerComment
has text: Also, even if I get the webapp running, I am curious from an academic standpoint: why would unpacking a war be to differently named folders when nothing has been mentioned in any configuration file? What prompts the creation of a ROOT folder in particular?
type: Comment
comment on: http://stackoverflow.com/a/21614837

http://stackoverflow.com/comment/32666428
score: 0
comment on: http://stackoverflow.com/q/21618285
type: Comment
type: QuestionComment
has text: Given that there is no screen, what do you expect the "screenshot" to contain? If we knew that, we might be able to help you figure out a way to capture it.

http://stackoverflow.com/q/21629926
tagged with: spring
tagged with: spring-mvc
type: AnsweredQuestion
score: 3
downvote count: 0
tagged with: java
possible better answer: http://stackoverflow.com/a/25292929
type: Question
has comment: http://stackoverflow.com/comment/32686128
tagged with: spring-security
upvote count: 3
has answer: http://stackoverflow.com/a/21630593
has body: I have a Spring web application that is running just fine. I'm using JavaConfig, so there's not a lick of XML in the whole configuration. I'm trying to integrate Spring Security, but when I add a class that extends AbstractSecurityWebApplicationInitializer as directed by this tutorial, I get the following exception: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:251) ... Any idea how I can resolve this?
answer count: 3
accepted answer: http://stackoverflow.com/a/21630593
has title: Added Spring Security, now I'm getting "No WebApplicationContext found: no ContextLoaderListener registered?"
has answer: http://stackoverflow.com/a/28963957
has answer: http://stackoverflow.com/a/25292929
favorite count: 0

http://stackoverflow.com/a/21648596
type: Answer
has body: From my understanding, you get your 6th parity bit at 32 bits of input, 7th at 64, etc. so what you need is floor(lg(n)) + 1, which in java you can get by using 32 - Integer.numberOfLeadingZeros(n). Assuming your input is made up entirely of 0s and 1s, you would do int parityDigits = 32 - Integer.numberOfLeadingZeros(input.length());
accepted answer of: http://stackoverflow.com/q/21648397
answers question: http://stackoverflow.com/q/21648397
score: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32723794

http://stackoverflow.com/comment/35891768
type: QuestionComment
comment on: http://stackoverflow.com/q/21625150
score: 0
has text: Not a solution, but a work-around: keep your assertion in your `method` method and, after that, call a `unsafeMethod` that accepts the same arguments and has no assertions. You'll get the warning there
type: Comment

http://stackoverflow.com/q/21640027
has comment: http://stackoverflow.com/comment/32704262
possible better answer: http://stackoverflow.com/a/21640180
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21640180
tagged with: java
accepted answer: http://stackoverflow.com/a/21640151
has title: Bubble pop using boolean in java.
type: Question
tagged with: boolean
answer count: 2
tagged with: for-loop
has comment: http://stackoverflow.com/comment/32703967
has comment: http://stackoverflow.com/comment/32703972
tagged with: bubble-sort
has body: import java.util.*; public class Zhangbubble { public static void main (String[] args) { int Bub[] = new int[6]; Random randy = new Random(); boolean Done = false; for (int x=0; x&lt;6; x++) { Bub[x] = randy.nextInt(100); System.out.println (Bub[x]); } System.out.println ("This is the original array"); while (! Done) { Done = true; for (int x = 0; x&lt;Bub.length-1; x++) { if(Bub[x+1] &gt; Bub[x]) { int temp = Bub[x]; Bub[x] = Bub[x+1]; temp = Bub[x+1]; Done = false; } else { Done = false; } } for(int x = 0; x&lt;6; x++) { System.out.print(Bub[x]+" "); } } } } So my programming teacher asked us to make a bubble sort in java using a boolean. His example shows the code in a while loop with for loops. This code is suppose to continuously sort until it has the numbers in the array organized from least to greatest. However, I'm really lost and I can't seem to figure out where I'm going wrong. Any help would be greatly appreciated!
has answer: http://stackoverflow.com/a/21640151
score: 0
tagged with: while-loop
has comment: http://stackoverflow.com/comment/32703982
has comment: http://stackoverflow.com/comment/32703952

http://stackoverflow.com/q/21597271
type: Question
answer count: 2
downvote count: 0
tagged with: thrift
has answer: http://stackoverflow.com/a/21612402
accepted answer: http://stackoverflow.com/a/21612402
favorite count: 0
has title: Convert an object to a JSON string with thrift json serialization
tagged with: thrift-protocol
has comment: http://stackoverflow.com/comment/49036811
has body: I'm new to the thrift. I need to convert my data object to a JSON string with Thrift JSON serialization. I tried in this way. TSerializer serializer = new TSerializer(new TSimpleJSONProtocol.Factory()); String json = serializer.toString(object_name); In here is an error, that object_name should be in TBase. How can I resolve this ?
possible better answer: http://stackoverflow.com/a/21597552
upvote count: 7
has answer: http://stackoverflow.com/a/21597552
type: AnsweredQuestion
score: 7
tagged with: java
tagged with: http://stackoverflow.com/tag/json

http://stackoverflow.com/a/37522551
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21645516
has body: i had the same problem, the solution is so simple , you have to add this property to configuration's file 0

http://stackoverflow.com/comment/32634926
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/21599991
has text: @m0skit0 can you suggest some solution?

sax
tags question: http://stackoverflow.com/q/21548436
tags question: http://stackoverflow.com/q/21588619
tags question: http://stackoverflow.com/q/21614684
tag name: sax
tags question: http://stackoverflow.com/q/21624803
type: Tag

http://stackoverflow.com/q/21586919
has body: So we're exporting records from a Filemaker Pro database and submitting those files to our vendor via EDI, but their system cannot accept our files because of some really wonky ".." (Hex 0B) characters that show up at the beginning of every new line in the text document. I've read that there are issues with how Filemaker Pro exports their files and because of that these Hex 0B characters can't be deleted beforehand, from within Filemaker. I have a limited understanding of Java, would there be an adequate Java based run-time solution that could be created to fix this problem? I've tried exporting the text file in question in every available export method, including .mer, .csv, .tab, etc, with every combination of output file character set available for each export type, some create even more issues with hidden characters. I ended up settling on .tab (ASCII [DOS]) as it had the lowest amount of residual information, but I still need to get rid of these 0B characters for our EDI integration partner to be able to accept our files without any issue. EDIT: Added more information for clarity.
tagged with: filemaker
type: Question
has title: EDI Hex Character Issues
answer count: 1
has comment: http://stackoverflow.com/comment/32643229
has comment: http://stackoverflow.com/comment/32650781
has comment: http://stackoverflow.com/comment/32634565
has answer: http://stackoverflow.com/a/21648223
tagged with: hex
score: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32625316
tagged with: java

http://stackoverflow.com/comment/32709764
has text: @ItayB yes to [use format string you need to use printf](http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html)
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/21643694
type: Comment

http://stackoverflow.com/comment/32534386
type: AnswerComment
score: 0
has text: there is no error other than getextra and putextra because if I comment them the code is executing fine I'll post my logcat as well
type: Comment
comment on: http://stackoverflow.com/a/21544104

http://stackoverflow.com/q/21565633
has body: I need to loop through a 2D Java array diagonally both ways (front and back). I have been looking for a code that can help me to do this but I have not been able to find. For instance if I have A B C D E E F G H I J K L M N I need a code that can loop this array and find all the possible diagonals i.e. AFL, EK, J CHN, EHL, DGK, etc
answer count: 1
has comment: http://stackoverflow.com/comment/32573454
has answer: http://stackoverflow.com/a/21565698
favorite count: 0
tagged with: multidimensional-array
type: UnansweredQuestion
upvote count: 1
score: 0
tagged with: java
tagged with: loops
downvote count: 1
type: Question
has title: How to loop thrrough a 2D array diagonally in java
has comment: http://stackoverflow.com/comment/32572905

http://stackoverflow.com/comment/33009650
comment on: http://stackoverflow.com/a/21679252
score: 0
type: AnswerComment
has text: I added, but still same message. I also tried to annotate different ways - if I don't specify the bean name -
type: Comment

http://stackoverflow.com/q/21579461
answer count: 1
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32597248
has comment: http://stackoverflow.com/comment/32628397
downvote count: 0
has title: Binding errors with list
score: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/32598165
type: Question
has body: I generated a form: <form:form action="${contextPath}/draw/constraints.do" method="post" modelAttribute="order"> <c:forEach items="${order.myDrawsAsArray}" var="draw" varStatus="status"> <form:radiobutton path="myDrawsAsArray[${status.index}].readable" value="true" /> yes <form:radiobutton path="myDrawsAsArray[${status.index}].readable" value="false" /> no </c:forEach></form:form> When I submit it to update my entities, I got the following exception: org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property 'myDrawsAsArray[0]' of bean class [com.entity.Order3d]: Getter for property 'myDrawsAsArray' threw exception; nested exception is java.lang.reflect.InvocationTargetException org.springframework.beans.InvalidPropertyException: Invalid property 'myDrawsAsArray[0]' of bean class [com.entity.Order3d]: Getter for property 'myDrawsAsArray' threw exception; nested exception is java.lang.reflect.InvocationTargetException java.lang.reflect.InvocationTargetException java.lang.NullPointerException com.entity.Order3d.getMyDrawsAsArray(Order3d.java:121) My controller is like this: @Controller @RequestMapping("/draw") public class PrintingController { @RequestMapping(value="/constraints") public String constraints( @ModelAttribute Order3d order, @RequestParam("order") int id, @RequestParam(value="save", required=false) String save, Model m) { Session s=HibernateUtils.getSessionFactory().openSession(); if(save!=null) { System.out.println(order.getMyDraws()); for(DrawFile df : order.getMyDraws()) s.saveOrUpdate(df); } Order3d o=(Order3d)s.createCriteria(Order3d.class).add(Restrictions.eq("id", id)).uniqueResult(); m.addAttribute("order", o); s.close(); return "3dconstraints"; } } I also post my entities if you need them: @Entity @Table (name="order3d") public class Order3d implements Serializable { private static final long serialVersionUID = -2241346447352903470L; publ…
tagged with: spring-mvc
tagged with: java
has answer: http://stackoverflow.com/a/21582038
upvote count: 1

http://stackoverflow.com/a/21549311
has comment: http://stackoverflow.com/comment/32542993
answers question: http://stackoverflow.com/q/21548989
has body: If You can use Apache objectutils ObjectUtils.equals(Object object1, Object object2) -- Returns boolean Compares two objects for equality, where either one or both objects may be null. ObjectUtils.equals(null, null) = true ObjectUtils.equals(null, "") = false ObjectUtils.equals("", null) = false ObjectUtils.equals("", "") = true ObjectUtils.equals(Boolean.TRUE, null) = false ObjectUtils.equals(Boolean.TRUE, "true") = false ObjectUtils.equals(Boolean.TRUE, Boolean.TRUE) = true ObjectUtils.equals(Boolean.TRUE, Boolean.FALSE) = false
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/32542937

http://stackoverflow.com/comment/32492132
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21520218
has text: what do you mean by variable number of decimal place?

http://stackoverflow.com/q/21518998
has answer: http://stackoverflow.com/a/21519023
type: Question
has comment: http://stackoverflow.com/comment/32490189
has answer: http://stackoverflow.com/a/21519052
possible better answer: http://stackoverflow.com/a/21519023
linked to: http://stackoverflow.com/q/8664705
has body: I want to read nth line from the end of the file. However my file size is very huge like 15MB, so I cannot go through each line to find out the last line. Is there an efficient way to get this nth line ? I went through RandomAccessFile API however my line sizes are not constant so i was not able to move my file pointer to that nth line location from the end. Can some one help me.
score: 0
answer count: 2
has title: Read nth line from the end of the file
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21519052
tagged with: java
tagged with: file

http://stackoverflow.com/a/21564264
has comment: http://stackoverflow.com/comment/32570417
type: Answer
has body: You have to mention all 3 Activities in your Menifest.
score: 0
has comment: http://stackoverflow.com/comment/32570634
accepted answer of: http://stackoverflow.com/q/21564048
has comment: http://stackoverflow.com/comment/32570218
answers question: http://stackoverflow.com/q/21564048
has comment: http://stackoverflow.com/comment/32570683
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32570344

http://stackoverflow.com/comment/32657651
comment on: http://stackoverflow.com/q/21613699
score: 0
type: QuestionComment
has text: My manifest has Manifest-Version: 1.0 Ant-Version: Apache Ant 1.8.4 Created-By: 1.7.0_45-b18 (Oracle Corporation) Main-Class: com.test.Test
type: Comment

http://stackoverflow.com/q/21544405
has answer: http://stackoverflow.com/a/21562390
type: UnansweredQuestion
has title: post request after going through containerRequest shows 404 not found
tagged with: java
type: Question
tagged with: jersey
score: 0
answer count: 1
has body: The service request class works fine so does the service request helper , but the userauthservice is not hit! the program exits giving a 404 not found. this is my ServiceRequest class public class ServiceFilter implements ContainerRequestFilter{ @Context HttpServletRequest servletRequest; @Override public ContainerRequest filter(ContainerRequest request) { System.out.println("request : "+request); URI reqUri = request.getRequestUri(); System.out.println("req uri "+reqUri ); BufferedReader inFromClient = null; try { inFromClient = new BufferedReader(new InputStreamReader( request.getEntityInputStream(), "UTF-8")); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } String line; StringBuffer buff = new StringBuffer(); try { while ((line = inFromClient.readLine()) != null) { buff.append(line); } inFromClient.close(); } catch (IOException e) { e.printStackTrace(); } System.out.println("###### Request parameters- " + buff); String userName = null; String password = null; Long sessionId = null; String serviceMethodName = request.getPathSegments() .get(request.getPathSegments().size() - 1).getPath(); if (!NullObjects.isNull(reqUri) && !reqUri.toString().contains( CommonConstants.REPORT_SERVICE_URI)) { Response response = null; try { System.out.println("service method name : "+serviceMethodName); ObjectMapper mapper = new ObjectMapper(); Map filterParams = mapper.readValue(buff.toString(),HashMap.class); //call helper ServiceRequestFilterHelper helper = new ServiceRequestFilterHelper(); request = helper.setRequestParams(request, filterParams, serviceMethodName); } catch (Exception e) { e.printStackTrace(); throw new WebApplicationException(response); } } System.out.println("request"+request); System.out.println("request URI: "+request.getRequestUri()); System.out.println("request-QueryParameters-"+request.getQueryParameters()); return request; } } this is my serviceRequestFilterHelper Class public class ServiceRequestFilterHelper { String userName = null; St…

http://stackoverflow.com/comment/32597160
type: Comment
type: QuestionComment
has text: is it intentional that `map` and `portMap` are different?
score: 2
comment on: http://stackoverflow.com/q/21579560

http://stackoverflow.com/a/21664129
type: Answer
has body: There are a few ways to handle this, but I'd suggest looking at AtomicInteger, which is a mutable wrapper class for an int value.
score: 0
answers question: http://stackoverflow.com/q/21663948

http://stackoverflow.com/comment/32945492
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21659117
has text: Thank you @Ryuchan i will have a go and let you know the outcome. The web service was based on glass fish 4.0 and I am not sure if need to configure glass fish to accept POST. I can easily use GET to pass params and return JSON with out issue. Please also let me know if you know anything about how to configure web server to accept POST from client.

http://stackoverflow.com/a/22021981
has body: @Listeners and @Parameters annotations in a superclass will be inherited in the subclass. I have tested this and verified that it works. So, like my code example, the @Listeners annotation used in my TestBase parent class listened for any @Test annotations for a child class that inherited TestBase. The issue I was having was related to Sauce Labs test execution vs. Selenium Grid test execution vs. local test execution. I had to add logic to Sauce Lab's SauceOnDemandTestListener class to figure out if the test execution was indeed routing to Sauce Labs VM browser jobs. That logic is outside of the scope of my original question, so I won't post it here.
answers question: http://stackoverflow.com/q/21558054
type: Answer
accepted answer of: http://stackoverflow.com/q/21558054
score: 0
type: AcceptedAnswer

http://stackoverflow.com/comment/32750116
has text: The OP hasn't solved the problem yet. Just wait until they test their solution! :-)
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21666501

http://stackoverflow.com/comment/32487067
has text: All of those comments are correct. For the record, I followed this article which made me think my parameterized results were bad: http://homeguides.sfgate.com/calculate-monthy-mortgage-payments-9620.html - still trying to decide if I should be rounding operations like they did there - Google also decided to round some numbers when I ran them through which didn't help the situation.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21516811
score: 0

httpsurlconnection
type: Tag
tags question: http://stackoverflow.com/q/21646961
tag name: httpsurlconnection

http://stackoverflow.com/q/21523574
tagged with: regex
tagged with: templates
tagged with: http://stackoverflow.com/tag/xml
favorite count: 0
score: 2
downvote count: 0
has answer: http://stackoverflow.com/a/21523662
tagged with: xslt
type: AnsweredQuestion
has body: I wish to replace special characters like & ndash; and & mdash; occuring in an xml document with corresponding code like & #150; etc i have an input xml document containing several special characters <?xml version="1.0"?> The war was between1890–1900 something—something else there are several other characters like & rsquo; for single quotation my xslt code is as follows <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"> <xsl:output method="html" omit-xml-declaration="yes" indent="yes" /> <xsl:strip-space elements="*" /> <xsl:param name="pDest" select="'file:///d:/LWW_Book_ePub_Transform/Epub_ZipCreation/XSLT_Transform/Output/'" /> <xsl:template-match="P"> <xsl:apply-templates/> </xsl:template-match> <xsl:template-match="AF"> ..... <xsl:apply-templates/> ..... </xsl:template-match> </xsl:stylesheet> my java codes for parsing is as follow (i am making use of saxon9.) package com.xsltprocessor; import java.io.File; import java.io.FileInputStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Source; import javax.xml.transform.Templates; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; import org.w3c.dom.Document; public class ParseUsingSAX { public ParseUsingSAX() { } public void parseBookContent(String xsltFile) { try { //File inputXml = new File("D:\\data\\myxml.0f"); File xslt = new File(xsltFile); TransformerFactory factory = TransformerFactory.newInstance(); Templates template = factory.newTemplates(new StreamSource(new FileInputStream(xslt))); Transformer xformer = template.newTransformer(); Source source = new StreamSource(new FileInputStream(inputXml)); StreamResult result = new StreamResult(); xformer.transform(source,result); System.out.println("DONE");…
linked to: http://stackoverflow.com/q/21328857
tagged with: java
type: Question
upvote count: 2
possible better answer: http://stackoverflow.com/a/21524851
answer count: 2
has answer: http://stackoverflow.com/a/21524851
has title: Replace special characters like &ndash; and &mdash; occuring in an xml document with corresponding code like &#150; etc
linked to: http://stackoverflow.com/q/31870
accepted answer: http://stackoverflow.com/a/21523662

http://stackoverflow.com/comment/32653520
type: Comment
has text: I must have added in bad code earlier when I was making changes bc the mxl=++ml; and bitwise worked fine. It shaved off .02seconds against bitwise alone. https://codility.com/cert/view/cert6M3PPC-DEJER9V9WQM5BS6G/details
comment on: http://stackoverflow.com/a/21610420
type: AnswerComment
score: 0

http://stackoverflow.com/a/21522079
type: Answer
upvote count: 1
has body: Set the signle action listener on check boxes. Inside the listener code, you can read the state of all boxes involved (isSelected()) into separate boolean variables and make a decision which ones should be disable or enabled (setEnabled()).
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/21520695

http://stackoverflow.com/a/21570072
has comment: http://stackoverflow.com/comment/32581159
type: Answer
upvote count: 1
has body: No, there isn't. Sounds like a pretty easy thing to implement, though. Some options that jump to mind are: Include a CountDownLatch in the object to consume, and discard the item only when it reaches 0 Have two of the consumers not consume the item (peek the queue rather than pop it) Don't use consumers, use listeners Or if you're willing to use something outside of rt.jar, you could use a messaging queue. ActiveMQ and RabbitMQ are popular, they both support publish-subscribe. EDIT: brief description of listener pattern Instead of multiplie consumers, have a single ListenerManager consumer. It pulls an object from the queue, then passes it to all Listeners that have previously registered themselves with the ListenerManager. Finally, the ListenerManager disposes of the object. Have a single ListenerManager per queue, and a single queue per event/object type. This makes it easy to manage.
answers question: http://stackoverflow.com/q/21570013
downvote count: 0
score: 1

http://stackoverflow.com/q/21578266
tagged with: extract
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21578378
has title: Extract String from another string in Java
answer count: 4
tagged with: java
has body: Here is a string: "http://l2.yimg.com/bt/api/res/1.2/iis49xBsStLiYI6LjauR6Q--/YXBwaWQ9eW5ld3M7Zmk9ZmlsbDtoPTg2O3E9NzU7dz0xMzA-/http://media.zenfs.com/fr_FR/News/LeMonde.fr/1515504_3_f73c_le-cyber-harcelement-est-une-realite-trop-lo_450282425a88c544c2ff4121a5d9dab4.jpg" This string is a concatenation of two URLs. I would like to extract only the second URL: "http://media.zenfs.com/fr_FR/News/LeMonde.fr/1515504_3_f73c_le-cyber-harcelement-est-une-realite-trop-lo_450282425a88c544c2ff4121a5d9dab4.jpg" How can I do that using Java?
type: Question
has comment: http://stackoverflow.com/comment/32600194
has answer: http://stackoverflow.com/a/21578357
has answer: http://stackoverflow.com/a/21578368
score: 0
has answer: http://stackoverflow.com/a/21578324
tagged with: string
has comment: http://stackoverflow.com/comment/32594828

http://stackoverflow.com/comment/32681103
comment on: http://stackoverflow.com/a/21622962
score: 1
type: AnswerComment
has text: OK. But did you try to download the content to the file system? Is it possible that not the whole content is read from the server and that the problem is not the parsing but the downloading?
type: Comment

http://stackoverflow.com/comment/32487670
type: Comment
comment on: http://stackoverflow.com/q/21517564
has text: could you post the code that you have tried and where you are having difficulty
score: 0
type: QuestionComment

http://stackoverflow.com/q/21571503
has title: Understanding Linked List in Java
type: AnsweredQuestion
tagged with: list
tagged with: linked-list
downvote count: 0
has answer: http://stackoverflow.com/a/21571694
score: 1
tagged with: java
possible better answer: http://stackoverflow.com/a/21571603
has comment: http://stackoverflow.com/comment/32583230
type: Question
has answer: http://stackoverflow.com/a/21571624
accepted answer: http://stackoverflow.com/a/21571624
has comment: http://stackoverflow.com/comment/32583361
has comment: http://stackoverflow.com/comment/32583413
has answer: http://stackoverflow.com/a/21571603
has body: I am currently learning to implement linked list in Java when I came across sample code which counts nodes in a linked list class ListNodes { int item; ListNodes next; } int count(Node ptr_start) { int c=0; Node ptr = new Node(); ptr = ptr_start; while(ptr != null) { c++; ptr = ptr.next; } return c; } I have few questions here what exactly is ListNodes next; and 'ListNodes' has same name as that of it's class ? what is ptr = ptr_start; i think it's for pointer to start with a value , but can it have other values other than 'ptr_start' ? and ptr = ptr.next; I think it moves to next pointer but 'next' moves it to other pointer , it 'next' Java defined or user defined thing? It sort of seems like I don't understand anything is this code , please help?
has comment: http://stackoverflow.com/comment/32583437
answer count: 3
upvote count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/32583381

http://stackoverflow.com/comment/32698601
score: 0
has text: @MadProgrammer yes put my idea was store the data into the text file, formated like this -26, 55, 34, 44 etc and then copy paste it into the brackets of the array (new byte[]{-26, 55, 34, 44} but rest of the data, But i understand its a lot of data, the array length is 1,8million
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21636477

http://stackoverflow.com/comment/32707717
type: QuestionComment
has text: they mean by AggregateRoot and it's Identity is not SQL primary key! it depends on how you persist you aggregates, aggregate roots can have a reference of other aggregates.
comment on: http://stackoverflow.com/q/21640580
score: 0
type: Comment

http://stackoverflow.com/comment/32581941
has text: Thank you, that has solved it. I didn't know you could do that in the `glTexCoord2f` method, because I tried changing them to decimal points, and the picture ended up distorted, but I did not do it for all of them. Thank you.
type: AnswerComment
comment on: http://stackoverflow.com/a/21570598
type: Comment
score: 0

http://stackoverflow.com/q/21535903
type: Question
tagged with: encoding
score: 4
tagged with: servlets
upvote count: 4
has answer: http://stackoverflow.com/a/21536604
answer count: 1
downvote count: 0
has body: I'm currently working on a web application platform being called by other sites using POST forms. Some sites call us using UTF-8, others call us using ISO-8895-1. Since my application is in UTF-8, some of the characters passed by the calling sites appear weird on my side. Ex: Montréal -> Montr�al I tried to "convert" the string like this: new String(request.getParameter("city").getBytes("ISO-8895-1"), "UTF-8"); But i'ts not working, I'm getting "Montr?al" Is it possible to convert encoding like this? Is it possible to use different request encoding depending of the calling site?
has title: Spring web app encoding
has comment: http://stackoverflow.com/comment/32520651
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32520158
tagged with: spring
tagged with: java

http://stackoverflow.com/q/21575726
score: 1
favorite count: 0
type: UnansweredQuestion
tagged with: itextpdf
has answer: http://stackoverflow.com/a/21578709
tagged with: itext
upvote count: 1
has answer: http://stackoverflow.com/a/21577277
has body: I want to dynamically align the iText PdfTable. How to set the x and y position based alignment in iTextPDF. PdfPCell cell; cell = new PdfPCell(testTable); cell.setFixedHeight(44f); cell.setColspan(3); cell.setBorder(0); table.addCell(cell); table1.addCell(table);
has title: iTextPDF: changing the Table Alignment dynamically
type: Question
tagged with: java
answer count: 2
downvote count: 0

http://stackoverflow.com/q/21536833
tagged with: java
type: Question
has title: submit onchange using request mapping in spring mvc
tagged with: javascript
has comment: http://stackoverflow.com/comment/32522222
has answer: http://stackoverflow.com/a/21537717
score: 0
has body: Generating a Jasper report depending on the user selected values from drop down (have two drop downs). JSP: <form:form name="f" action="${flowExecutionUrl}" modelAttribute="simpleReportSelector"> <fmt:message key="report.someextract"/> <fmt:message key="somereport.sortdate"/> <c:forEach var="dl" items="${dateList}"> <c:if test="${dl.selected==false}"> ${dl.itemLabel} </c:if> <c:if test="${dl.selected==true}"> ${dl.itemLabel} </c:if> </c:forEach> <fmt:message key="somereport.equipNumber"/> <c:forEach var="u" items="${uldList}"> ${u.itemLabel} </c:forEach> Submit </form:form> When user selects this particular menu from header, page populates with datelist and uldlist. datelist will be defaulted to today date and uldlist with 'select'. When user selects a previous date or future date, uldlist supposed to populate with different list. controller: @Controller @RequestMapping("/uldReport.do") public class ULDReport { @Transactional(readOnly=true) @RequestMapping(value="/uldReport.do",method = RequestMethod.GET) public String setupForm(Model model, HttpServletRequest request, HttpServletResponse response) { //code to populate datelist and uld list(populates using present day) } @Transactional(readOnly=true) @RequestMapping(params={"reloadPage='true'"}, value="/uldReport.do", method = RequestMethod.GET) public String setUpUld(Model model, HttpServletRequest request, HttpServletResponse response) { //this should populate the uld list by using the date seelcted by user } @Transactional(readOnly=true) @RequestMapping(params={"reloadPage='false'"}, method = RequestMethod.POST) public ModelAndView processSubmit(@ModelAttribute SimpleReportSelector simpleReportSelector, Model model, HttpServletRequest request, HttpServletResponse response) throws IOException{ //some code } } First method works good, but when I change the date, app directs to an error page. I think may be something with @RequestMapping, if I remove params from second and third method in controller, app submits wit…
answer count: 1
tagged with: jsp
has comment: http://stackoverflow.com/comment/32522109
tagged with: spring
accepted answer: http://stackoverflow.com/a/21537717
tagged with: spring-mvc
type: AnsweredQuestion

http://stackoverflow.com/q/21613009
tagged with: spring-data
has answer: http://stackoverflow.com/a/21613512
has body: I am calling MongoTemplate.find(query, type) which returns a List&lt;T&gt;. My question, how do I remove all elements in the list from the DB Collection in one DB call. I know I could create a Query manually using id if I know the structure of T but what if I don't know what T is. MongoTemplate has a remove method that I can pass T. What I need is the equivalent removeAll(Collection&lt;T&gt; items, Class&lt;T&gt; type) EDIT per answer I need to process each element and determine which ones to remove so I cannot simply pass the Query to remove.
tagged with: mongodb
downvote count: 0
type: UnansweredQuestion
favorite count: 0
type: Question
tagged with: mongotemplate
score: 1
upvote count: 1
has title: MongoTemplate: remove list of elements returned from `find`
answer count: 1
tagged with: java

http://stackoverflow.com/a/61794252
upvote count: 3
has comment: http://stackoverflow.com/comment/139307121
has comment: http://stackoverflow.com/comment/135208065
downvote count: 1
answers question: http://stackoverflow.com/q/21581152
has body: Table relationships Let's assume we have the following post and post_comment tables, which form a one-to-many relationship via the post_id Foreign Key column in the post_comment table. Fetching a one-to-many DTO projection with JPA and Hibernate Considering we have a use case that only requires fetching the id and title columns from the post table, as well as the id and review columns from the post_comment tables, we could use the following JPQL query to fetch the required projection: select p.id as p_id, p.title as p_title, pc.id as pc_id, pc.review as pc_review from PostComment pc join pc.post p order by pc.id When running the projection query above, we get the following results: | p.id | p.title | pc.id | pc.review | |------|-----------------------------------|-------|---------------------------------------| | 1 | High-Performance Java Persistence | 1 | Best book on JPA and Hibernate! | | 1 | High-Performance Java Persistence | 2 | A must-read for every Java developer! | | 2 | Hypersistence Optimizer | 3 | It's like pair programming with Vlad! | However, we don't want to use a tabular-based ResultSet or the default List<Object[]>JPA or Hibernate query projection. We want to transform the aforementioned query result set to a List of PostDTO objects, each such object having a comments collection containing all the associated PostCommentDTO objects: We can use a Hibernate ResultTransformer, as illustrated by the following example: List<PostDTO> postDTOs = entityManager.createQuery(""" select p.id as p_id, p.title as p_title, pc.id as pc_id, pc.review as pc_review from PostComment pc join pc.post p order by pc.id """) .unwrap(org.hibernate.query.Query.class) .setResultTransformer(new PostDTOResultTransformer()) .getResultList(); assertEquals(2, postDTOs.size()); assertEquals(2, postDTOs.get(0).getComments().size()); assertEquals(1, postDTOs.get(1).getComments().size()); The PostDTOResultTransformer is going to define the mapping between the Object[] projection and th…
has comment: http://stackoverflow.com/comment/139306916
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/139305351

http://stackoverflow.com/q/21596845
has title: Creating and chaining LinkedList in for loop
has comment: http://stackoverflow.com/comment/32627899
score: 0
has answer: http://stackoverflow.com/a/21596986
accepted answer: http://stackoverflow.com/a/21596986
answer count: 1
type: AnsweredQuestion
tagged with: linked-list
has body: I am trying to create a new LinkedListNode object as I parse through a char[] in reverse. Then I want to link these char[] totalnum = (total + "").toCharArray(); for (int i = totalnum.length; i &gt; 0; i--) { LinkedListNode sum = new LinkedListNode(totalnum[i]); sum.next = null; } Here is my LinkedListNode class: public class LinkedListNode { int data; public LinkedListNode next; // constructor public LinkedListNode(int newData) { this.next = null; this.data = newData; } } I was wondering how can I go about doing this. I am new to Java so this has gotten me stumped! I know I should create a new LinkedListNode object in each iteration but that is as far as I have gotten
tagged with: java
type: Question

http://stackoverflow.com/q/21577990
has answer: http://stackoverflow.com/a/21581091
tagged with: javascript
has body: I want to set a CustomScrollPanel to height 100%; What I tried is to get the CustomScrollPanel to height 100% but it does not work that way. Here is want I tried. public class MyScrollPanel extends Composite implements HasWidgets { private ResizeLayoutPanel resizeLayoutPanel; private CustomScrollPanel customScrollPanel; public MyScrollPanel() { resizeLayoutPanel = new ResizeLayoutPanel(); resizeLayoutPanel.setStyleName(resources.css().resizeLayoutPanel()); customScrollPanel = new CustomScrollPanel(); customScrollPanel.addStyleName(resources.css().customScrollPanel()); resizeLayoutPanel.add(customScrollPanel); initWidget(resizeLayoutPanel); } My css: .resizeLayoutPanel { height: 100%; background-color: yellow; } How do I get the CustomScrollPanel to height 100%?
score: 0
tagged with: http://stackoverflow.com/tag/html
has title: How to set a CustomScrollPanel to height 100%?
has answer: http://stackoverflow.com/a/21578478
has comment: http://stackoverflow.com/comment/32596581
type: UnansweredQuestion
tagged with: css
tagged with: gwt
tagged with: java
type: Question
answer count: 2

http://stackoverflow.com/q/21650249
has answer: http://stackoverflow.com/a/21650462
tagged with: java
tagged with: http://stackoverflow.com/tag/json
tagged with: twitter
has title: Specific information from json string
type: Question
answer count: 2
downvote count: 0
possible better answer: http://stackoverflow.com/a/21650723
has answer: http://stackoverflow.com/a/21650723
accepted answer: http://stackoverflow.com/a/21650462
score: 1
favorite count: 0
upvote count: 1
type: AnsweredQuestion
has body: I've been playing around with tweets in Eclipse for a while, which are presented as a json string. To this end, I've created an object called Tweet (original, huh?) which takes certain information from the json string, and stores it in the Tweet object. Nothing fancy. My Tweet class looks as follows: public class Tweet implements TwitterMelding { public Tweet() { } String created_at; String id; String text; String user; public void setUser(String user) { this.user = user; } public void setText(String text) { this.text = text; } public void setId(String id) { this.id = id; } public void setCreated_at(String created_at) { this.created_at = created_at; } } Now, simple as it may look, there is one of those that doesn't work. Specifically String user. What it's suppose to do, is store user ID of the person who posted the tweet. The following is the tweet as obtained from Twitter in all it's horrible length: {"created_at":"Sat Feb 08 15:37:37 +0000 2014","id":432176397474623489,"id_str":"432176397474623489","text":"Skal begynne \u00e5 selge vekter.. Eneste m\u00e5ten det konstant kommer penger i lommen","source":"\u003ca href=\"http:\/\/twitter.com\/download\/iphone\" rel=\"nofollow\"\u003eTwitter for iPhone\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":366301747,"id_str":"366301747","name":"skinny-pete","screen_name":"JFarsund","location":"bj\u00f8rge","url":null,"description":"j\u00f8rgen er en tynn gutt med pack.. Men det teller vel ikke? Det gj\u00f8r vel ikke bio heller","protected":false,"followers_count":427,"friends_count":291,"listed_count":2,"created_at":"Thu Sep 01 23:03:49 +0000 2011","favourites_count":5103,"utc_offset":3600,"time_zone":"Copenhagen","geo_enabled":true,"verified":false,"statuses_count":8827,"lang":"no","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_ba…

http://stackoverflow.com/comment/32752772
score: 0
has text: @JoshM Can you take a look at it now?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21667586

http://stackoverflow.com/comment/32703225
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21638468
has text: sure :) , and you can post new question and feel free to mention me

http://stackoverflow.com/comment/32521516
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21516088
type: Comment
has text: Thank you! I'll try it out as soon as possible.

http://stackoverflow.com/comment/32538146
has text: not sure-- I believe those autobox into Object, and I need to save as much memory as I can, and none of those support the replace/max operation I need. also technically I'm storing byte, not int
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21546471
score: 0

http://stackoverflow.com/q/21569703
favorite count: 0
tagged with: javasound
type: UnansweredQuestion
tagged with: audio
has answer: http://stackoverflow.com/a/21574754
upvote count: 9
tagged with: java
has body: I'm writing an application that records the screen and audio. While the screen recording works perfectly, I'm having difficulty in getting the raw audio using the JDK libraries. Here's the code: try { // Now, we're going to loop long startTime = System.nanoTime(); System.out.println("Encoding Image....."); while (!Thread.currentThread().isInterrupted()) { // take the screen shot BufferedImage screen = robot.createScreenCapture(screenBounds); // convert to the right image type BufferedImage bgrScreen = convertToType(screen, BufferedImage.TYPE_3BYTE_BGR); // encode the image writer.encodeVideo(0, bgrScreen, System.nanoTime() - startTime, TimeUnit.NANOSECONDS); /* Need to get audio here and then encode using xuggler. Something like WaveData wd = new WaveData(); TargetDataLine line; AudioInputStream aus = new AudioInputStream(line); short[] samples = getSourceSamples(); writer.encodeAudio(0, samples); */ if (timeCreation &lt; 10) { timeCreation = getGMTTime(); } // sleep for framerate milliseconds try { Thread.sleep((long) (1000 / FRAME_RATE.getDouble())); } catch (Exception ex) { System.err.println("stopping...."); break; } } // Finally we tell the writer to close and write the trailer if // needed } finally { writer.close(); } This page has some pseudo code like while(haveMoreAudio()) { short[] samples = getSourceSamples(); writer.encodeAudio(0, samples); } but what exactly should I do for getSourceSamples()? Also, a bonus question - is it possible to choose from multiple microphones in this approach? See also: Xuggler encoding and muxing
linked to: http://stackoverflow.com/q/13839850
linked to: http://stackoverflow.com/q/4668863
score: 9
type: Question
linked to: http://stackoverflow.com/q/14542514
tagged with: xuggler
answer count: 1
downvote count: 0
has title: How to get Audio for encoding using Xuggler

http://stackoverflow.com/comment/32505029
type: Comment
has text: if suppose `map` is the map returned from Collections.synchronizedMap(...) then would thread3 also see value1 or it will like the same as ConcurrentHashMap?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21525756

http://stackoverflow.com/comment/32586874
type: AnswerComment
comment on: http://stackoverflow.com/a/21525188
score: 0
type: Comment
has text: I also have question, how to add method which will periodic check book status and if status changed it alert, with RCP ?

http://stackoverflow.com/comment/32620125
comment on: http://stackoverflow.com/q/21592056
type: Comment
has text: https://web.archive.org/web/20120504181858/http://www.antlr.org/wiki/display/ANTLR4/Examples
type: QuestionComment
score: 0

http://stackoverflow.com/a/21642037
answers question: http://stackoverflow.com/q/21642013
score: 1
has body: for(checkint != (int)checkint) Isn't valid syntax for a for loop. That's a while loop. Consider this: while (checkint != (int)checkint) A while loop has one condition and will loop until that condition is not met. A for loop is actually just a while loop in disguise, but has three conditions: starting point/initialization; condition; increment However, you can leave the starting point and the increment blank to simulate a while loop. HOWEVER this will put you in an ENDLESS LOOP. I don't know why you want a loop in the first place: Finally, you should actually be doing this: if (checkint != (int)checkint)
downvote count: 0
upvote count: 1
type: Answer

http://stackoverflow.com/comment/32730723
type: AnswerComment
comment on: http://stackoverflow.com/a/21655409
score: 0
type: Comment
has text: However, it is important to note that the IP address you get may not be the IP address of the real client machine. Consider the NAT case, and the HTTP proxy case.

import
type: Tag
tags question: http://stackoverflow.com/q/21555615
tag name: import
tags question: http://stackoverflow.com/q/21559670
tags question: http://stackoverflow.com/q/21646828
tags question: http://stackoverflow.com/q/21518627
tags question: http://stackoverflow.com/q/21639325
tags question: http://stackoverflow.com/q/21573758
tags question: http://stackoverflow.com/q/21669272
tags question: http://stackoverflow.com/q/21665857
tags question: http://stackoverflow.com/q/21630389
tags question: http://stackoverflow.com/q/21558092

http://stackoverflow.com/q/21604816
has title: nodes in Elasticsearch
type: AnsweredQuestion
tagged with: nosql
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/21607180
accepted answer: http://stackoverflow.com/a/21607180
tagged with: lucene
score: 0
has body: So I'm getting started with Elasticsearch, and I created a few nodes on my machine using: elasticsearch -Des.node.name=Node-2 Now, as far as I understand a node is another machine/server on a cluster, you can correct me if I'm wrong, now. 1.In order to add nodes to a cluster you need these machines to be on the same network? can I have a node in US and another node in the EU as part of the same structure? Or do they need to be in the same building, same network. 2.What is the idea with nodes? to split the data on multiple machines/nodes and also split power to calculate certain querys?
answer count: 1
tagged with: elasticsearch

http://stackoverflow.com/comment/32627196
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21596465
score: 1
has text: you are getting `[5652,8388,8388,7537,8843,2039,8235,0,12220]` String in Response or it is inside inner JSONObject of JSONArray?

http://stackoverflow.com/q/21662405
tagged with: java
answer count: 2
has answer: http://stackoverflow.com/a/21662954
tagged with: radio-group
has answer: http://stackoverflow.com/a/21662487
type: UnansweredQuestion
tagged with: radio-button
score: 3
downvote count: 0
has title: Android: How to check/uncheck a RadioButton inside a RadioGroup programmatically in Java
favorite count: 0
has body: I have to activities, MainActivity and settingsActivity. Because of that I'm using the methods onPause and onResume in the settingsActivity. So that the things I have done in the settingsActivity are saved after switching to MainActivity and back again. settingsActivity: Here I have a TextView (called "settings2") as a kind of variable and my three RadioButtons (radio0, radio1 and radio2) which are inside a RadioGroup. After switching to the MainActivity my programe puts "0" in a file (which is saved on the sdcard) if radio0 was last checked. But if radio1 was last checked, it puts 1 in that file. And if radio2 was last checked, it puts 2 in that file. I used this in the method onPause. Then in the method onResume I read the text of that file and put it in the TextView "settings2". After this code (still in onResume) I want to check/uncheck my RadioButtons. So if the text of the TextView "settings2" is "0" the RadioButton "radio0" shall be checked and the others not. If the text of this TextView is "1" the RadioButton "radio1" shall be checked and the others not. And if the text of this TextView is "2" the RadioButton "radio2" shall be checked and the others not. To do this I used the following two codes but unfortunately they didn't work. First code: if (settings2.getText().equals("0")) { radio0.setChecked(true); radio1.setChecked(false); radio2.setChecked(false); } else if (settings2.getText().equals("1")) { radio0.setChecked(false); radio1.setChecked(true); radio2.setChecked(false); } else if (settings2.getText().equals("2")) { radio0.setChecked(false); radio1.setChecked(false); radio2.setChecked(true); } Second code: if (settings2.getText().equals("0")) { radioGroup1.check(R.id.radio0); } else if (settings2.getText().equals("1")) { radioGroup1.check(R.id.radio1); } else if (settings2.getText().equals("2")) { radioGroup1.check(R.id.radio2); } Can someone help with this little problem please? I'm looking forward to your help! Thanks in advance!
type: Question
tagged with: android
upvote count: 3

http://stackoverflow.com/a/21515188
has body: Since Path cannot be iterated you better use it as object of output nature, so basically you should initially fill ArrayList with points and when use this ArrayList to construct path or even create separate function for that.
type: Answer
answers question: http://stackoverflow.com/q/21514925
score: 0

http://stackoverflow.com/q/21616939
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32663519
tagged with: android
has comment: http://stackoverflow.com/comment/32663562
tagged with: java
has title: I have heaps of redundant code. The set of letters come in the json file and i want to parse whatever is there
has answer: http://stackoverflow.com/a/21617048
downvote count: 1
tagged with: android-uiautomator
type: Question
score: -1
tagged with: data-structures
upvote count: 0
answer count: 1
has body: package automate; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Vector; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.graphics.Point; import com.android.uiautomator.core.UiDevice; import com.android.uiautomator.testrunner.UiAutomatorTestCase; public class AlphabetGestures extends UiAutomatorTestCase { private static Map&lt;Character,Vector&lt;Point&gt;&gt; map = new HashMap&lt;Character,Vector&lt;Point&gt;&gt;() ; private static JSONObject jsonObj; static{ String text; try { File file = new File("/data/misc/alphaNums.json"); FileInputStream fis = new FileInputStream(file); byte[] data = new byte[(int)file.length()]; fis.read(data); fis.close(); text = new String(data, "UTF-8"); jsonObj = new JSONObject(text); } catch(JSONException e){ e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } /*I am not able to implement the following algorithm:- I want to create a map for all the characters &lt;- already there in the static bloc open the alphaNum.json file &lt;- already there in the static bloc,but not error handling. parse it as a json object &lt;- already there in the static bloc, for every letter in the json object { create a vector&lt;Point&gt; for every Point in the letter { add the Point to the vector } add the vector to the map } */ Vector&lt;Point&gt; liA = setupA(); Vector&lt;Point&gt; liB = setupB(); Vector&lt;Point&gt; liC = setupC(); map.put('A',liA) ; map.put('B',liB) ; map.put('C',liC) ; } private static Vector&lt;Point&gt; setupA(){ try { JSONArray jsonArr = jsonObj.getJSONArray("A"); System.out.println("IS here"); //get array A if(jsonArr!=null){ Vector&lt;Point&gt; apoints = new Vector&lt;Point&gt;(); System.out.println("IS here"); for(int k = 0; k &lt; jsonArr.length(); k++ ){ JSONArray arr = jsonArr.getJSONArray(k); apoints.add(new Point(arr.getInt(…

http://stackoverflow.com/q/21546540
has answer: http://stackoverflow.com/a/69953290
has body: I have done a video player using vlcj library of vlc media player. Here is my code to do that.. public class Player { public static void main(final String[] args) { NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "C:\\Program Files\\VideoLAN\\VLC"); Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Player(args); } }); } private Player(String[] args) { JFrame frame = new JFrame("vlcj Tutorial"); MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(); Canvas c = new Canvas(); c.setBackground(Color.black); JPanel p = new JPanel(); p.setLayout(new BorderLayout()); p.add(c, BorderLayout.CENTER); frame.add(p, BorderLayout.CENTER); EmbeddedMediaPlayer mediaPlayer = mediaPlayerFactory.newEmbeddedMediaPlayer(); mediaPlayer.setVideoSurface(mediaPlayerFactory.newVideoSurface(c)); frame.setLocation(100, 100); frame.setSize(1050, 600); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); mediaPlayer.playMedia("D:\\EmbeddedMediaPlayer\\test.3gp"); } } I can play a video using this code, but how can I see the same video on full screen like vlc media player? How to apply maximizing (full screen) and minimizing on a double-click event by mouse right button?
tagged with: java
score: 2
accepted answer: http://stackoverflow.com/a/21547905
type: AnsweredQuestion
downvote count: 0
has title: vlcj Full Screen video player
tagged with: awt
tagged with: vlcj
favorite count: 0
type: Question
tagged with: vlc
upvote count: 2
answer count: 2
possible better answer: http://stackoverflow.com/a/69953290
has answer: http://stackoverflow.com/a/21547905
tagged with: swing

http://stackoverflow.com/a/21529879
type: Answer
score: 0
answers question: http://stackoverflow.com/q/21529544
has body: Ok got the answer guys. Thanks. Compiling the points as: Class loads (with static members) Object loads (First IIB executes, then values assigned to the NS variables) Constructor called by "this" pointer

http://stackoverflow.com/q/21523199
type: UnansweredQuestion
tagged with: selenium
has answer: http://stackoverflow.com/a/28496271
has answer: http://stackoverflow.com/a/21666111
tagged with: selenium-webdriver
has answer: http://stackoverflow.com/a/21523763
tagged with: java
has answer: http://stackoverflow.com/a/34665796
answer count: 6
type: Question
has comment: http://stackoverflow.com/comment/32496953
has title: How can I select all the options in a drop down- Selenium Webdriver?
score: 0
tagged with: http://stackoverflow.com/tag/html
has answer: http://stackoverflow.com/a/52960652
has comment: http://stackoverflow.com/comment/32497055
has comment: http://stackoverflow.com/comment/32497026
has answer: http://stackoverflow.com/a/71645587
has body: Currently working on Selenium WebDriver and using Java. If I have drop down name called Product.. In that drop down I have so many values (for ex:60). when executing the code I deselect all option then I selected which option I want because by default all values are selected in the HTML.. and it is working fine.. In the same way if I want to select all options at the same time.. How can I perform the action. 1020 ROUTER SERIES 1030 ROUTER SERIES 1040 ROUTER SERIES 1061 ROUTER and so on.. Here is the sample code: Log.info("Clicking on Product dropdown"); JavascriptExecutor executor31 = (JavascriptExecutor)driver; executor31.executeScript("document.getElementById('ProductId').style.display='block';"); Select select31 = new Select(driver.findElement(By.id("ProductId"))); select31.deselectAll(); select31.selectByVisibleText("1222"); Thread.sleep(6000); JavascriptExecutor executor32 = (JavascriptExecutor)driver; executor32.executeScript("document.getElementById('ProductId').style.display='block';"); Select select32 = new Select(driver.findElement(By.id("ProductId"))); select32.selectByVisibleText("1020");

http://stackoverflow.com/comment/32676006
comment on: http://stackoverflow.com/a/21624702
score: 9
has text: With the qualification that in Java, "someone" means "a committee of top-class experts" :)
type: AnswerComment
type: Comment

http://stackoverflow.com/a/21610163
score: 1
has body: The regex you've provided for the delimiter isn't doing what you think it is. I would take this approach instead. String input = scanner.nextLine(); String[] array = input.split(":"); String label = array[0]; String data = array[1]; String[] number = data.split(","); Integer x = new Integer(number[0]); Documentation for String#split()
upvote count: 1
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21610021
type: Answer
accepted answer of: http://stackoverflow.com/q/21610021
downvote count: 0

http://stackoverflow.com/q/21632136
tagged with: eclipse
has answer: http://stackoverflow.com/a/21638023
type: Question
tagged with: plist
has title: Java Mac App Hiding Dock Icon
has comment: http://stackoverflow.com/comment/32695468
score: 0
answer count: 1
has comment: http://stackoverflow.com/comment/32692985
tagged with: macos
type: UnansweredQuestion
tagged with: java
linked to: http://stackoverflow.com/q/2762456
has body: I recently wrote a small Java application with Eclipse and packaged the exported Runnable Jar using Apple's Jar Bundler. Everything works great, except my plist keys for hiding the application icon in the dock. I have tried previous plist keys I have used before to hide my dock icon, but they are not working. I run my app, the icon shows up in the dock and sits there bouncing for a while, then it stops bouncing and just sits there. I don't want the Dock icon shown, and I don't want a system tray icon. I am just needing my app to run in the background. Keys I have tried and had no luck. apple.awt.UIElement true and Application is agent (UIElement) set to True/Yes in Plist Editor UPDATE: Here is my plist. My app still bounces in the dock. If I let it sit for a while it will eventually start to work. <?xml version="1.0" encoding="UTF-8"?> LSUIElement 1 CFBundleName My App CFBundleIdentifier org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader CFBundleVersion 100.0 CFBundleAllowMixedLocalizations true CFBundleExecutable JavaApplicationStub CFBundleDevelopmentRegion English CFBundlePackageType APPL CFBundleSignature ???? CFBundleGetInfoString My App CFBundleInfoDictionaryVersion 6.0 CFBundleIconFile icon.icns Java WorkingDirectory $APP_PACKAGE/Contents/Resources/Java MainClass org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader JVMVersion 1.6+ ClassPath $JAVAROOT/myapp.jar Properties UPDATE 2: When I run my java application using terminal command sudo open /Applications/MyJava.app it runs fine. If I run my app normally, and let it bounce on the dock for a while it will eventually run. I would prefer not prompting the user for credentials to just run my simple app.

http://stackoverflow.com/q/21618495
has answer: http://stackoverflow.com/a/21618918
tagged with: java
has body: I'm trying to get five random numbers printed that never repeat, based on a certain range provided by the user. Posted below is the code I have so far. Firstly, I don't know how to list the numbers found in the ArrayList, or even if I should use ArrayList over just an Array. Any thoughts? package h1p2; import java.util.ArrayList; public class test{ public void method (int min, int max){ //Declare and initialize arrays and index variables ArrayList&lt;Integer&gt; rangeOne = new ArrayList&lt;Integer&gt;(); ArrayList&lt;Integer&gt; rangeMinMax = new ArrayList&lt;Integer&gt;(); int z = min; int i = 0; int q = 0; //int rangeLength = rangeMinMax.length; //need minimum/max differential of 50 or &gt; to execute method if (max - min &lt; 50){ System.out.println("Please enter numbers with a differential of 50 or greater."); } //run if differential checks out else{ while (z &lt;= max &amp;&amp; z &gt;= min ){ rangeMinMax.set(z, 1); i++; } } while (q &lt; 5){ int randomNumber = (int)(rangeMinMax.size() * Math.random()); if (randomNumber == rangeOne.indexOf(0)|| randomNumber == rangeOne.indexOf(1) || randomNumber == rangeOne.indexOf(2) || randomNumber == rangeOne.indexOf(3) || randomNumber == rangeOne.indexOf(4) || randomNumber == rangeOne.indexOf(5)){ break; } else{ rangeOne.set(q, randomNumber); } q++; } System.out.println("The numbers are " + ) } }
type: Question
has title: How do I get a list of five random numbers to be printed without duplicates in Java?
has comment: http://stackoverflow.com/comment/32666170
tagged with: arrays
answer count: 1
linked to: http://stackoverflow.com/q/21324959
tagged with: arraylist
has comment: http://stackoverflow.com/comment/32666876
has comment: http://stackoverflow.com/comment/32667008
type: UnansweredQuestion
score: 0

http://stackoverflow.com/comment/32706280
has text: what is model.param().set(...)?
score: 1
type: Comment
comment on: http://stackoverflow.com/q/21641463
type: QuestionComment

http://stackoverflow.com/comment/32609482
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21578954
has text: Now I created a new clean JAX-RS project only based on Jersey 2. Now I can use javax.ws.rs.container.ContainerRequestFilter and bind it to certain methods of my services. works perfectly now. Thanks!!
type: Comment

http://stackoverflow.com/comment/32756170
has text: In that case would something like `scanner.useDelimiter(System.getProperty("line.separator"));` help?
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21670209

http://stackoverflow.com/a/21655441
has body: My first use of mapreduce was something almost exactly like this. I had to add a property to my image models and I did it like this: In mapreduce.yaml mapreduce: - name: cleanimages mapper: input_reader: mapreduce.input_readers.DatastoreInputReader handler: main.process params: - name: entity_kind default: main.Image Then what you want to happen, you put in the process code: def process(entity): entity.small = None yield op.db.Put(entity) In this case I just set one of the variables to None since it was no longer used, but you can put any code there you like, creating a new property and saving the entity like abose. You can find more info at the mapreduce site.
answers question: http://stackoverflow.com/q/21638552
score: 0
type: Answer

http://stackoverflow.com/comment/32501976
type: Comment
has text: Are you able to navigate to expedia.com.nl manually in a browser inside the same machine?
comment on: http://stackoverflow.com/q/21523824
score: 0
type: QuestionComment

http://stackoverflow.com/comment/32706606
comment on: http://stackoverflow.com/a/21596521
type: Comment
has text: No need to put the tld's in WEB-INF since we are using the struts-taglib-1.3.10.jar as a dependency jar
score: 0
type: AnswerComment

http://stackoverflow.com/q/21541745
tagged with: jdbc
has comment: http://stackoverflow.com/comment/32531613
type: AnsweredQuestion
score: 3
tagged with: stored-procedures
has comment: http://stackoverflow.com/comment/32534169
has comment: http://stackoverflow.com/comment/32576819
upvote count: 3
tagged with: java
has title: PostgreSQL 9 JDBC driver returns incorrect metadata for stored procedures
type: Question
has comment: http://stackoverflow.com/comment/32536254
has answer: http://stackoverflow.com/a/21742863
tagged with: sql
accepted answer: http://stackoverflow.com/a/21742863
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/32543326
favorite count: 0
has body: I am on a team that develops a business intelligence (reporting) tool. We report off many sources include Stored Procedures. We use the meta-data provided by the JDBC driver to determine the input and output paramters of a Stored Procedure. It appears that PostgreSQL 9 JDBC drivers are incorrectly returning meta-data for the parameters of a procedure. For instance my stored procedure looks like this: CREATE FUNCTION person(personid int) RETURNS TABLE(person int, name varchar(200)) AS $$ BEGIN RETURN QUERY SELECT ipperson, firstname FROM person WHERE ipperson = personid; END; $$ LANGUAGE plpgsql; So it has one paramter in, two columns returned in a resultset. The PostgreSQL driver is reporting that there are 3 IN parameters. personid (the parameter) person (first column returned) name (second column returned) with no meta-data to distinguish between types. I execute this with: SELECT * FROM person(?); (As a prepared statement, setting values for each ? token) I know that I can filter using the columns returned like this: SELECT * FROM person(5) where person = 5; But I am more interested in getting only the parameters returned by the meta-data, so I can programmatically build the query string (I need to know how many ?'s to put in the query). Not sure if this is a bug, or whether I am doing something wrong. If I use a PostgreSQL 8 driver, it seems to return the correct number of parameters: personid (the parameter) Thanks. Specific Driver/Server versions are: PostgreSQL Server 9.11 (Mint 16) PostgreSQL "8" 8.0 JDBC3 with SSL(build 313) PostgreSQL "9" 9.3 JDBC4 (build 1100) Additional Information to replicate what I am seeing: DB Scripts: CREATE TABLE testtable ( id integer, name varchar ); INSERT INTO testtable VALUES (1, 'Bob'); CREATE FUNCTION testproc(itemid int) RETURNS TABLE(id int, name varchar(200)) AS $$ BEGIN RETURN QUERY SELECT ipperson, firstname FROM testtable WHERE id = itemid; END; $$ LANGUAGE plpgsql; Java Code: package com.hof.unittest; import java.sql…
tagged with: postgresql

cryptography
tag name: cryptography
tags question: http://stackoverflow.com/q/21570972
tags question: http://stackoverflow.com/q/21658033
type: Tag
tags question: http://stackoverflow.com/q/21664967
tags question: http://stackoverflow.com/q/21626688
tags question: http://stackoverflow.com/q/21581347
tags question: http://stackoverflow.com/q/21655286
tags question: http://stackoverflow.com/q/21559079
tags question: http://stackoverflow.com/q/21594387
tags question: http://stackoverflow.com/q/21651444

http://stackoverflow.com/q/21650626
tagged with: ssh
tagged with: shell
has comment: http://stackoverflow.com/comment/32788925
has answer: http://stackoverflow.com/a/21692777
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21692777
tagged with: java
has title: Invoking shell script contains SSH from java
type: Question
upvote count: 4
has comment: http://stackoverflow.com/comment/32867510
answer count: 2
has body: I am trying to invoke a shell script containing SSH command from a java program. However it is failing with a error code 1. My java code is as: public class CallScript { private static String filePath=""; private static String args1=""; public static void main(String[] args) throws Exception{ if(args!=null &amp;&amp; args.length &gt; 0){ filePath = args[0]; if(args.length &gt; 1){ args1=args[1]; } }else{ throw new Exception("File Path should be first Argument"); } System.out.println(args.length); invokeScript(filePath,args1); } private static void invokeScript(String filePath, String arg1) throws Exception{ System.out.println("Inside invoke Script " + arg1); Process p = Runtime.getRuntime().exec(filePath); p.waitFor(); int exitVal = p.exitValue(); System.out.println("The Exit Value " + exitVal); } } I compiled the program and placed the executable jar in my Unix environment. shell script which is invoked from java ssh -l &gt;test.log I used the following command to run my java program : java -jar invokeScript.jar /tmp/upog/test.sh output Inside invoke Script The Exit Value 1. If I have some other command in the shell script like ls -al &gt; test.log, the code is working with success and I am getting the return value 0. Also if I invoke the shell script containing ssh command directly in Unix box, it is working fine.(the box have password-less connectivity) But it is failing, if i call from java... Any advice....
downvote count: 0
has answer: http://stackoverflow.com/a/21778204
score: 4
has comment: http://stackoverflow.com/comment/32859447
favorite count: 0
tagged with: bash
has comment: http://stackoverflow.com/comment/32789923
possible better answer: http://stackoverflow.com/a/21778204

http://stackoverflow.com/comment/32739800
has text: I just did, but nothing will happen.
comment on: http://stackoverflow.com/a/21660985
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/21644909
answer count: 1
tagged with: timedelay
favorite count: 0
linked to: http://stackoverflow.com/q/11068257
tagged with: android
has comment: http://stackoverflow.com/comment/32784235
has comment: http://stackoverflow.com/comment/32711780
type: AnsweredQuestion
upvote count: 3
has answer: http://stackoverflow.com/a/21645183
linked to: http://stackoverflow.com/q/4199191
accepted answer: http://stackoverflow.com/a/21645183
tagged with: java
downvote count: 3
has body: I have an Activity that I want to run a Delay Function when it runs. I [i]don't[/i] want a delay in OnClick function, I want delay when activity [i]starts[/i]. I have tried the following solutions : How to set delay in Android onClick function How to pause/delay on Android? Android: Timer/Delay Alternative Android timer set delay ...and some more and none of them did what I want. I want a delay when activity starts (for my project , when The Game Starts) but with that codes, it starts the delay (e.g 10s) when I put my finger on the screen.
has comment: http://stackoverflow.com/comment/32744491
type: Question
has title: Delay Function on Android Project
linked to: http://stackoverflow.com/q/4063526
has comment: http://stackoverflow.com/comment/32712036
linked to: http://stackoverflow.com/q/6284095
score: 0

http://stackoverflow.com/a/21627377
score: 0
accepted answer of: http://stackoverflow.com/q/21627241
answers question: http://stackoverflow.com/q/21627241
has body: Have a look at this snippet from Googles developer site for GData: Check out our issue tracker at http://code.google.com/p/gdata-issues/issues/list. Look for your feature request and star it to add your support and receive updates on its status.
type: AcceptedAnswer
type: Answer

http://stackoverflow.com/a/21548902
has comment: http://stackoverflow.com/comment/32542630
answers question: http://stackoverflow.com/q/21548741
downvote count: 0
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/32542431
has body: how about: String s="t\'est\\\'"; s = s.replaceAll("\\\\'", "*"); System.out.println(s); produces: t'est* I escaped your string with http://www.htmlescape.net/javaescape_tool.html
score: 1

http://stackoverflow.com/comment/32616785
has text: If there isn't enough contiguous memory available (a) you're terribly memory constrained or have an enormous string, and (b) GC will run to attempt to free up storage so the String can be created. The String will require that much contiguous storage regardless of how it's created.
comment on: http://stackoverflow.com/q/21589971
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/32722288
type: AnswerComment
score: 0
type: Comment
has text: Yes I completely understand NPE point and I really appreciate everyonce quick responses but I am currently trying to learn this bounded wildcard generics and following some forum say legal but it gives me above mentioned compile error any thing you see below is a copy paste from there: Set<? extends Number> setOfAllSubTypeOfNumber = new HashSet<Integer>(); //legal - Integer extends Number setOfAllSubTypeOfNumber = new HashSet<Float>(); //legal - because Float extends Number"
comment on: http://stackoverflow.com/a/21650426

http://stackoverflow.com/comment/32570752
comment on: http://stackoverflow.com/q/21564499
type: Comment
type: QuestionComment
has text: "objects that are created in one class and place them in a constructor of another class". Objects are not created "in" a class. A class is sort of a blueprint on how objects are created. You create Ship objects anywhere in your code, then pass *them* in your Fleet constructor.
score: 0

http://stackoverflow.com/comment/32649364
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21609314
has text: Thank you... Will you please add some comments explaining the stuff you changed?
score: 0

http://stackoverflow.com/q/21542067
has answer: http://stackoverflow.com/a/21542105
has body: First of all I am new to android. I went through many similar question in SO but none of them make sense to me. I can't get my application running. All I see on the emulator is "Unfortunately {app_name} has stopped". Don't know how to fix it. Here is my Manifest file: &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /&gt; &lt;application android:debuggable="true" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name=".MainActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; LogCat: 02-03 01:49:59.255: E/Trace(3815): error opening trace file: No such file or directory (2) 02-03 01:49:59.255: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.255: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.255: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.314: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.314: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.334: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.334: W/Trace(3815): Unexpected value from nativeGetEnabledTags: 0 02-03 01:49:59.334: D/AndroidRuntime(3815): Shutting down VM 02-03 01:49:59.334: W/dalvikvm(3815): threadid=1: thread exiting with uncaught exception (group=0xb2d2e908) 02-03 01:49:59.364: E/AndroidRuntime(3815): FATAL EXCEPTION: main 02-03 01:49:59.364: E/AndroidRuntime(3815): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.rupantar/com.example.rupantar.MainActivity}: java.lang.NullPointerException 02-03 01:49:59.364: E/AndroidRuntime(3815): at android.app.ActivityThread.performLau…
tagged with: java
tagged with: eclipse
has answer: http://stackoverflow.com/a/21542713
answer count: 3
score: 0
tagged with: android
has answer: http://stackoverflow.com/a/21542737
has title: Unfortunately app_name has stopped- Android Eclipse
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32531349
tagged with: android-intent
type: Question

http://stackoverflow.com/comment/32687381
has text: Yes, check the link posted in my comment on OP's question.
type: Comment
score: 0
comment on: http://stackoverflow.com/a/21630793
type: AnswerComment

http://stackoverflow.com/comment/32691460
score: 0
type: Comment
type: QuestionComment
has text: So you can't even see the Tomcat root admin page http://localhost:8080/manager/html/ ?
comment on: http://stackoverflow.com/q/21633070

http://stackoverflow.com/comment/32579893
type: Comment
has text: You may want to use jQuery AJAX and avoid Scriptlets.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21569398

http://stackoverflow.com/comment/32621723
type: AnswerComment
has text: it will still throw, but you can also have it just return 0 if `s.isEmpty()`
type: Comment
comment on: http://stackoverflow.com/a/21592945
score: 0

http://stackoverflow.com/comment/32717977
score: 0
type: Comment
type: QuestionComment
has text: Is this IE11 in the Modern UI or on the Desktop IE?
comment on: http://stackoverflow.com/q/21638936

http://stackoverflow.com/comment/32728971
score: 0
type: Comment
has text: I see what you are saying. The only problem is that the Java class I'm in hasn't covered methods yet so I am forced to use the paint method and main class.
comment on: http://stackoverflow.com/a/21641556
type: AnswerComment

split
tags question: http://stackoverflow.com/q/21670258
tags question: http://stackoverflow.com/q/21586201
tags question: http://stackoverflow.com/q/21531531
tags question: http://stackoverflow.com/q/21639379
tags question: http://stackoverflow.com/q/21575452
tags question: http://stackoverflow.com/q/21660061
tag name: split
tags question: http://stackoverflow.com/q/21535827
tags question: http://stackoverflow.com/q/21606219
tags question: http://stackoverflow.com/q/21516210
tags question: http://stackoverflow.com/q/21585604
tags question: http://stackoverflow.com/q/21524494
tags question: http://stackoverflow.com/q/21627866
tags question: http://stackoverflow.com/q/21641180
tags question: http://stackoverflow.com/q/21541627
tags question: http://stackoverflow.com/q/21675850
tags question: http://stackoverflow.com/q/21644970
type: Tag
tags question: http://stackoverflow.com/q/21638316
tags question: http://stackoverflow.com/q/21642170

http://stackoverflow.com/comment/32582042
comment on: http://stackoverflow.com/a/21570792
score: 0
type: Comment
has text: Which version you are using during compile and running ?
type: AnswerComment

http://stackoverflow.com/comment/32648897
comment on: http://stackoverflow.com/q/21608990
score: 0
has text: ok I am looking for an illustration on how to store the numbers then grab them from a scanner. When I look up ways to do this the other illustrations are different. for instance one shows me how to add the data to the ArrayList but I cant find anything that stores theoretical numbers that don't exist tell someone enters them in. I am sure you would make a great teacher. I am 30 years old I am asking for a specific question to be answered not life advice.
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21639427
type: UnansweredQuestion
tagged with: java
score: 0
type: Question
has answer: http://stackoverflow.com/a/22701080
has body: We have been learning Java in school, but we aren't very far. I went ahead by myself and learned how to use the scanner class, and made this project that will use the Pythagorean theorem, and also show work. We haven't learned how to use static or main, which I know are necessary in Java. I've tried looking online, but I don't know how to do it without referencing non static content, or a similar error. Can someone look through my code and tell me the changes I need to make, and also tell me why I need to make these changes for next time? Edit: All of the if-else statements are to remove the .0 off of doubles. Thanks so much. import java.util.Scanner; /** * Solve problems with the pythagorean theorem. Work included. * * @author Andrew Bourgeois * @version 2/7/2014 */ import java.util.Scanner; /** * Solve problems with the pythagorean theorem. Work included. * * @author Andrew Bourgeois * @version 2/7/2014 */ public class Pythagorean { public double a; public double b; public double c; public boolean isPlaying = true; public Scanner reader; public Pythagorean() { while(isPlaying) { reader = new Scanner(System.in); String input; System.out.println("Solve for a, b, c, or quit?"); input = reader.nextLine().trim().toLowerCase(); if(input.equals("a")) { System.out.println(""); System.out.println("Length of b?"); input = reader.nextLine().trim().toLowerCase(); b = Double.parseDouble(input); System.out.println(""); System.out.println("Length of c?"); input = reader.nextLine().trim().toLowerCase(); c = Double.parseDouble(input); a(); } else if(input.equals("b")) { System.out.println(""); System.out.println("Length of a?"); input = reader.nextLine().trim().toLowerCase(); a = Double.parseDouble(input); System.out.println(""); System.out.println("Length of c?"); input = reader.nextLine().trim().toLowerCase(); c = Double.parseDouble(input); b(); } else if(input.equals("c")) { System.out.println(""); System.out.println("Length of a?"); input = reader.nextLine().trim().toLowerCase…
tagged with: bluej
tagged with: program-entry-point
answer count: 1
tagged with: console
has title: How To Turn My BlueJ Project Into a Application That Can Run In Console

http://stackoverflow.com/a/21632841
score: 0
type: Answer
has body: Basically, you should never use == to compare Strings, instead use equals(), so for you: testa.equals(testb) The difference is that == is used to compare references, it is saying: "Do these two String references point to the same String object in memory?"...this is unpredictable due to how Java stores Strings, which basically accounts for why "A" == "A" returns true...not something to go into here. The equals() method is more what you would expect, in the Java Class String, this method basically checks whether or not each character in the String is the same, and returns true if they do. If it's an object, you should use equals() to compare, if its a primitive data type, such as an int (or you are checking if a reference is null) then use ==.
has comment: http://stackoverflow.com/comment/32690380
has comment: http://stackoverflow.com/comment/32690314
answers question: http://stackoverflow.com/q/21632814

http://stackoverflow.com/comment/32641700
type: AnswerComment
comment on: http://stackoverflow.com/a/21604707
score: 0
type: Comment
has text: Please read my notes about separate statements and missing r2.next() in my other answer.

http://stackoverflow.com/comment/32672955
type: QuestionComment
comment on: http://stackoverflow.com/q/21622917
has text: "What should i do?" Well you should start by showing us the code you're using to generate the file...
score: 0
type: Comment

http://stackoverflow.com/a/21654415
downvote count: 0
score: 1
has body: "Now I just have to set the text of the colorfulLabel to lblString, and I can't figure out how to do that without creating a new object" What you want to do is pass the ColorfulLabel as reference to RatingSlider. Like this public class RatingSlider extends JSlider { ColorfulLabel cLabel; public RatingSlider(int horiz, int start, int max, int min, ColorfulLabel cLabel){ super(horiz, start, max, min); this.cLabel = cLabel; } So you'd never be creating a new ColotrfulLabel in the RatingSlider, you just use the same one that you created in the main. Then you can use it in the listener cLabel.setText(lblString); Just instantiate the RatingSlider passing the reference of the ColorfulLabel new RatingSlider(JSlider.HORIZONTAL , 0, 3, 0, blueLabel);
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/21654300

http://stackoverflow.com/a/21669784
has body: If you read lines as Strings, you can use the trim() method: String line = "...\n".trim(); public String trim(): Returns a copy of the string, with leading and trailing whitespace omitted.
score: 0
answers question: http://stackoverflow.com/q/21669743
type: Answer

http://stackoverflow.com/q/21519458
answer count: 1
has title: Java Number While Loop
has comment: http://stackoverflow.com/comment/32490981
favorite count: 0
accepted answer: http://stackoverflow.com/a/21519988
has body: I'm in a university and I don't understand how to fix this problem. I'm trying to make a program where a user types in all the numbers s/he wants, and enter -1 when s/he is done. "Expected" results are as directed by my professor: Write a program that will allow the user to enter any number of positive integers. The user will enter a -1 when they are done entering numbers (do not include the -1 as a number). The program must print out, when the user is done entering numbers, the following: Which number had the longest run of identical values, and how long the run was The minimum number entered The maximum number entered For example, if the user enters these numbers: 5 9 5 7 5 7 -1 Then the program would print out: Longest run: 5 entered 3 times Minimum number: 2 Maximum number: 9 If there are multiple runs of equal length, print out the first such run encountered. import java.util.Scanner; public class ExSixNumber { public static void main(String args []) { int mostUsedNumber = 0; int mostUsedCount = 0; System.out.println("I will track all your numbers!"); System.out.println("Enter any digits between 1 and 9."); System.out.println("Enter '-1' when done:"); Scanner scn = new Scanner (System.in); while(scn.hasNext()) { String userInput = scn.next(); while (scn.equals (userInput)) { mostUsedNumber++; mostUsedCount++; } if(userInput.equals("-1")) { System.out.println("Your tracked data:"); System.out.println("Longest run: " + mostUsedNumber + " entered " + mostUsedCount + " ."); break; } } } } This is as far as I had gotten. It doesn't like to track my userInput, could someone point me in the right direction on improving the program? I'm new and not asking for a direct answer, but "dummy" terms would be greatly appreciated. :)
has comment: http://stackoverflow.com/comment/32491035
type: AnsweredQuestion
tagged with: java.util.scanner
tagged with: java
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/21519988
tagged with: if-statement
score: -1
has comment: http://stackoverflow.com/comment/32490947
tagged with: while-loop
has comment: http://stackoverflow.com/comment/32490986
upvote count: 0

http://stackoverflow.com/comment/32551884
type: QuestionComment
has text: @Pragnesh Khalas. Thanks for editing!
comment on: http://stackoverflow.com/q/21554530
score: 0
type: Comment

http://stackoverflow.com/comment/32592974
has text: This questions looks more like a requirements doc.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21577308
score: 2

http://stackoverflow.com/comment/32633479
type: Comment
comment on: http://stackoverflow.com/a/21599229
score: 0
has text: He wants to use a socket and transmitting a file through a socket has the same difficulties than transmitting a string, or more.
type: AnswerComment

http://stackoverflow.com/a/21564546
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21564478
downvote count: 1
upvote count: 1
has body: why are you call set method inside constructor ? try this private String foreName; private String surName; private int age; private double height; private String gender public Person(String foreName,String surName, int age, double height, String gender){ personCount++; this.foreName = foreName; this.surName = surName; this.age = age; this.height = height; this.gender = gender; } /// setter and getter methods of above private variables..

http://stackoverflow.com/comment/32634775
type: QuestionComment
comment on: http://stackoverflow.com/q/21576931
score: 0
has text: What do you expect? How your example function should be called? Specify the input format, for example giving example JSON request.
type: Comment

http://stackoverflow.com/comment/32749713
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21666156
score: 0
has text: I believe the issue must be lying somewhere in the code to delete the item and copy the array items. I am just not sure what I am doing wrong. If I remove the code for this button all together everything works. Line 435 is if (inventoryBook[i].getISBN() != itemDelete.getISBN())

http://stackoverflow.com/comment/32689504
has text: The first option don't wortk(Exception). But the second on works! Thank you soooo much:)
comment on: http://stackoverflow.com/a/21620496
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/21596847
downvote count: 0
answer count: 1
has comment: http://stackoverflow.com/comment/32627955
has title: Java collection program showing error - Stack is abstract, cannot be instantiated
favorite count: 0
has comment: http://stackoverflow.com/comment/32627984
upvote count: 1
tagged with: collections
has body: import java.util.*; public class StackDemo { public static void main (String[] args) { Stack st = new Stack(); } } While running this code on JCreator with JDK 1.6 an error is occured - Stack is abstract; cannot be instantiated Stack st = new Stack(); Otherwise program runs successfully on online compilers like http://www.compileonline.com/ Please help.
has answer: http://stackoverflow.com/a/21596924
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32627821
score: 1
tagged with: stack
tagged with: java
accepted answer: http://stackoverflow.com/a/21596924
type: Question
has comment: http://stackoverflow.com/comment/32627976

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

http://stackoverflow.com/comment/32485333
score: 0
has text: @Sotirios Delimanolis that's what I really dont understand, isn't the toString method informative??
comment on: http://stackoverflow.com/q/21516303
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21578849
answers question: http://stackoverflow.com/q/21578736
has comment: http://stackoverflow.com/comment/32595704
score: 0
type: Answer
has body: Change the constructor like this public StudentQuizInfo(int[] score) { addQuizScore(score) } or StudentQuizInfo newStudent = new StudentQuizInfo(score); newStudent.addQuizScore(score);

http://stackoverflow.com/q/21646683
upvote count: 20
accepted answer: http://stackoverflow.com/a/21652054
downvote count: 0
possible better answer: http://stackoverflow.com/a/21646850
favorite count: 0
has body: I want to list all the files on my computer recursively using Java 8. Java 8 provides a listFiles method that returns all the files and directories but without recursion. How can I use it to get a full recursive list of files (without using a mutating collection)? I've tried the code below but it only goes one level deep: static Function&lt;Path, Stream&lt;Path&gt;&gt; listFiles = p -&gt; { if (p.toFile().isDirectory()) { try { return Files.list(p); } catch (Exception e) { return Stream.empty(); } } else { return Stream.of(p); } }; public static void main(String[] args) throws IOException { Path root = Paths.get("C:/temp/"); Files.list(root).flatMap(listFiles).forEach(System.out::println); } And using return Files.list(p).flatMap(listFiles); does not compile (not sure why)... Note: I am not interested in solutions involving FileVisitors or external libraries.
has comment: http://stackoverflow.com/comment/32722354
has answer: http://stackoverflow.com/a/21646850
has title: Recursive stream
has comment: http://stackoverflow.com/comment/32721727
tagged with: java-stream
tagged with: file
tagged with: java-8
has comment: http://stackoverflow.com/comment/32720377
type: AnsweredQuestion
tagged with: recursion
tagged with: java
has answer: http://stackoverflow.com/a/21652054
has comment: http://stackoverflow.com/comment/32722000
type: Question
score: 20
answer count: 2

http://stackoverflow.com/q/21611976
has comment: http://stackoverflow.com/comment/32654343
has body: package javaapplication6; import java.util.*; public class JavaApplication6{ public static void main(String[] args){ Scanner vh=new Scanner(System.in); String niz=""; char pod_niz=vh.next().charAt(0); char pod_niz2=vh.next().charAt(0); int index=niz.indexOf(pod_niz); String m=niz.replace(niz.charAt(index),pod_niz2); System.out.println(m); } } So this program changes one letter from a string.So for example: String niz="monkey"; char pod_niz='y'; char pod_niz='x'; I get monkex Now i have a file (D:\file.bin) and i want to change it to File.bin using this program. How to do that? Maybe I need to store the file name into a String, change it, then change the file name using the data which the String contains. Thanks..
tagged with: text
has title: File name changer program - need to save file name into a string
answer count: 0
tagged with: filenames
linked to: http://stackoverflow.com/q/1158777
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32655492
tagged with: java
has comment: http://stackoverflow.com/comment/32655028
type: Question
score: 0
has comment: http://stackoverflow.com/comment/32656975
has comment: http://stackoverflow.com/comment/32656243
tagged with: string

http://stackoverflow.com/comment/32691104
comment on: http://stackoverflow.com/a/21632701
type: Comment
has text: If this is the intention, you can implement a point of contact for the threads to write to and this guy just buffers and write in batches into the file. So the threads don't wait for I/O. The I/O pain is bore by a single guy who writes to file.
score: 0
type: AnswerComment

http://stackoverflow.com/q/21603742
has comment: http://stackoverflow.com/comment/32660201
upvote count: 2
tagged with: java
has comment: http://stackoverflow.com/comment/32639174
has comment: http://stackoverflow.com/comment/32639282
type: Question
has answer: http://stackoverflow.com/a/21603819
has answer: http://stackoverflow.com/a/21603765
has body: if("String ".intern().trim()=="String"){ System.out.println("Equals"); }else{ System.out.println("Unequal"); } above code is showing Unequal. I don't understand why? Can someone explain it?
linked to: http://stackoverflow.com/q/1855170
has comment: http://stackoverflow.com/comment/32639329
tagged with: comparison
downvote count: 4
linked to: http://stackoverflow.com/q/513832
has comment: http://stackoverflow.com/comment/32639722
has answer: http://stackoverflow.com/a/21603811
has title: Why my below code of String Comparison is not showing what i am expecting in java
tagged with: string
duplicate of: http://stackoverflow.com/q/513832
favorite count: 0
has answer: http://stackoverflow.com/a/21603839
answer count: 5
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/32639362
score: -2
has answer: http://stackoverflow.com/a/21603867

http://stackoverflow.com/comment/32712654
comment on: http://stackoverflow.com/a/21645437
score: 0
type: Comment
has text: @Rokas please check the links in my edited answer, is your requirement different (?)
type: AnswerComment

http://stackoverflow.com/q/21536771
tagged with: ibatis
accepted answer: http://stackoverflow.com/a/21538088
tagged with: logging
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21538088
tagged with: java
tagged with: struts2
type: Question
answer count: 1
score: 0
has title: How to swich off the log4j debug information of iBatis and Struts2 in my project?
has comment: http://stackoverflow.com/comment/32523665
has body: I'm working on a Strus2+iBatis project. When I config the log4j.properties for my project in WEB-INF/classes/... the iBatis and Struts2 show it's debug information. but sometimes I only want to see my code's log. I know there is a Hierrachy Logger object in my project. so quesiton is: 1, Is my RootLogger alse the root logger of the iBatis and Struts2 ? 2, How to swith off those 3rd lib's log information? 3, In which way the log4j put my logger in the Hierrachy ? (I guess is: if the logger name is "com.domain.proj.pkg" then log4j will create "com"->"domain"->"proj" 3 namespace and put my logger "pkg" in this namespace)
tagged with: log4j

http://stackoverflow.com/a/21601120
has comment: http://stackoverflow.com/comment/32634957
score: 0
type: Answer
answers question: http://stackoverflow.com/q/21601010
has body: You can change the value of a variable by right clicking it -> Change value

http://stackoverflow.com/comment/32748959
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21664826
type: Comment
has text: That started to make sense till I got to the part about turning them into object using the constructors. When I enter what I believe the argument would be from the Personal Contact class is just gives me errors cannot find symbol. This is what I am attempting to put: Contact contact; if(contactType == 1){ contact = new PersonalContact(String contactId, String firstName, String lastName, String address, String phoneNumber, String emailAddress, String dateofBirth); System.out.println("Please enter Birthday: "); String dateofBirth = input.nextLine();}

http://stackoverflow.com/q/21587066
type: AnsweredQuestion
score: 1
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32613654
possible better answer: http://stackoverflow.com/a/21587198
has answer: http://stackoverflow.com/a/21587137
downvote count: 0
has body: I testing an implementation of the singleton pattern and I feel like I can't figure out why IntelliJ is throwing me an error. Here is the code. public class CowSingleton { private static CowSingleton unique; private CowSingleton(){} //Only create new object if NOT already instantiated. public static CowSingleton getInstance(){ if (unique == null){ //creating unique object unique = new CowSingleton(); System.out.println(unique); } //return Object return unique; } public String cowMoo(String str) { return str; } } And here is where how I'm calling it: CowSingleton cowSingleton = new CowSingleton.getInstance(); System.out.println(cowSingleton.cowMoo("Moooooo")); The error I'm getting: "java: /Users/gpendleton/Personal/MyAnimals/src/Main.java:25: cannot find symbol symbol : class getInstance location: class CowSingleton"
has title: Error with my implementation of the singleton pattern
has answer: http://stackoverflow.com/a/21587129
upvote count: 1
tagged with: singleton
has comment: http://stackoverflow.com/comment/32611125
accepted answer: http://stackoverflow.com/a/21587116
has comment: http://stackoverflow.com/comment/32611187
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/21587198
has comment: http://stackoverflow.com/comment/124869575
has answer: http://stackoverflow.com/a/21587116

http://stackoverflow.com/q/21570520
tagged with: key-bindings
tagged with: java
has answer: http://stackoverflow.com/a/21570676
tagged with: eclipse
answer count: 1
has title: Eclipse: How to unbind Ctlr+I
has body: When I press Ctrl+I a tab character is inserted into the editor (if the focus is in the editor). This also happens when I press Ctrl+Shift+I which happens to be my favorite shortcut for checking in stuff. When I go to Preferences->General->Keys, Ctrl+I is NOT listed, so it seems this is some kind of "internal" keyboard shortcut. Is there still a way to remove Ctrl+I ? I am using Eclipse: Version: Kepler Release Build id: 20130614-0229
score: 0
type: UnansweredQuestion
type: Question

http://stackoverflow.com/comment/32769890
type: AnswerComment
has text: I don't get any error. I just get an empty . No error Im very new to java, i've just known jsp, sorry i don't know about servlets and all. is there any way to solve it using just jsp?
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21663123

http://stackoverflow.com/a/21649189
accepted answer of: http://stackoverflow.com/q/21643449
score: 3
upvote count: 3
has body: it's still ok even drag on the label, but when i add mouseclicked event for the label, even no codes actually proccessed in the adapter Correct, the MouseEvent is only passed to one component, so the label stops the event from being passed to the window. So you need to add the MouseListener to the window and the label in order to drag the window. Check out Moving Windows. It is a listener that will allow you to move any component relative to its parent. So you can create a ComponentMover and then register the root pane of your window to allow you to drag the window. But you will also need to register the label.
downvote count: 0
has comment: http://stackoverflow.com/comment/32756402
answers question: http://stackoverflow.com/q/21643449
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32753407
type: Answer

http://stackoverflow.com/q/21581347
tagged with: cryptography
tagged with: aes
has comment: http://stackoverflow.com/comment/32601109
has comment: http://stackoverflow.com/comment/32647475
tagged with: encryption
has body: I have created a Java file with following code that encrypt or decrypt a string: public class Aes { public static String encrypt(String seed, String cleartext) throws Exception { byte[] rawKey = getRawKey(seed.getBytes()); byte[] result = encrypt(rawKey, cleartext.getBytes()); return toHex(result); } public static String decrypt(String seed, String encrypted) throws Exception { byte[] rawKey = getRawKey(seed.getBytes()); byte[] enc = toByte(encrypted); byte[] result = decrypt(rawKey, enc); return new String(result); } private static byte[] getRawKey(byte[] seed) throws Exception { KeyGenerator kgen = KeyGenerator.getInstance("AES"); SecureRandom sr = SecureRandom.getInstance("SHA1PRNG"); sr.setSeed(seed); kgen.init(128, sr); // 192 and 256 bits may not be available SecretKey skey = kgen.generateKey(); byte[] raw = skey.getEncoded(); return raw; } private static byte[] encrypt(byte[] raw, byte[] clear) throws Exception { byte[] iv = new byte[] { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF }; IvParameterSpec ivSpec = new IvParameterSpec(iv); SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); Cipher cipher = Cipher.getInstance("AES/CFB/NoPadding"); cipher.init(Cipher.ENCRYPT_MODE, skeySpec, ivSpec); byte[] encrypted = cipher.doFinal(clear); return encrypted; } private static byte[] decrypt(byte[] raw, byte[] encrypted) throws Exception { byte[] iv = new byte[] { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF }; IvParameterSpec ivSpec = new IvParameterSpec(iv); SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); Cipher cipher = Cipher.getInstance("AES/CFB/NoPadding"); cipher.init(Cipher.DECRYPT_MODE, skeySpec, ivSpec); byte[] decrypted = cipher.doFinal(encrypted); return decrypted; } public static String toHex(String txt) { return toHex(txt.getBytes()); } public static String fromHex(String hex) { return new String(toByte(hex)); } public static byte[] toByte(String hexString) { int len = hexStri…
has comment: http://stackoverflow.com/comment/32603349
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32600965
has comment: http://stackoverflow.com/comment/32602735
has comment: http://stackoverflow.com/comment/32608209
tagged with: java
has comment: http://stackoverflow.com/comment/32601324
linked to: http://stackoverflow.com/q/11418336
type: Question
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/21609678
accepted answer: http://stackoverflow.com/a/21609678
has title: JAVA ANDROID AES CFB NOPADDING
possible better answer: http://stackoverflow.com/a/34504022
has answer: http://stackoverflow.com/a/34504022
tagged with: android

http://stackoverflow.com/comment/32529038
has text: You might want to indicate which programming language you are using...
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21540761

http://stackoverflow.com/comment/32522176
has text: Good question and thanks for asking, yes I am on a 64-bit JVM. I've added further clarification to the original question.
comment on: http://stackoverflow.com/q/21536413
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/21542862
answers question: http://stackoverflow.com/q/21542825
score: 0
has comment: http://stackoverflow.com/comment/32532846
type: Answer
has body: Every open connection must be closed, or it won't get implemented and no errors will be displayed. First learned lesson. public static void DeleteRow(String name) { try { Class.forName("com.mysql.jdbc.Driver"); Connection connection = DriverManager.getConnection(url, username, password); PreparedStatement st = connection.prepareStatement("DELETE FROM Table WHERE name = " + name + ";"); st.executeUpdate(); connection.close(); } catch(Exception e) { System.out.println(e); } } Hope this helps
upvote count: 1
downvote count: 1

http://stackoverflow.com/comment/32759382
type: Comment
type: QuestionComment
has text: You mean `this.size=a` ?
comment on: http://stackoverflow.com/q/21672278
score: 4

http://stackoverflow.com/a/21670524
has body: Allowed characters in a URL is restricted. You have to encode the URL with encodeURIComponent. A better option might be posting those parameters in a data -variable and using @FormParam instead of @PathParam.
answers question: http://stackoverflow.com/q/21669633
accepted answer of: http://stackoverflow.com/q/21669633
upvote count: 2
type: AcceptedAnswer
type: Answer
score: 2
downvote count: 0

http://stackoverflow.com/a/21530734
type: Answer
has comment: http://stackoverflow.com/comment/32511506
has comment: http://stackoverflow.com/comment/32510529
has comment: http://stackoverflow.com/comment/32510674
has body: For one thing, you want your date to be separated by / in most places, but you check if the string has the same length as "ddMMYYYY". You should probably change your isValidDate() method to include the slashes (and a trailing close-brace): public boolean isValidDate(String dateString) { SimpleDateFormat df = new SimpleDateFormat("dd/MM/YYYY"); if (dateString.length() != "dd/MM/YYYY".length()) { return false; } try { df.parse(dateString); return true; } catch (ParseException e) { return false; } }
answers question: http://stackoverflow.com/q/21530642
score: 0

http://stackoverflow.com/a/21641382
type: Answer
answers question: http://stackoverflow.com/q/21641354
has body: if (letter1.equals("A") &amp;&amp; letter2.equals("+")) gpa = 4.0; else if(letter1.equals("A")) {gpa = 3.9;} else if(letter1.equals("B")) {gpa = 3.0;} else if(letter1.equals("C")) {gpa = 2.1;} else if(letter1.equals("D")) {gpa = 1.2;} else if(letter1.equals("F")) {gpa = 0;} if (!letter1.equals("F")) { if(letter2.equals("+") &amp;&amp; !letter1.equals("A")) gpa += 0.3; else if(letter2.equals("-")) gpa -= 0.3; }
score: 0
has comment: http://stackoverflow.com/comment/32706237

http://stackoverflow.com/a/21658700
type: Answer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/21658566
answers question: http://stackoverflow.com/q/21658566
score: 5
has body: When you do a JNDI lookup, you lookup the remote Interface. so changing your cast to bean = (UserViewBeanRemote) context.lookup(lookupName); should do the trick.
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32735994
upvote count: 5

http://stackoverflow.com/comment/32756172
type: QuestionComment
has text: I dont see the entity annotation is part of embedded object ?
type: Comment
comment on: http://stackoverflow.com/q/21669992
score: 0

http://stackoverflow.com/comment/65319690
has text: Under the "Refactor" menu, I see an "Encapsulate Field..." menu item, but not an "Encapsulate Fields..." menu item. So if a class has many fields, the user is forced to repeatedly invoke "Encapsulate Field..." for each field.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21597844

http://stackoverflow.com/comment/32687690
has text: Using [javascript](http://docs.seleniumhq.org/docs/03_webdriver.jsp#using-javascript)?
comment on: http://stackoverflow.com/q/21631273
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/21553269
tagged with: lazy-evaluation
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21553768
has answer: http://stackoverflow.com/a/21553768
tagged with: java
has comment: http://stackoverflow.com/comment/32549839
upvote count: 1
downvote count: 1
type: Question
answer count: 2
has body: I was working in C# for a long time, and I liked one construct very much, I am talking about yield return here. This allowed to organize even infinite collections thanks to lazy evaluation: IEnumerable&lt;int&gt; fib() { int a = 0, b= 1; while (true) { yield return b; int c = a; a = b; b = c+b; } } Will Java 8 have a semantics similar to this? Will it allow the lazy evaluation at it's full power?
score: 0
has answer: http://stackoverflow.com/a/21553313
has comment: http://stackoverflow.com/comment/32550760
favorite count: 0
tagged with: yield-return
has title: Will Java 8 have lazy evaluation?
accepted answer: http://stackoverflow.com/a/21553313

http://stackoverflow.com/comment/32685102
comment on: http://stackoverflow.com/a/21629753
type: Comment
score: 0
type: AnswerComment
has text: i am getting same error can you please provide the code for retrieval @Kai

http://stackoverflow.com/comment/32768258
score: 0
type: Comment
has text: I asked as I was thinking of a variation and not your implementation exactly.
comment on: http://stackoverflow.com/a/21676848
type: AnswerComment

http://stackoverflow.com/q/21582039
type: AnsweredQuestion
score: 1
tagged with: java
has title: WEKA: Classify instances with a deserialized model
has answer: http://stackoverflow.com/a/21585898
tagged with: weka
answer count: 2
downvote count: 0
has body: I used Weka Explorer: Loaded the arff file Applied StringToWordVector filter Selected IBk as the best classifier Generated/Saved my_model.model binary In my Java code I deserialize the model: URL curl = ClassUtility.findClasspathResource( "models/my_model.model" ); final Classifier cls = (Classifier) weka.core.SerializationHelper.read( curl.openConnection().getInputStream() ); Now, I have the classifier BUT I need somehow the information on the filter. Where I am getting is: how do I prepare an instance to be classified by my deserialized model (how do I apply the filter before classification) - (The raw instance that I have to classify has a field text with tokens in it. The filter was supposed to transform that into a list of new attributes) I even tried to use a FilteredClassifier where I set the classifier to the deserialized on and the filter to a manually created instance of StringToWordVector final StringToWordVector filter = new StringToWordVector(); filter.setOptions(new String[]{"-C", "-P x_", "-L"}); FilteredClassifier fcls = new FilteredClassifier(); fcls.setFilter(filter); fcls.setClassifier(cls); The above does not work either. It throws the exception: Exception in thread "main" java.lang.NullPointerException: No output instance format defined What I am trying to avoid is doing the training in the Java code. It can be very slow and the prospect is that I might have multiple classifiers to train (different algorithms as well) and I want my app to start fast.
favorite count: 0
accepted answer: http://stackoverflow.com/a/21585898
possible better answer: http://stackoverflow.com/a/40359137
upvote count: 1
has answer: http://stackoverflow.com/a/40359137
type: Question

http://stackoverflow.com/q/21528963
has comment: http://stackoverflow.com/comment/32569453
answer count: 1
downvote count: 0
accepted answer: http://stackoverflow.com/a/21529074
has title: Parsing HashMap to Json
favorite count: 0
has comment: http://stackoverflow.com/comment/32517578
has comment: http://stackoverflow.com/comment/32610732
type: AnsweredQuestion
score: 3
upvote count: 3
tagged with: java
tagged with: http://stackoverflow.com/tag/json
tagged with: gson
type: Question
has answer: http://stackoverflow.com/a/21529074
tagged with: jackson
has body: Here is the HashMap I'm trying to parse: HashMap map = new HashMap(); map.put("bowser", "b=mozilla"); map.put("car", "car=Ford"); map.put("model","model=Mustang"); map.put("Year", 2014); map.put("dealer", "Dealer=AKHI"); First I've tried Gson and then Jackson but both of them have a common problem., They parse "=" to "=" ObjectMapper mapper = new ObjectMapper(); try { String json = mapper.writeValueAsString(map); System.out.println("---------------------Parsed HashMap---------------------------:"+json); } catch (JsonGenerationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JsonMappingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } The output I get is : ---------------------Parsed HashMap---------------------------: {"dealer":"Dealer=AKHI","car":"car=Ford","Year":2014,"model":"model=Mustang","bowser":"b=mozilla"} I've been through few other blogs and see that there is a glitch in the API but is there any way we could fix this here with may be some other method.

http://stackoverflow.com/q/21634273
score: 2
has answer: http://stackoverflow.com/a/21634327
downvote count: 0
has answer: http://stackoverflow.com/a/21634384
tagged with: runtime.exec
tagged with: java
type: Question
upvote count: 2
has comment: http://stackoverflow.com/comment/32705867
has body: How do I execute a .bat or .exe within my java program that is in a sub-folder within the main folder that holds my java program. Runtime.getRuntime().exec("cmd /c start example.bat"); The code above works perfectly fine when the .bat is in the same folder as the java program. But if my program's .java and .class files were organized in a package (and the .bat would be in a separate folder), how would I call that bat program?
has title: Executing bat file within Java program
linked to: http://stackoverflow.com/q/320542
tagged with: batch-file
answer count: 3
favorite count: 0
has answer: http://stackoverflow.com/a/21634366
type: UnansweredQuestion

http://stackoverflow.com/q/21672120
score: 2
tagged with: android-webview
has comment: http://stackoverflow.com/comment/32804594
tagged with: java
has title: WebView autofill forms
has body: The forum is a lot of topics dedicated to my question, but all the codes that do not work there. There is a form: &lt;form name="forma1"&gt; &lt;input type="text" name="ulogin" size="20" maxlength="50" value="login"&gt; &lt;/form&gt; Codes that do not work for me: code 1 webView.setWebViewClient(new WebViewClient(){ @Override public void onPageFinished (WebView webView, String url) { webView.loadUrl("javascript:document.getElementById('ulogin').value='"+username+"';"); } }); code 2 String username = "cristian"; webview.loadUrl("javascript:document.getElementById('ulogin').value = '"+username+"';"); code 3 webView.loadUrl("javascript: {" + "document.getElementById('ulogin').value = '"+uname +"';" + "var frms = document.getElementsByName('forma1');" + "frms[0].submit(); };"); But when the page opens, but the form is not filled in, what's the problem?
has answer: http://stackoverflow.com/a/21672522
type: Question
downvote count: 0
answer count: 1
has comment: http://stackoverflow.com/comment/32763930
favorite count: 0
has comment: http://stackoverflow.com/comment/32805192
upvote count: 2
type: UnansweredQuestion
tagged with: android

http://stackoverflow.com/a/58722401
has body: Try countProjection @Query(value="SELECT v FROM VisitEntity v LEFT JOIN FETCH v.comments WHERE v.venue.id = :venueId and ..." , countProjection = "v.id") public Page&lt;VisitEntity&gt; getVenueVisits(@Param("venueId") long venueId,..., Pageable pageable);
type: Answer
answers question: http://stackoverflow.com/q/21549480
score: 0

http://stackoverflow.com/a/22492199
has body: We fixed it, by installing Tomcat 6.35 in linux, we stopped using tomcat without the installer.
type: Answer
answers question: http://stackoverflow.com/q/21638600
score: 0

http://stackoverflow.com/a/21550227
has comment: http://stackoverflow.com/comment/32577520
type: Answer
has comment: http://stackoverflow.com/comment/32546248
has body: Call PSCP program from Java: String[] command = { "pscp", "-q", // quiet, don't show statistics "-pw", // passw login with specified password "yourP4ssw0rd", // the user password "username@yourhost:file.csv", "c:\\the\\destination\\of\\your\\file.csv" }; // command == pscp -q -pw yourP4ssw0rd username@yourhost:file.csv c:\\the\\destination\\of\\your\\file.csv Process p = Runtime.getRuntime().exec(command); p.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = ""; while ((line = reader.readLine())!= null) { sb.append(line + "\n"); } ... Reference PSCP manual Download PSCP
score: 2
upvote count: 2
accepted answer of: http://stackoverflow.com/q/21550099
answers question: http://stackoverflow.com/q/21550099
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/21521756
has title: Using free TTS makse program unresponsive
tagged with: text-to-speech
has comment: http://stackoverflow.com/comment/32515928
type: AnsweredQuestion
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32551817
has answer: http://stackoverflow.com/a/23495979
accepted answer: http://stackoverflow.com/a/23495979
has body: I am creating a tts program. I am using free tts. The program is fine, running. I have assigned two buttons(start,stop) and a text box. The start button reads the text from the text box and sent it to the free tts algorithm to convert to speech. It all works fine but the problem is that once I have click on start, the program starts reading and it becomes unresponsive until reading is completed, I cannot even click the stop button. I tried to solve this problem by sending word by word to the tts algorithm but the the speech is really unbearable How do I solve this problem???
tagged with: freetts
score: 0
answer count: 1

http://stackoverflow.com/a/21605231
has comment: http://stackoverflow.com/comment/32643262
answers question: http://stackoverflow.com/q/21604908
has body: You know, if you use more than one variable to match the other player, you may find interesting the idea of searching the other player that is the "nearest". For example, you're comparing using the "rating" variable. It's a single variable comparison. But what if you had more variables to compare your players, like strenght, agility, etc etc etc and compare them all at the same time? If you think on a multi-variable comparison, you could use something like KNN to find a group of players that are "closer" to yours, and then you could just pick up one of this group. There's a full KNN java code example and explanation here http://afewguyscoding.com/2010/05/nearest-neighbors-java/
has comment: http://stackoverflow.com/comment/32642033
upvote count: 2
type: Answer
score: 2
downvote count: 0

http://stackoverflow.com/comment/32572687
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/21542524
type: Comment
has text: that helps. another question would be how to keep the connection and use it in different classes but i havent looked that up yet so idk if its answered or not

http://stackoverflow.com/comment/32585227
type: Comment
score: 0
has text: That doesn't look like text at all. Is it (perhaps) a PDF file? Or compressed? I doubt that this is a "simple" problem with UTF-8.
type: QuestionComment
comment on: http://stackoverflow.com/q/21572485

http://stackoverflow.com/comment/81822332
type: AnswerComment
comment on: http://stackoverflow.com/a/39465150
has text: Just use logging. And EAGER is bad, yes.
type: Comment
score: 0

http://stackoverflow.com/q/21561087
tagged with: stack-overflow
favorite count: 0
has answer: http://stackoverflow.com/a/21561293
has body: I've tried to put on a very simple JAVA example (i'm a newbie) to handle events; it's a game skeleton (say chess, with two players, white and black) Here is the source code: //--------------------------------------------------------- // Game.java package chess; public class Game { private static Player p1; private static Player p2; private static Board b; public static void main(String[] args) { b = new Board(); p1 = new Player(b, "white"); p2 = new Player(b, "black"); p1.MakeMove(); } } //--------------------------------------------------------- // Board.java package chess; import java.util.ArrayList; public class Board { int num; private ArrayList&lt;NextMoveListener&gt; listeners = new ArrayList&lt;NextMoveListener&gt;(); public Board() { num = 0; } public void addListener(NextMoveListener nml) { listeners.add(nml); } void LastMove() { System.out.println("Game Over!"); } void NextMove(NextMoveEvent e) { if (e.finished) { LastMove(); } else { for (NextMoveListener nml : listeners) { if (nml != e.getSource()) { nml.MakeMove(); } } } } } //--------------------------------------------------------- // Player.java package chess; interface NextMoveListener { public void MakeMove(); } public class Player implements NextMoveListener { private String name; private Board b; private int nMove; private NextMoveEvent evt; Player(Board b, String nome) { this.nMove = 0; this.b = b; this.name = nome; this.evt = new NextMoveEvent(this); b.addListener(this); } @Override public void MakeMove() { System.out.println("Player: " + name + ", move: " + (++nMove)); evt.setFinished(nMove == 1000); b.NextMove(evt); } } //--------------------------------------------------------- // NextMoveEvent.java package chess; import java.util.EventObject; public class NextMoveEvent extends EventObject { boolean finished; public NextMoveEvent(Object source) { super(source); } public void setFinished(boolean finished) { this.finished = finished; } } Obviously there's no real game inside, it's just an exam…
has comment: http://stackoverflow.com/comment/32564339
upvote count: 1
accepted answer: http://stackoverflow.com/a/21561293
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/21561601
has answer: http://stackoverflow.com/a/21561601
score: 1
tagged with: java
has title: Stack overflow in custom event processing
type: Question
has comment: http://stackoverflow.com/comment/32564209
answer count: 2
downvote count: 0

http://stackoverflow.com/q/21657454
type: Question
tagged with: performance
tagged with: memory
has comment: http://stackoverflow.com/comment/32733681
has body: I have a computationally demanding task that I am going to spread out over multiple threads. Each thread will require access to the identical, large String[][]. I am wondering whether the fact that they all need to access the same String[][] on heap will hit performance? Would it be better to make copies of this String[][] for each thread to access individually (even though they all only need to access the identical instance of this String[][])? Note that, for String[][] someArray = new String[100][1000000]; (for example), it is improbable that at any single point in time they will be calling the same someArray[i] at the same time. Generally each thread will be using a different i at any given point in time. However sometimes i will be the same across threads (mostly by chance). Each thread will be read-only on someArray.
has answer: http://stackoverflow.com/a/21657518
answer count: 1
has title: Performance hit if each thread has to access identical array
accepted answer: http://stackoverflow.com/a/21657518
score: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/32733688
has comment: http://stackoverflow.com/comment/32733995
has comment: http://stackoverflow.com/comment/32733718
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32733680
upvote count: 2
tagged with: java
tagged with: multithreading
downvote count: 1
has comment: http://stackoverflow.com/comment/32733906
has comment: http://stackoverflow.com/comment/32734277

http://stackoverflow.com/q/21612593
tagged with: while-loop
has body: Task: To check that if a user input string has the same first and last character. If yes or no, output to the screen, if the user enters "done", the loop is exited. Issue: While loop executes when condition is false What I've tried: Using different types of loops, doing a loop within the loop to revalidate the code and all together giving up! import java.util.*; public class lab_15 { public static void main(String args[]) { String userInput = ""; String done = "done"; while (!userInput.equalsIgnoreCase(done)) { int length; Scanner sc = new Scanner(System.in); userInput = sc.next(); length = (int)userInput.length(); if (userInput.charAt(0) == userInput.charAt(userInput.length()-1)) { System.out.println("The first character equals the second character."); } else { System.out.println("The first and second characters are different."); } } // EXIT LOOP System.out.println("Thank you for using this software!"); } } Inputs + bradley + hannah + done I am still new to the site and have referred to the t's &amp; c's regarding posts. Please do not negative if you find the question to not be challenging. I am new to programming and hope to progress. Thank you!!!
has comment: http://stackoverflow.com/comment/32655265
has comment: http://stackoverflow.com/comment/32655327
type: AnsweredQuestion
upvote count: 3
tagged with: java
accepted answer: http://stackoverflow.com/a/21612695
type: Question
score: 3
has title: While Loop executing one last time when condition is set to false
has comment: http://stackoverflow.com/comment/32655476
answer count: 1
downvote count: 0
tagged with: string
has answer: http://stackoverflow.com/a/21612695
favorite count: 0
has comment: http://stackoverflow.com/comment/32655255
has comment: http://stackoverflow.com/comment/32655234

http://stackoverflow.com/comment/32600248
has text: @smartmouse check if you have different time parts, see my answer
comment on: http://stackoverflow.com/q/21580841
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/32639740
comment on: http://stackoverflow.com/q/21603911
score: 0
type: Comment
type: QuestionComment
has text: Please describe the commands / Eclipse controls that you are using to run the program.

http://stackoverflow.com/comment/32726393
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21653096
has text: so the `thread.sleep(50);` in my `move()` method in the for loop is causing this as well/

http://stackoverflow.com/q/21548237
tagged with: selenium-webdriver
score: 2
type: AnsweredQuestion
downvote count: 0
tagged with: java
tagged with: selenium
linked to: http://stackoverflow.com/q/3163615
linked to: http://stackoverflow.com/q/9443067
type: Question
upvote count: 2
has answer: http://stackoverflow.com/a/21549312
accepted answer: http://stackoverflow.com/a/21549312
answer count: 1
has comment: http://stackoverflow.com/comment/32541543
favorite count: 0
has body: How to scroll page using webdriver directly. I know how to scroll using javascript executor. My question is, can it be done without using java script?? With java script I was using following: JavascriptExecutor jsx = (JavascriptExecutor)driver; jsx.executeScript("window.scrollBy(0,450)", "");
has title: Page scroll in webdriver

http://stackoverflow.com/comment/32552856
comment on: http://stackoverflow.com/a/21555060
type: AnswerComment
score: 0
type: Comment
has text: Any chance you can help me out and implement list in my code, just a quick example so I have something to start from?

http://stackoverflow.com/a/21667112
downvote count: 0
type: Answer
has body: Try to do something like this: SimpleDateFormat formatter = new SimpleDateFormat("EEEE, MMM dd, yyyy HH:mm:ss a"); String dateInString = "Friday, Jun 7, 2013 12:10:56 PM"; try { Date date = formatter.parse(dateInString); System.out.println(date); System.out.println(formatter.format(date)); } catch (ParseException e) { e.printStackTrace(); } Ref: How to Convert String to Date in Java
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/21667075

http://stackoverflow.com/comment/32679870
score: 0
comment on: http://stackoverflow.com/q/21623911
type: Comment
type: QuestionComment
has text: -I/usr/include/opencv -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann

http://stackoverflow.com/a/21606356
answers question: http://stackoverflow.com/q/21606219
score: 0
type: Answer
has body: how about some method like string.Replace("e ", "e"); I assume you are using String static method, as I can see you are using Split

http://stackoverflow.com/q/21612820
upvote count: 0
has comment: http://stackoverflow.com/comment/32655611
answer count: 1
has title: How to write a counter for a .txt file in java
has body: I have a program that I am writing and I have it completed but I keep receiving an error in a counter that I am using. The purpose of the program is to build a plate stacker and I have finished that but need to write a counter based on the particular colors used (how many green plates...etc.). As I know several classmates use this site to cheat, I will not post the code in whole but only the fragments I feel are necessary. Below is an example of a statement that I am using to attempt to get a count of the beige plates in the text file. The statement is in a while loop with the other colors having the same coding. I also have initialized the counter (int beige = 0;) prior to this and outside of the while loop: if(line == "beige") { beige++; } I have a System.out following these statements to display the count but it always comes up as 0 so I believe the problem is in this particular fragment. If I need to send additional coding I will but I believe it is something to do with this or the placement of it in the while loop.
favorite count: 0
has answer: http://stackoverflow.com/a/21612939
linked to: http://stackoverflow.com/q/513832
accepted answer: http://stackoverflow.com/a/21612939
duplicate of: http://stackoverflow.com/q/513832
type: AnsweredQuestion
downvote count: 1
type: Question
tagged with: java
score: -1

http://stackoverflow.com/q/21531500
has title: Eclipse Tomcat Publishing Error: FlatFile Cannot be cast to IFlatFolder
tagged with: eclipse
tagged with: publishing
downvote count: 0
answer count: 1
tagged with: tomcat
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/40669748
score: 1
tagged with: java
upvote count: 1
has comment: http://stackoverflow.com/comment/55814361
has body: I have an application which I can't deploy or run in Tomcat because as soon as I attempt to start Tomcat in Eclipse (with this application configured in Add/Remove Project), I get this error: Could not publish to the server. org.eclipse.wst.common.componentcore.internal.flat.FlatFile cannot be cast to org.eclipse.wst.common.componentcore.internal.flat.IFlatFolder This happens on starting, publishing, and cleaning the Tomcat server in Eclipse, as long as my application is configured there. When I remove the application, I can publish fine. What is this error about? I couldn't find any resources in Google.
type: Question

http://stackoverflow.com/comment/32797374
score: 0
type: Comment
has text: Ah the good old Exception solved the case eh? Note that Exception is generic and will catch practically any exception, and it encompasses StringIndexOutofBoundsException. Dunno y your compiler doesn't recognize it though :). No problem, glad to help out.
type: AnswerComment
comment on: http://stackoverflow.com/a/21669242

http://stackoverflow.com/q/21537211
type: Question
score: 3
possible better answer: http://stackoverflow.com/a/21538413
accepted answer: http://stackoverflow.com/a/21552314
has answer: http://stackoverflow.com/a/21538413
tagged with: spring-transactions
answer count: 2
downvote count: 0
favorite count: 0
tagged with: legacy-code
has answer: http://stackoverflow.com/a/21552314
tagged with: spring
has title: How to run a legacy code inside a managed spring transaction?
type: AnsweredQuestion
upvote count: 3
tagged with: java
has body: Hi I have a legacy code which gets its jdbc connections through DataSource.getConnection() The DataSource is bounded to Jndi namespace., Suppose that I have a function which gets its connections like that: foo(){ ... Connection con = DataSource.getConnection() ... } And I want to run this foo method into a well defined spring transaction. How would I do that ? I have used TransactionAwareDataSourceProxy and It worked quite well before I move onto something like JPA At first I could synronize foo's transaction with my spring transaction with this configuration. <tx:annotation-driven transaction-manager="txManager"/> classpath:/db.properties <constructor-arg ref="dbcpDataSource"/> oracle.jdbc.driver.OracleDriver jdbc:oracle:thin:@${jdbc.url}:1521:${jdbc.db} ${jdbc.username} ${jdbc.password} After that I move onto JPA using LocalContainerEntityManagerFactoryBean and JpaTransactionManager. package setup; import javax.sql.DataSource; import org.apache.commons.dbcp.BasicDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.JpaVendorAdapter; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.Database; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.PlatformTransactionManager; @Configuration @EnableJpaRepositories public class SpringContextConfiguration { @Bean public TestsSetup testSetup(){ return new TestsSetup(); } @Bean public TransactionAwareDataSourceProxy dataSource(){ TransactionAwareDataSourceProxy tp = new TransactionAwareDataSourceProxy(); BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName("oracle.jdbc.driver.Orac…

http://stackoverflow.com/q/21651498
tagged with: trident
tagged with: java
has answer: http://stackoverflow.com/a/32379833
type: Question
answer count: 1
downvote count: 0
favorite count: 0
tagged with: cassandra
has body: I'm trying to insert a simple row to a table in Cassandra 2.0.5, Storm version 0.9.0.1. My test is as follows: I have a table consisting of an id (int) and sentence (text) colum. id is the primary key. My spout generates sentences and I add an ID (static increment in the code). This is my topology: TridentTopology topology = new TridentTopology(); StateFactory cassandraStateFactory = CassandraMapState.nonTransactional(options); Fields fields = new Fields("id", "sentence"); MyTridentTupleMapper tupleMapper = new MyTridentTupleMapper(keyspace, fields); CassandraUpdater updater = new CassandraUpdater(tupleMapper); TridentState wordCounts = topology.newStream("spout1", spout) .each(new Fields("sentence"), new AddId(), new Fields("id")) .partitionPersist(cassandraStateFactory, fields, updater); LocalCluster cluster = new LocalCluster(); cluster.submitTopology("test", config, topology.build()); The code for MyTridentTupleMapper: https://github.com/guywald/trident-cassandra-read-write-examples/blob/master/src/test/java/com/guywald/storm/trident/cassandra/MyTridentTupleMapper.java I get the following exception: 2014-02-08 22:20:14 ERROR executor:0 - java.lang.RuntimeException: java.lang.ClassCastException: storm.trident.state.map.SnapshottableMap cannot be cast to com.hmsonline.storm.cassandra.trident.CassandraState at backtype.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:90) at backtype.storm.utils.DisruptorQueue.consumeBatchWhenAvailable(DisruptorQueue.java:61) at backtype.storm.disruptor$consume_batch_when_available.invoke(disruptor.clj:62) at backtype.storm.daemon.executor$fn__3498$fn__3510$fn__3557.invoke(executor.clj:730) at backtype.storm.util$async_loop$fn__444.invoke(util.clj:403) at clojure.lang.AFn.run(AFn.java:24) at java.lang.Thread.run(Thread.java:744) I'm not sure why it returns this and would appreciate help.
score: 2
has title: Inserting rows to cassandra using Storm Trident
upvote count: 2
type: UnansweredQuestion
tagged with: apache-storm

http://stackoverflow.com/comment/32581362
comment on: http://stackoverflow.com/q/21569717
type: QuestionComment
type: Comment
score: 1
has text: already they are using update and add. then, why and where they are passing the details...@gowtham

http://stackoverflow.com/q/21576148
upvote count: 2
answer count: 1
downvote count: 1
has answer: http://stackoverflow.com/a/21576178
accepted answer: http://stackoverflow.com/a/21576178
favorite count: 0
has body: I have a list of objects. Each object has a list. What I want to do is to add these objects horizontally to a new list so that it looks like this: At the moment I am struggling with a proper algorithm, so I wrote this little test program: public class testClass { /** * @param args */ public static void main(String[] args) { List&lt;Double&gt; list1 = new ArrayList&lt;Double&gt;(); List&lt;Double&gt; list2 = new ArrayList&lt;Double&gt;(); List&lt;Double&gt; list3 = new ArrayList&lt;Double&gt;(); List&lt;List&lt;Double&gt;&gt; objectList = new ArrayList&lt;List&lt;Double&gt;&gt;(); //add data list1.add(1.0); list1.add(2.0); list1.add(3.0); list1.add(4.0); list1.add(5.0); list1.add(6.0); list1.add(7.0); list2.add(1.0); list2.add(2.0); list2.add(3.0); list2.add(4.0); list2.add(5.0); list2.add(6.0); list2.add(7.0); list3.add(1.0); list3.add(2.0); list3.add(3.0); list3.add(4.0); list3.add(5.0); list3.add(6.0); list3.add(7.0); objectList.add(list1); objectList.add(list2); objectList.add(list3); double result = 0.0; List&lt;Double&gt; resultList = new ArrayList&lt;Double&gt;(); for (int i = 0; i &lt; objectList.size(); i++) { for (int j = 0; j &lt; objectList.get(i).size(); j++) { result =+ objectList.get(i).get(j); resultList.add(result); } } System.out.println(resultList.toString()); } } However, what I am currently getting is: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0] Any recommendations on how to fix that to get the desired output from the picture? I appreciate your answer! UPDATE Changing to += operator I am getting: [1.0, 3.0, 6.0, 10.0, 15.0, 21.0, 28.0, 29.0, 31.0, 34.0, 38.0, 43.0, 49.0, 56.0, 57.0, 59.0, 62.0, 66.0, 71.0, 77.0, 84.0] The list size has tripled. How to add the elements horizontally?
has comment: http://stackoverflow.com/comment/32591585
type: AnsweredQuestion
tagged with: list
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/32591236
tagged with: loops
has title: Adding up several lists horizontally
type: Question
has comment: http://stackoverflow.com/comment/32591271
tagged with: algorithm

http://stackoverflow.com/q/21674977
accepted answer: http://stackoverflow.com/a/21701422
type: Question
type: AnsweredQuestion
has title: element of list must not move when hovering in primefaces
tagged with: primefaces
tagged with: java
answer count: 1
has answer: http://stackoverflow.com/a/21701422
score: 0
has body: I have a list of elements and currently when I hover on the element selected in the list, the element moves slightly, I have thus created a class "remainStill" in the css &lt;p:selectOneMenu ... class="remainStill"&gt; &lt;f:selectItem itemLabel=".." /&gt; &lt;f:selectItems value="..." /&gt; &lt;/p:selectOneMenu&gt; and in the csss .remainStill{ border:0px; } but it does not work. Any ideas ?
tagged with: css

http://stackoverflow.com/a/59311206
answers question: http://stackoverflow.com/q/21653883
has comment: http://stackoverflow.com/comment/104825692
type: Answer
has body: Find out how many elemnts are in the Array. public class MultiArrayEx3 { public static void main(String[]args) { int[][] myNumbers = { {1,2,3,4,5}, {6,7,8,9} }; int x = myNumbers[0].length; int y = myNumbers[1].length; int z = x + y; System.out.println(z); } }
score: 0

file-io
tags question: http://stackoverflow.com/q/21599278
tags question: http://stackoverflow.com/q/21665733
tags question: http://stackoverflow.com/q/21633948
tags question: http://stackoverflow.com/q/21526461
tags question: http://stackoverflow.com/q/21559566
tags question: http://stackoverflow.com/q/21612168
tags question: http://stackoverflow.com/q/21648095
type: Tag
tags question: http://stackoverflow.com/q/21668382
tags question: http://stackoverflow.com/q/21618417
tags question: http://stackoverflow.com/q/21641303
tags question: http://stackoverflow.com/q/21651176
tags question: http://stackoverflow.com/q/21577137
tags question: http://stackoverflow.com/q/21523964
tags question: http://stackoverflow.com/q/21591522
tags question: http://stackoverflow.com/q/21643792
tags question: http://stackoverflow.com/q/21610021
tags question: http://stackoverflow.com/q/21660061
tag name: file-io
tags question: http://stackoverflow.com/q/21631638

filewriter
tag name: filewriter
tags question: http://stackoverflow.com/q/21647820
tags question: http://stackoverflow.com/q/21554109
type: Tag
tags question: http://stackoverflow.com/q/21537783

http://stackoverflow.com/comment/32746307
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21664441
has text: AFAIK services are usually run in UI thread, I'm not sure about this approach!
type: AnswerComment

http://stackoverflow.com/q/21521678
possible better answer: http://stackoverflow.com/a/21521696
score: -2
has answer: http://stackoverflow.com/a/21521696
downvote count: 2
answer count: 3
has answer: http://stackoverflow.com/a/21521699
tagged with: try-catch
tagged with: enums
tagged with: java
has answer: http://stackoverflow.com/a/21521748
type: AnsweredQuestion
upvote count: 0
accepted answer: http://stackoverflow.com/a/21521699
has title: JAVA error in try catch block
favorite count: 0
has body: I'm a beginner to java , and i was doing a simple program having classes in different files and creating the objects. I have two files called dataFile.java ( for data a,b,c which will take input from keyboard with the help of method getdata() ) another file is called classFile.java which is used for using the data from the other class and printing the sum. However im getting this error while compiling the dataFile.java Code for the dataFile.java is as follows import java.io.DataInputStream; class differentFile { DataInputStream input = new DataInputStream(System.in); int a,b,c; try { void getdata(){ a= Integer.valueOf(input.readLine()).intValue(); b=Integer.valueOf(input.readLine()).intValue(); c=Integer.valueOf(input.readLine()).intValue(); } } catch(Exeption e) { System.out.println(" IO ERROR "); } } and the error im finding is dataFile.java:8: error: illegal start of type try { ^ dataFile.java:8: error: ';' expected try { ^ dataFile.java:17: error: class, interface, or enum expected catch(Exeption e) { ^ dataFile.java:19: error: class, interface, or enum expected } ^ 4 errors I'm not familiar with these errors and according to the textbook im using the syntax is correct. It would be greatfull if anyone helped me with this . Thank you.
type: Question

http://stackoverflow.com/comment/32609194
score: 0
has text: You mean ... who called the method or on object of what type is the method called?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21586004

http://stackoverflow.com/comment/32628163
type: Comment
comment on: http://stackoverflow.com/a/21582038
score: 0
has text: I added getters related to my Set, changed my JSP to get an Array but I throw a new exception
type: AnswerComment

http://stackoverflow.com/comment/32717820
comment on: http://stackoverflow.com/a/21648087
has text: @Shervin If my link answers your question, yes ;).
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/21586960
tagged with: opengl
tagged with: math
tagged with: java
type: Question
answer count: 1
score: 0
tagged with: matrix
tagged with: shader
linked to: http://stackoverflow.com/q/21152556
type: UnansweredQuestion
has body: I am trying to model my scene in light space as preperation of my shadow mapping, however I am massively confused. The line that calculates the position in my shader: gl_Position = light_projection_matrix * light_view_matrix * light_model_matrix * position;, where position is a model coordinate (equal to world coordinate in my case) given by 3 floats, I am reading it as vec4 and that part has proven to be working. Now I use the following, coded in Java, for my matrices: lightModelMatrix.identity().multiply(modelMatrix); lightViewMatrix.identity().lookAt(new Vector3f(-20f, 7.5f, -20f), Vector3f.O, Vector3f.Y); lightProjectionMatrix.identity().frustum(-1f, 1f, -1f, 1f, -200f, 200f); Where modelMatrix is identity() I think that the issue is that the lookAt matrix is changing the .w component of my vector, I am not sure if that should be happening, I only know that the projection matrix must calculate a .w component. So this is the code for my lookAt: public Matrix4f lookAt(final Vector3f eye, final Vector3f at, final Vector3f up) { Vector3f zAxis = at.subtract(eye).normalized(); Vector3f xAxis = up.cross(zAxis).normalized(); Vector3f yAxis = zAxis.cross(xAxis); return multiply( xAxis.getX(), xAxis.getY(), xAxis.getZ(), -xAxis.dot(eye), //X column yAxis.getX(), yAxis.getY(), yAxis.getZ(), -yAxis.dot(eye), //Y column zAxis.getX(), zAxis.getY(), zAxis.getZ(), -zAxis.dot(eye), //Z column 0.0f, 0.0f, 0.0f, 1.0f //W column ); } All matrices in my code are defined in column major order. Also, what is a good way to debug the gl_Position that gets calculated in the Vertex Shader to see if an issue is there?
has title: Calculating lookAt matrix is not working out?
has answer: http://stackoverflow.com/a/21587195

http://stackoverflow.com/q/21599991
has comment: http://stackoverflow.com/comment/32668945
answer count: 0
has title: Chunking of corresponding data in java
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/32636021
has comment: http://stackoverflow.com/comment/32633400
score: 0
has comment: http://stackoverflow.com/comment/32638378
has comment: http://stackoverflow.com/comment/32633243
type: UnansweredQuestion
has body: I am new in java I want to chunk string which is present in arraylist. For Example : My String ="I am going to Department of agriculture science near to my house" then i want to chunk Department-of-agriculture-science which i added in arraylist in my code Another Example like "You can use either Iterator or ListIterator for traversing on Java ArrayList" From my code it will give problem something is wrong. but i want output as "You can use either Iterator or ListIterator-for-traversing-on-Java-ArrayList. "ListIterator for traversing" and "traversing on Java ArrayList" is already in arraylist. I want to chunk token only which i added in list like "Department of ayurveda" "ListIterator for traversing". if my string is "You can use either Iterator or ListIterator for traversing on Java ArrayList" then output should be "You can use either Iterator or ListIterator-for-traversing-on-Java-ArrayList" My Code : String input = "You can use either Iterator or ListIterator for traversing on Java ArrayList"; ArrayList&lt;String&gt; alPatterns = new ArrayList&lt;String&gt;(); alPatterns.add("Department of ayurveda"); alPatterns.add("science"); alPatterns.add("ListIterator for traversing"); alPatterns.add("for traversing on Java ArrayList"); int NoOfRecords = alPatterns.size(); int counter = 0; final int flags = Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE; Iterator it = alPatterns.iterator(); while (counter++ &lt; NoOfRecords) { try { String sPat = (String) it.next(); Pattern p = Pattern.compile(sPat, flags); Matcher m = p.matcher(input); OUTER: while (m.find()) { String sMatchFound = m.group(); String newstring = sMatchFound.replaceAll(" ", "-"); input = input.replaceAll(sMatchFound, newstring); continue OUTER; } System.out.println(input); } catch (Exception e) { e.printStackTrace(); } } }
tagged with: regex
has comment: http://stackoverflow.com/comment/32634926
has comment: http://stackoverflow.com/comment/32633544

http://stackoverflow.com/comment/32662497
type: QuestionComment
comment on: http://stackoverflow.com/q/21615990
has text: You might want to take a look at [Performing Custom Painting](http://docs.oracle.com/javase/tutorial/uiswing/painting/) and you might want to consider adding some information about what it is you are trying to achieve and why as it will produce a better quality of answer
score: 0
type: Comment

http://stackoverflow.com/comment/32567325
has text: Yep, setting `java.rmi.server.hostname` was the answer. I just did it incorrectly at first. Thanks.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21535650

http://stackoverflow.com/comment/32584287
type: Comment
has text: OP's not using any JSP at all. Also, as noted in comments, OP's trying to access `http://server/ServletExample` when it should be `http://server/WebApplicationName/HelloServlet/`.
comment on: http://stackoverflow.com/a/21571736
score: 0
type: AnswerComment

http://stackoverflow.com/comment/32673333
type: Comment
comment on: http://stackoverflow.com/a/21622800
has text: From edit to question *"I'm not using a container because well this isn't going to be set up as an applet.."* ?!? You seem to think a 'container' is something very different to what it actually is. Admittedly, [`Applet`](http://docs.oracle.com/javase/7/docs/api/java/applet/Applet.html) does inherit functionality from [`Container`](http://docs.oracle.com/javase/7/docs/api/java/awt/Container.html) but then, so does almost everything else that appears on-screen in a Java GUI (whether it is an embedded applet, or a free floating frame).
type: AnswerComment
score: 0

http://stackoverflow.com/comment/32758483
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/21671748
score: 0
has text: show some effort please.

http://stackoverflow.com/comment/32544365
comment on: http://stackoverflow.com/a/21550121
type: AnswerComment
has text: Whiich JDK are you using ?
type: Comment
score: 0

http://stackoverflow.com/comment/32585841
score: 1
has text: You only have to use SWT version >= 3.7.2 to get rid of this bug!
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21572423

http://stackoverflow.com/comment/32604726
comment on: http://stackoverflow.com/q/21583711
type: Comment
type: QuestionComment
has text: System.out.println (rooms)
score: 0

http://stackoverflow.com/comment/32704782
has text: Please define and expand on "doesn't work".
comment on: http://stackoverflow.com/q/21640541
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/21643853
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/32710105
type: Answer
has comment: http://stackoverflow.com/comment/32710172
downvote count: 0
score: 1
has body: As suggested in the comments to the question: Just do not scan the line you read for numbers, but parse it as a single number instead using Double.valueOf (I also beautified the rest of your code a little, see comments in there) public static void main( String[] args ) { Scanner scan = new Scanner(System.in); ArrayList&lt;Double&gt; myArr = new ArrayList&lt;Double&gt;(); int count = 0; System.out.println("Enter a number to be averaged, repeat up to 20 times:"); // we can use a for loop here to break on q and read the next line instead of that while you had here. for (String inputs = scan.nextLine() ; !inputs.matches("[qQ]") ; inputs = scan.nextLine()) { if (count == 20) { System.out.println("You entered more than 20 numbers, you suck!"); break; } try{ myArr.add(Double.valueOf(inputs)); count++; //that'S even shorter than count += 1, and does the exact same thing. System.out.println("Please enter another number or press Q for your average"); } catch (NumberFormatException e) { System.out.println("You entered more than one number, or not a valid number at all."); continue; // Skipping the input and carrying on, instead of just starting over. // If that's not what you want, just stay with what you had here } } Double average = calculate_average(myArr); System.out.println("Your average is: " + average); } (Code untested, so there may be errors in there. Please notify me if you got one ;))
has comment: http://stackoverflow.com/comment/32710186
accepted answer of: http://stackoverflow.com/q/21643592
answers question: http://stackoverflow.com/q/21643592

http://stackoverflow.com/a/21570066
score: 0
answers question: http://stackoverflow.com/q/21569859
type: Answer
has body: AFAIK Fragments are in context of a particular Activity and public methods in the activity can be accessed like getActivity().methodName(). Now If you want to change any data that has to be changed from the fragment then you may go by any of these two approaches : From your fragment call a public method of you base activity and within that public method you can get the context of MainActivity and change its public variables. I am not sure about the design or flow of your application but will recommend to create static variables and access and modify them using class names easily

http://stackoverflow.com/comment/32489309
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21518294
type: AnswerComment
has text: Make sure you are not returning the function inside the loop. I have tested the code and it works fine. I have updated the answer, take a look now.

celltable
type: Tag
tag name: celltable
tags question: http://stackoverflow.com/q/21558045
tags question: http://stackoverflow.com/q/21597274

http://stackoverflow.com/q/21592224
answer count: 3
tagged with: sql
has body: I need to get the result set from an executed batch : String [] queries = {"create volatile table testTable as (select * from orders) with data;", "select top 10 * from testTable;" , "drop table testTable" }; for (String query : queries) { statement.addBatch(query); } statement.executeBatch(); Ones i execute batch how can i get the result set from the select query ?
downvote count: 0
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/75388178
has answer: http://stackoverflow.com/a/21592458
score: 8
tagged with: java
upvote count: 8
type: Question
has title: How to get ResultSet from executeBatch?
has answer: http://stackoverflow.com/a/50351924
linked to: http://stackoverflow.com/q/21118698
has comment: http://stackoverflow.com/comment/32620460

http://stackoverflow.com/a/21602675
has body: That should just work: By default DropDownChoice will use the index to identify the selected enum value. No conversion is involved there.
type: AcceptedAnswer
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/32672405
answers question: http://stackoverflow.com/q/21599478
accepted answer of: http://stackoverflow.com/q/21599478

http://stackoverflow.com/comment/32729416
has text: Question rolled back. Original poster, please don't change your question so much so that the answer doesn't make sense.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21654735
score: 0

http://stackoverflow.com/q/21515659
score: 2
has title: Catch all exceptions within a thread
upvote count: 3
type: UnansweredQuestion
tagged with: multithreading
has answer: http://stackoverflow.com/a/21515735
tagged with: loops
has comment: http://stackoverflow.com/comment/32484354
downvote count: 1
has comment: http://stackoverflow.com/comment/32484245
type: Question
has body: Below is the code I have developed for a thread. int i; Thread thread = new Thread() { @Override public void run() { try { while(true) { sleep(10000); i++ } } catch (InterruptedException e) { e.printStackTrace(); } } }; thread.start(); Is there any possible way I can use any other catch or exception to catch all possible crushes within it? Thank you in advance!
tagged with: java
has comment: http://stackoverflow.com/comment/32484255
answer count: 2
has answer: http://stackoverflow.com/a/21515687
linked to: http://stackoverflow.com/q/21938
has comment: http://stackoverflow.com/comment/32484232
favorite count: 0
tagged with: while-loop
tagged with: android

http://stackoverflow.com/a/21613089
has comment: http://stackoverflow.com/comment/32794666
has body: Maybe I've missed something here but are you sure you're not overcomplicating things? If you want to expose a populated Calendar instance in your jsp, then after populating it just add it to the model in your controller method. Provided that Calendar has Java bean style properties for its providers and appointments then you can use dotted notation to access this data in the jsp. For example, without seeing any controller code: @Controller public class SomeController { @RequestMapping("/calendar") public String showCalendar(Model model) { Calendar calendar = getCalendar() // Or whatever you do to create it model.addAttribute("calendar", calendar); return "calendar"; } ... } And then in calendar.jsp: &lt;c:forEach var="appointment" items="${calendar.appointments}"&gt; &lt;c:out value="${appointment.time}" /&gt; &lt;%-- Access the fields in the usual manner --%&gt; &lt;/c:forEach&gt;
has comment: http://stackoverflow.com/comment/32657720
upvote count: 1
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/21592892
type: Answer
accepted answer of: http://stackoverflow.com/q/21592892
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/32659491

http://stackoverflow.com/comment/32750318
has text: @Kasra: Note that, in theory, the JIT compiler should be converting your micro-benchmark into native instructions. I don't know of a good way to confirm that. You may wish to do some research on what CPU is in your tablet. If it is ARMv7, it will have a floating-point co-processor. If it is ARMv5, it will not.
comment on: http://stackoverflow.com/a/21666622
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/21533206
has title: How do I use a QR code result from ZXing as a string?
has body: I got ZXing working using an intent, but I am really confused as how to use the output and save it as a string. Here is the intent: public void scan(View view) { try { Intent intent = new Intent("com.google.zxing.client.android.SCAN"); intent.putExtra("SCAN_MODE", "QR_CODE_MODE"); // "PRODUCT_MODE for bar codes startActivityForResult(intent, 0); } catch (Exception e) { Uri marketUri = Uri.parse("market://details?id=com.google.zxing.client.android"); Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri); startActivity(marketIntent); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 0) { if (resultCode == RESULT_OK) { String contents = data.getStringExtra("SCAN_RESULT"); } if(resultCode == RESULT_CANCELED){ //handle cancel } } } And trying to use it as a string: <TextView android:id="@+id/result" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/"title_activity_on_activity_result" android:layout_marginTop="45dp" android:layout_alignParentTop="true" android:layout_alignRight="@+id/button" android:layout_alignEnd="@+id/button" /> And finally the strings: TEST123 Hello world! Settings Scan ActivityResult onActivityResult Exception: EXCEPTION: main java.lang.RuntimeException: Unable to resume activity {com.JunkerDev.testfaggot/com.JunkerDev.testfaggot.MainActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=Intent { act=com.google.zxing.client.android.SCAN flg=0x80000 (has extras) }} to activity {com.JunkerDev.testfaggot/com.JunkerDev.testfaggot.MainActivity}: java.lang.NullPointerException How can I fix this problem?
answer count: 1
favorite count: 0
tagged with: android
type: UnansweredQuestion
upvote count: 1
tagged with: zxing
downvote count: 1
tagged with: java
has answer: http://stackoverflow.com/a/21533444
type: Question
score: 0

http://stackoverflow.com/q/21618628
accepted answer: http://stackoverflow.com/a/21619178
upvote count: 3
tagged with: java
has comment: http://stackoverflow.com/comment/32666746
score: 2
has comment: http://stackoverflow.com/comment/32667349
has comment: http://stackoverflow.com/comment/32667279
has answer: http://stackoverflow.com/a/29990057
has title: Passing data back and forth between activities
tagged with: android-listview
type: AnsweredQuestion
tagged with: android
possible better answer: http://stackoverflow.com/a/29990057
favorite count: 0
type: Question
has comment: http://stackoverflow.com/comment/32666880
has body: I have a MainActivity which has a ListView, when I click the ListView it opens a new activity for that item. I want to be able to change the information in that item, then when I click back it changes the ListView. Here's some of the code I have: MainActivity: String[] people; private ListView mListView; public static ArrayAdapter&lt;String&gt; adapter; In onCreate(){ people = new String[] {"", "", "", "", "", "", "", ""}; mListView = (ListView) findViewById(R.id.personListView); adapter = (new ArrayAdapter&lt;String&gt;(this, R.layout.list_item, people); mListView.setAdapter(adapter); mListView.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { // Current item String person = ((TextView) view).getText().toString(); // Launch new activity based on item Intent intent = new Intent(getApplicationContext(), SinglePerson.class); // intent.putExtra("person", person); //intent.putExtra("peopleList", people); intent.putExtra("position", position); startActivityForResult(intent, 1); // } }); I have this in the class which I thought would get the information from the other activity back but nothing happens: @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // Check which request we're responding to if (requestCode == 1) { // Make sure the request was successful if(resultCode == RESULT_OK){ int listPos = data.getIntExtra("listPosition", 1); //edit listview value at position people[listPos] = data.getStringExtra("edittextvalue"); adapter.notifyDataSetChanged(); } } } In the other activity class: public class SinglePerson extends Activity{ String[] people; int position; Intent intent; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); this.setContentView(R.layout.single_person_item_view); EditText txtPerson = (EditText) findViewById(R.id.person_name); intent = getIntent(); String person = intent.getS…
answer count: 2
has answer: http://stackoverflow.com/a/21619178
downvote count: 1

http://stackoverflow.com/q/21639096
has body: I want to play a video located in the assests folder of my application I get a message 'Impossible to play the video' I guess the path is incorrect this the code : String fileName = "android.resource://"+ getPackageName() +"/assets/video.3gp"; VideoView vv = (VideoView) this.findViewById(R.id.surface); vv.setVideoURI(Uri.parse(fileName)); vv.start();
tagged with: android
has comment: http://stackoverflow.com/comment/32702388
tagged with: video
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
has answer: http://stackoverflow.com/a/21639222
accepted answer: http://stackoverflow.com/a/21639222
type: Question
has title: Android VideoView load Audio/Video file from assets
tagged with: eclipse
answer count: 1
has comment: http://stackoverflow.com/comment/32702393
downvote count: 0
favorite count: 0

http://stackoverflow.com/comment/32530308
comment on: http://stackoverflow.com/a/21541428
score: 0
type: Comment
has text: Thank you, I actually didn't know how to really word it to search it up properly
type: AnswerComment

http://stackoverflow.com/comment/32623841
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/21593825
type: Comment
has text: oh, that's a valid reason, too :)

http://stackoverflow.com/q/21528921
has answer: http://stackoverflow.com/a/21529174
possible better answer: http://stackoverflow.com/a/21529139
answer count: 3
has comment: http://stackoverflow.com/comment/32507442
has answer: http://stackoverflow.com/a/21529099
favorite count: 0
has comment: http://stackoverflow.com/comment/32507364
upvote count: 2
tagged with: regex
has comment: http://stackoverflow.com/comment/32508201
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/21529099
score: 1
tagged with: java
has body: I just created an regular expression in Java, I want to look for expressions in about 5000 tweets, each tweet takes almost one second, why is it so slow?? If it's too complex that expression or there're something on it that it's too expensive to execute? I'd hope to process the whole data in less than 5 seconds for sure. The code is: public class RegularExpression { public static void main(String[] args) throws IOException { String filter = ".*\"created_at\":\"(.*?)\".*\"content\":\"(.*?word.*?)\",\"id\".*"; Pattern pattern = Pattern.compile(filter); List&lt;String&gt; tweets = FileUtils.readLines(new File("/tmp/tweets")); System.out.println("Start with " + tweets.size() ); int i=0; for (String t : tweets){ Matcher matcher = pattern.matcher(t); matcher.find(); System.out.println(i++); } System.out.println("End"); } } The input are JSON tweets. If I do my RE simpler it runs faster, but, I think that my RE isn't so heavy. I'd like to understand why this's happenng, I was just checking a test. UPDATED: The reason why I'm using RE when I try to parse JSON, it's because in the end, I could get a simple text, and XML, a JSON format, a log from any kind of server. So, I have to work with my input like plain-text.
downvote count: 1
type: Question
has title: Regular Expressions Java, why is this regex so slow?
has answer: http://stackoverflow.com/a/21529139

http://stackoverflow.com/a/21647904
downvote count: 0
has comment: http://stackoverflow.com/comment/32716900
has comment: http://stackoverflow.com/comment/32717289
type: Answer
has comment: http://stackoverflow.com/comment/32716959
answers question: http://stackoverflow.com/q/21647885
accepted answer of: http://stackoverflow.com/q/21647885
score: 3
upvote count: 3
has comment: http://stackoverflow.com/comment/32717307
has body: Yes, You have created a annonymous inner implementation class of ActionListener interface. And instantiate it and assigned to closeAction variable In short we can say that an anonymous class is an inner class that does not have a name at all. And whose instance is being created at the time of its creation. Check here for more details.
type: AcceptedAnswer

http://stackoverflow.com/q/21546817
upvote count: 0
has body: Ok so i have this code and obviously the "g = gd" from the render method isnt modifying the field value of "g". How can i make it so that the render method modifies the field g? I want to have a graphics field so i can use graphics to print strings outside the render method but i really have no idea how to do that. private Graphics g; private BufferedImage background; public Tutorial(Core core){ background = core.getResources().getImage(4); } public void render(Graphics gd) { g = gd; g.drawImage(background, 0, 0, null); } EDIT: ok this is the whole class how can i modify it so that the displayMessage will work ? tick() is called before render() , that might be a problem? package com.andrewxd.spaceinvaders.levels; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.image.BufferedImage; import com.andrewxd.spaceinvaders.main.Core; public class Tutorial implements Levels{ private Graphics g; private BufferedImage background; public Tutorial(Core core){ background = core.getResources().getImage(4); } public void render(Graphics gd) { g = gd; g.drawImage(background, 0, 0, null); } public void tick() { displayMessage("Welcome", 200,200); } public void displayMessage(String message, int x, int y) { g.setFont(new Font("ARIAL", Font.BOLD, 20)); g.setColor(Color.RED); g.drawString(message, x, y); } public void displayMessage(String message, int x, int y, Font font) { g.setFont(font); g.setColor(Color.WHITE); g.drawString(message, x, y); } public void displayMessage(String message, int x, int y, Font font, Color color) { g.setFont(font); g.setColor(color); g.drawString(message, x, y); } }
favorite count: 0
tagged with: return
has title: How can i return a value from a void method in java
has comment: http://stackoverflow.com/comment/32538752
answer count: 4
tagged with: void
has answer: http://stackoverflow.com/a/21546889
has answer: http://stackoverflow.com/a/21546910
has comment: http://stackoverflow.com/comment/32538508
type: UnansweredQuestion
tagged with: java
downvote count: 1
has comment: http://stackoverflow.com/comment/32538552
type: Question
has comment: http://stackoverflow.com/comment/32538488
has comment: http://stackoverflow.com/comment/32538605
score: -1
has answer: http://stackoverflow.com/a/21546901
has answer: http://stackoverflow.com/a/21546877

http://stackoverflow.com/comment/32707012
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/21641864
type: Comment
has text: Yes for 20+30+16+20+25

http://stackoverflow.com/comment/32484253
comment on: http://stackoverflow.com/a/21515531
type: Comment
has text: I've already coded this, but it's terribly inefficient. The point is to find a solution which does not rely on matrices. (question changed accordingly, and +1 anyways)
score: 0
type: AnswerComment

http://stackoverflow.com/q/21554875
type: UnansweredQuestion
has body: I am trying to display the line numbers alongside a jTextArea. Following is the code is used for purpose-> jScrollPane1.setRowHeaderView(jTextArea3); jTextArea1.getDocument().addDocumentListener(new DocumentListener() { public String getText() { int caretPosition = jTextArea1.getDocument().getLength(); Element root = jTextArea1.getDocument().getDefaultRootElement(); text = "1" + System.getProperty("line.separator"); for (int i = 2; i &lt; root.getElementIndex(caretPosition) + 2; i++) { text += i + System.getProperty("line.separator"); } return text; } @Override public void changedUpdate(DocumentEvent de) { jTextArea3.setText(getText()); } @Override public void insertUpdate(DocumentEvent de) { jTextArea3.setText(getText()); } @Override public void removeUpdate(DocumentEvent de) { jTextArea3.setText(getText()); } }); (where jTextArea3 is where the line numbers are displayed and jTextArea1 is where the text is entered. JScrollpane2 contains jTextArea3). It works fine, but at higher number of lines, there is problem-> http://imageshack.com/a/img36/737/yvhk.png (sry not yet allowed for direct image uploads) Any help please? PS-> I am using netbeans (just in the middle of learning java) and am using default layouts (that are auto generated by the software, this also implies default layout properties).
has comment: http://stackoverflow.com/comment/32553506
answer count: 0
has comment: http://stackoverflow.com/comment/32552983
has comment: http://stackoverflow.com/comment/32552791
type: Question
has title: Setting RowHeaderView width having a textarea as component
score: 0
tagged with: java

http://stackoverflow.com/q/21607563
has body: I have a program that will average your numbers from the command line. Everything is in the main method. 1. The program should run allowing you to enter one number at a time and when you press enter it asks you for another number or offers the ability to press Q to get your average. 2. The program has a limit set to 20 numbers added. When you hit 21 the program notifies you that you added to many numbers and shuts down. 3. If you enter multiple numbers on the same line and press enter, for every number you enter it System.out.println a message once for every number instead of just once. I would like to understand how to change the program to do these things. How to get the System.out.println to only appear one time per entry. How to get the program to output the average of 20 before it ends when someone enters 21 how do i change it to create a method for averaging outside of main then call on the averaging method inside the main. import java.util.Scanner; class programTwo { public static void main (String[] args) { Scanner scan = new Scanner(System.in); double sum = 0; int count = 0; System.out.println ("Enter your numbers to be averaged:"); String inputs = scan.nextLine(); while (!inputs.contains("q")) { Scanner scan2 = new Scanner(inputs); // create a new scanner out of our single line of input while(scan2.hasNextDouble()) { sum += scan2.nextDouble(); count += 1; System.out.println("Please enter another number or press Q for your average"); } if(count == 21) { System.out.println("You entered too many numbers! Fail."); return; } inputs = scan.nextLine(); } System.out.println("Your average is: " + (sum/count)); }
upvote count: 1
tagged with: methods
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/21607755
score: 0
answer count: 2
tagged with: program-entry-point
favorite count: 0
accepted answer: http://stackoverflow.com/a/21607755
possible better answer: http://stackoverflow.com/a/21607892
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21607892
has title: java program that finds average with average method
tagged with: syntax
tagged with: java

http://stackoverflow.com/comment/32573453
type: QuestionComment
score: 0
has text: I don't get it @MadProgrammer can you show me some example if it is not a problem.
comment on: http://stackoverflow.com/q/21565712
type: Comment

http://stackoverflow.com/comment/32627425
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/21595303
has text: @AnshulParashar Well am not having any fxml file. What to do now ?